diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-05 08:48:03 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-06 21:04:21 (GMT) |
| commit | 2b5ebcef727af5d99ebaee224545510b668d63ae (patch) | |
| tree | e9f084497ff8a4a041a38fd830d62f862bd32040 /wasp | |
| parent | bb4e76d85222c263c4486ad1722df44200fcabf2 (diff) | |
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.
Diffstat (limited to 'wasp')
| -rw-r--r-- | wasp/apps/testapp.py | 2 | ||||
| -rw-r--r-- | wasp/icons.py | 5 | ||||
| -rw-r--r-- | wasp/widgets.py | 18 |
3 files changed, 24 insertions, 1 deletions
diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py index 3beca50..8c15848 100644 --- a/wasp/apps/testapp.py +++ b/wasp/apps/testapp.py @@ -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) diff --git a/wasp/icons.py b/wasp/icons.py index 891b429..c3089c4 100644 --- a/wasp/icons.py +++ b/wasp/icons.py @@ -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') diff --git a/wasp/widgets.py b/wasp/widgets.py index aac56da..9aa39a0 100644 --- a/wasp/widgets.py +++ b/wasp/widgets.py @@ -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) |
