Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bmsleight/8785aa85aecea33037f2ff54abaf5a89 to your computer and use it in GitHub Desktop.
Save bmsleight/8785aa85aecea33037f2ff54abaf5a89 to your computer and use it in GitHub Desktop.
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
"""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 if you change
anything make sure len(colors) is not a multiple of 5).
"""
import wasp
import icons
# 2-bit RLE, generated from res/demo_icon.png, 292 bytes
demo_icon = (
b'\x02'
b'`@'
b'.\xc1?\x1f\xc3?\x1d\xc5?\x1b\xc7?\x19\xc9?\x17'
b'\xcb?\x16\xcc?\x10\xc1\x06\xc8\x06\xc1?\n\xc4\x06\xc4'
b'\x06\xc3?\n\xc6\x0c\xc6?\x08\xc9\x08\xc8?\x08\xc7\x0c'
b'\xc7?\x06\xc6\x06\xc4\x06\xc5?\x06\xc4\x05\xc9\x06\xc3?'
b'\x06\xc1\x06\xce\x05\xc2?\n\xd2?\x0c\xd7?\x08\xdc?'
b'\x05\xdc\x05\xc18\xc3\x05\xd7\x06\xc38\xc5\x06\xd2\x05\xc6'
b'8\xc7\x06\xce\x05\xc88\xca\x05\xc9\x06\xca8\xcc\x06\xc4'
b'\x06\xcc8\xce\x0b\xcf8\xd0\x08\xd08\xce\x0b\xcf8\xcc'
b'\x06\xc4\x06\xcc8\xc9\x06\xc9\x06\xca8\xc7\x06\xcd\x06\xc8'
b'8\xc5\x06\xd2\x06\xc58\xc3\x05\xd7\x06\xc3>\xdb\x06\xc1'
b'<\xe08\xc2\x06\xdf\x07\xc12\xc3\x06\xdb\x06\xc42\xc6'
b'\x06\xd6\x06\xc54\xc7\x06\xd1\x06\xc84\xca\x05\xcd\x06\xc9'
b'6\xcb\x06\xc8\x05\xcc6\xcd\x06\xc3\x06\xcd7\xd0\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'
b'\t-!-\t-\t-\t-!-\t-\t-'
b'\t-!-\t-\t-\t-!-\t-\t-'
b'\t-!-\t-\t-\t-!-\t-\t-'
b'\t-!-\t-\t-\t-!-\t-\t-'
b'\t-!-\t-\t-\t-!-\t-\t-'
b'\t-!-\t-\t-\t-!-\tc\t-'
b'!-\tc\t-!-\tc\t-!-\tc'
b'\t-!-\tc\t-!-\tc\t-!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-'
b'\tc\t\x12\x0c\x0f!-\tc\t-!-\tc'
b'\t-!-\tc\t-!-\tc\t-!-'
b'\tc\t-!-\tc\t-!-\tc\t-'
b'!-\tc\t-!-\tc\t-!-\tc'
b'\t-!-\tc\t-!-\tc\t-!-'
b'\tc\t-!-\tc\t-!-\tc\t-'
b'!-\tc\t-!-\tc\t-!-\tc'
b'\t-\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00'
b'\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00'
b'\xff\x00\x11'
)
class DemoApp():
"""Application for live demos.
Start this to give the watch something "interesting" to do when talking
over demos!
"""
NAME = 'Demo'
ICON = demo_icon
def __init__(self):
pass
def foreground(self):
"""Draw the first frame and establish the tick."""
self._draw()
wasp.system.request_tick(5000)
def tick(self, ticks):
"""Handle the tick."""
self._draw()
wasp.system.keep_awake()
def _draw(self):
"""Draw the next frame."""
draw = wasp.watch.drawable
# Works with micropython logo
self._logo = micropython
draw.rleblit(self._logo)
# Works with calling _rle2bit directly
self._logo = demo_icon
draw._rle2bit(self._logo, 0, 0, fg=0xffff, c1=0x4a69, c2=0x7bef)
# Does not work with demo logo & rleblit
self._logo = demo_icon
draw.rleblit(self._logo)
# Crashes on above line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment