diff --git a/wasp/demo.py b/wasp/demo.py index b8477db..1470ff5 100644 --- a/wasp/demo.py +++ b/wasp/demo.py @@ -1,27 +1,49 @@ -# Simple alternating logo demo +# +# Logo demo for PineTime +# +# This demo is simply an alternating sweep of the Pine64 and +# MicroPython logos. It cycles through a variety of colours +# and swaps between the logos every 5 images (so make sure +# len(colors) is not a multiple of 5 ;-) ). +# -import pinetime, logo, time +import pinetime, logo, time, gc + +colors = ( + 0xffff, + 0xf800, # red + 0xffff, + 0xffe0, # yellow + 0xffff, + 0x07e0, # green + 0xffff, + 0x07ff, # cyan + 0xffff, + 0x001f, # blue + 0xffff, + 0xf81f, # magenta + ) + +# Let's keep this where we can find it if someone delivers ^C to the +# demo +tft = pinetime.st7789() def run(): - colors = ( - 0xffff, - 0xf800, # red - 0xffff, - 0xffe0, # yellow - 0xffff, - 0x07e0, # green - 0xffff, - 0x07ff, # cyan - 0xffff, - 0x001f, # blue - 0xffff, - 0xf81f, # magenta - ) - - tft = pinetime.st7789() + l = logo.pine64 + i = 0 while True: for c in colors: - tft.rleblit(logo.sx, logo.sy, logo.image, fg=c) - time.sleep(2) + if i < 5: + i += 1 + else: + i = 0 + if l == logo.pine64: + l = logo.micropython + else: + l = logo.pine64 + tft.fill(0) + tft.rleblit(l, fg=c) + time.sleep(2) + gc.collect() diff --git a/wasp/drivers/st7789.py b/wasp/drivers/st7789.py index a7c3756..c3f22fc 100644 --- a/wasp/drivers/st7789.py +++ b/wasp/drivers/st7789.py @@ -83,15 +83,16 @@ class ST7789(object): for y in range(self.height): self.write_data(self.linebuffer) - def rleblit(self, sx, sy, image, fg=0xffff, bg=0): + def rleblit(self, image, fg=0xffff, bg=0): + (sx, sy, rle) = image self.set_window() - # TODO: rework algorithm to allow us to reuse the line buffer + # TODO: rework algorithm to allow us to reuse the line buffer buf = bytearray(2*sx) bp = 0 color = bg - for rl in image: + for rl in rle: while rl: buf[bp] = color >> 8 buf[bp+1] = color & 0xff diff --git a/wasp/logo.py b/wasp/logo.py index 605062e..f526e2a 100644 --- a/wasp/logo.py +++ b/wasp/logo.py @@ -1,3 +1,3 @@ -sx = 240 -sy = 240 -image = b'x\x01\xee\x03\xec\x05\xea\x07\xe8\t\xe6\x0b\xe4\r\xe2\x0f\xe0\x11\xde\x13\xdc\x15\xda\x17\xd8\x19\xd6\x1b\xd4\x1d\xd2\x1f\xd1 \xcf!\xce#\xcc%\xca\'\xc8)\xc6+\xc4-\xc3-\xc6\'\xcb#\xd0\x1d\xb6\x02\x1d\x19\x1b\x03\x99\x05\x1e\x13\x1c\x05\x99\x08\x1d\x0f\x1c\x08\x98\n\x1e\t\x1d\n\x97\r\x1e\x05\x1c\r\x97\x10:\x10\x96\x126\x12\x95\x151\x15\x95\x17-\x18\x93\x1b(\x1a\x93\x1d$\x1c\x93\x1e!\x1f\x91\x1d%\x1d\x91\x1b*\x1a\x91\x19.\x19\x8f\x17\x19\x01\x19\x17\x8f\x15\x19\x05\x19\x15\x8f\x13\x19\t\x1a\x13\x8d\x12\x19\r\x1a\x11\x8d\x10\x18\x12\x1a\x10\x8c\r\x19\x17\x19\x0e\x8b\x0c\x19\x1b\x19\x0c\x8b\n\x19\x1f\x1a\n\x89\t\x18$\x1a\x08\x89\x07\x18)\x19\x06\x89\x04\x19-\x19\x05\x87\x03\x191\x19\x03\x87\x01\x186\x19\x01\x9e;\xb3?\xafC\xabG\xa6L\xa2Q\x9dU\x98Z\x94^\x90c\x8bg\x87k\x85kn\x01\x18f\x1a\x01V\x03\x19a\x1a\x03V\x05\x19]\x1a\x05V\x07\x19Y\x19\x08V\n\x18T\x1a\nV\x0c\x19O\x1a\x0cV\x0e\x19K\x19\x0fV\x11\x18G\x19\x11V\x13\x18B\x1a\x13V\x16\x18=\x19\x16V\x18\x189\x19\x18V\x1a\x185\x19\x1aV\x1c\x181\x19\x1cV\x1f\x18+\x19\x1fV!\x18\'\x19!V#\x18#\x19#V%\x18\x1f\x18&V(\x17\x1a\x19(V*\x18\x15\x19*V,\x18\x11\x18-V/\x17\r\x18/V1\x17\x08\x191V4\x17\x03\x184V6.6V8*8V:&:V= =V<"\x06\x1cm\x1d\x06?\x08\x1ch\x1c\x08@\n\x1cd\x1c\nA\x0c\x1b_\x1c\x0cB\x0e\x1b[\x1c\x0eB\x11\x1bV\x1b\x11C\x12\x1bR\x1b\x12D\x14\x1bM\x1c\x14E\x16\x1aI\x1b\x16F\x18\x1aE\x1b\x18G\x1a\x1a?\x1b\x1aH\x1c\x1a;\x1b\x1cI\x1e\x197\x1a\x1eJ \x193\x1a J"\x1a-\x1b!L$\x19)\x1a$L&\x19%\x1a&M(\x18!\x1a\'N*\x19\x1c\x19*O+\x19\x18\x19+P.\x18\x13\x19.Q/\x18\x0f\x19/R2\x18\n\x182S3\x18\x05\x193T5\x18\x01\x195T8,8U9(9V<"\x06\x1cm\x1d\x06?\x08\x1ch\x1c\x08@\n\x1cd\x1c\nA\x0c\x1b_\x1c\x0cB\x0e\x1b[\x1c\x0eB\x11\x1bV\x1b\x11C\x12\x1bR\x1b\x12D\x14\x1bM\x1c\x14E\x16\x1aI\x1b\x16F\x18\x1aE\x1b\x18G\x1a\x1a?\x1b\x1aH\x1c\x1a;\x1b\x1cI\x1e\x197\x1a\x1eJ \x193\x1a J"\x1a-\x1b!L$\x19)\x1a$L&\x19%\x1a&M(\x18!\x1a\'N*\x19\x1c\x19*O+\x19\x18\x19+P.\x18\x13\x19.Q/\x18\x0f\x19/R2\x18\n\x182S3\x18\x05\x193T5\x18\x01\x195T8,8U9(9V<"