1
0
Fork 0

wasp: st7789: Make fill() control sizing

This commit is contained in:
Daniel Thompson 2020-02-03 22:34:54 +00:00
parent 118b7bab00
commit 57035ce080

View file

@ -83,15 +83,22 @@ class ST7789(object):
self.write_data(bytearray([y >> 8, y & 0xff, yp >> 8, yp & 0xff])) self.write_data(bytearray([y >> 8, y & 0xff, yp >> 8, yp & 0xff]))
self.write_cmd(_RAMWR) self.write_cmd(_RAMWR)
def fill(self, bg): def fill(self, bg, x=0, y=0, w=None, h=None):
self.set_window() if not w:
w = self.width - x
if not h:
h = self.height - y
self.set_window(x, y, w, h)
# Populate the line buffer # Populate the line buffer
for x in range(0, 2 * self.width, 2): buf = memoryview(self.linebuffer)[0:2*w]
self.linebuffer[x] = bg >> 8 for xi in range(0, 2*w, 2):
self.linebuffer[x+1] = bg & 0xff buf[xi] = bg >> 8
for y in range(self.height): buf[xi+1] = bg & 0xff
self.write_data(self.linebuffer)
# Do the fill
for yi in range(h):
self.write_data(buf)
@micropython.native @micropython.native
def rleblit(self, image, pos=(0, 0), fg=0xffff, bg=0): def rleblit(self, image, pos=(0, 0), fg=0xffff, bg=0):