wasp: widgets: Add a scrolling indicator

As we enrich the navigation options we will increasinly need to visualize
between apps where up/down will switch us between rings and there
up/down is needed to scroll through content.
This commit is contained in:
Daniel Thompson 2020-04-05 09:48:03 +01:00
parent bb4e76d852
commit 2b5ebcef72
3 changed files with 24 additions and 1 deletions

View file

@ -11,6 +11,7 @@ class TestApp():
def __init__(self):
self.tests = ('Touch', 'String', 'Button', 'Crash')
self.test = self.tests[0]
self.scroll = wasp.widgets.ScrollIndicator()
def foreground(self):
"""Activate the application."""
@ -75,6 +76,7 @@ class TestApp():
draw.fill()
draw.string('{} test'.format(self.test),
0, 6, width=240)
self.scroll.draw()
if self.test == 'Crash':
draw.string("Press button to", 12, 24+24)

View file

@ -4,3 +4,8 @@
# 1-bit RLE, generated from res/battery.png, 189 bytes
battery = (36, 48, b'\x97\x0e\x14\x12\x11\x14\x10\x14\x0c\x08\x0c\x08\x08\x08\x0c\x08\x08\x08\x0c\x08\x08\x08\x0c\x08\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x0c\x04\x04\x04\x08\x04\x0b\x05\x04\x04\x08\x04\n\x06\x04\x04\x08\x04\t\x07\x04\x04\x08\x04\x08\x07\x05\x04\x08\x04\x07\x07\x06\x04\x08\x04\x06\x07\x07\x04\x08\x04\x05\x07\x08\x04\x08\x04\x04\x0e\x02\x04\x08\x04\x03\x0f\x02\x04\x08\x04\x02\x10\x02\x04\x08\x04\x02\x10\x02\x04\x08\x04\x02\x0f\x03\x04\x08\x04\x02\x0e\x04\x04\x08\x04\x08\x07\x05\x04\x08\x04\x07\x07\x06\x04\x08\x04\x06\x07\x07\x04\x08\x04\x05\x07\x08\x04\x08\x04\x04\x07\t\x04\x08\x04\x04\x06\n\x04\x08\x04\x04\x05\x0b\x04\x08\x04\x04\x04\x0c\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x1c\x08\x1c\x08\x1c\x08\x1c\x98')
# 1-bit RLE, generated from res/up_arrow.png, 16 bytes
up_arrow = (16, 9, b'\x07\x02\r\x04\x0b\x06\t\x08\x07\n\x05\x0c\x03\x0e\x01 ')
# 1-bit RLE, generated from res/down_arrow.png, 17 bytes
down_arrow = (16, 9, b'\x00 \x01\x0e\x03\x0c\x05\n\x07\x08\t\x06\x0b\x04\r\x02\x07')

View file

@ -11,7 +11,7 @@ class BatteryMeter(object):
def draw(self):
self.level = -2
self.update()
def update(self):
icon = icons.battery
draw = watch.drawable
@ -50,3 +50,19 @@ class BatteryMeter(object):
draw.fill(rgb, x, 38 - h, w, h)
self.level = level
class ScrollIndicator():
def __init__(self, x=240-18, y=240-24):
self._pos = (x, y)
self.up = True
self.down = True
def draw(self):
self.update()
def update(self):
draw = watch.drawable
if self.up:
draw.rleblit(icons.up_arrow, pos=self._pos, fg=0x7bef)
if self.down:
draw.rleblit(icons.down_arrow, pos=(self._pos[0], self._pos[1] + 13), fg=0x7bef)