st7789_mpy
st7789_mpy copied to clipboard
Update st7789.c
a try to use a optimized box+r-algo each line is drawn only once todo: hollow rect to implement the algo counts the concated pixel for line-draw
a Box with R (or without) on the four edges from X1,Y1 to X2,Y2 and color MASK = left-top bit 0, right-top bit 1, left-bottom bit 2, right-bottom bit 3, future fill bit 4
on M5Fire: from machine import Pin, SPI import time import st7789,os import vga1_8x16 as font spi = SPI(2, baudrate=60000000) tft = st7789.ST7789(spi,320,240,reset=Pin(33, Pin.OUT),cs=Pin(14, Pin.OUT),dc=Pin(27, Pin.OUT),backlight=Pin(32, Pin.OUT),rotation=0) tft.init() tft.madctl(0x18) tft.inversion_mode(False) q1=time.ticks_us() tft.box(10,10,200,200,15,st7789.BLUE,16+1+8) tft.box(15,15,195,195,10,st7789.GREEN,1+8) tft.box(25,25,185,185,80,st7789.RED,1+2+4+8) tft.box(35,35,175,175,70,st7789.YELLOW,1+2+4+8+16) q2=time.ticks_us() print(q2-q1) tft.text(font,"HELLO",105-5*8//2,105-8,st7789.BLACK,st7789.YELLOW)
~300ms for all 4 filled boxes with 160MHz Clockspeed ~215ms with 240MHz