diff options
Diffstat (limited to 'wasp/apps')
| -rw-r--r-- | wasp/apps/clock.py | 24 | ||||
| -rw-r--r-- | wasp/apps/flashlight.py | 12 | ||||
| -rw-r--r-- | wasp/apps/testapp.py | 21 |
3 files changed, 31 insertions, 26 deletions
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py index f99091a..bc612b2 100644 --- a/wasp/apps/clock.py +++ b/wasp/apps/clock.py @@ -1,7 +1,9 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson + +import wasp + import fonts.clock as digits -import watch -import widgets -import manager DIGITS = ( digits.clock_0, @@ -18,28 +20,28 @@ DIGITS = ( MONTH = 'JanFebMarAprMayJunJulAugSepOctNovDec' -class ClockApp(object): +class ClockApp(): """Simple digital clock application. Shows a time (as HH:MM) together with a battery meter and the date. """ def __init__(self): - self.meter = widgets.BatteryMeter() + self.meter = wasp.widgets.BatteryMeter() def handle_event(self, event_view): """Process events that the app is subscribed to.""" - if event_view[0] == manager.EVENT_TICK: + if event_view[0] == wasp.EVENT_TICK: self.update() else: # TODO: Raise an unexpected event exception pass - def foreground(self, manager, effect=None): + def foreground(self, effect=None): """Activate the application.""" self.on_screen = ( -1, -1, -1, -1, -1, -1 ) self.draw(effect) - manager.request_tick(1000) + wasp.system.request_tick(1000) def tick(self, ticks): self.update() @@ -56,7 +58,7 @@ class ClockApp(object): def draw(self, effect=None): """Redraw the display from scratch.""" - draw = watch.drawable + draw = wasp.watch.drawable draw.fill() draw.rleblit(digits.clock_colon, pos=(2*48, 80), fg=0xb5b6) @@ -70,14 +72,14 @@ class ClockApp(object): The updates are a lazy as possible and rely on an prior call to draw() to ensure the screen is suitably prepared. """ - now = watch.rtc.get_localtime() + now = wasp.watch.rtc.get_localtime() if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]: if now[5] != self.on_screen[5]: self.meter.update() self.on_screen = now return False - draw = watch.drawable + draw = wasp.watch.drawable draw.rleblit(DIGITS[now[4] % 10], pos=(4*48, 80)) draw.rleblit(DIGITS[now[4] // 10], pos=(3*48, 80), fg=0xbdb6) draw.rleblit(DIGITS[now[3] % 10], pos=(1*48, 80)) diff --git a/wasp/apps/flashlight.py b/wasp/apps/flashlight.py index f1f9418..3336cfa 100644 --- a/wasp/apps/flashlight.py +++ b/wasp/apps/flashlight.py @@ -1,5 +1,7 @@ -import watch -import manager +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson + +import wasp class FlashlightApp(object): """Trivial flashlight application. @@ -10,11 +12,11 @@ class FlashlightApp(object): def __init__(self): self.backlight = None - def foreground(self, manager, effect=None): + def foreground(self, effect=None): """Activate the application.""" self.on_screen = ( -1, -1, -1, -1, -1, -1 ) self.draw(effect) - manager.request_tick(1000) + wasp.system.request_tick(1000) def background(self): """De-activate the application (without losing state).""" @@ -28,5 +30,5 @@ class FlashlightApp(object): def draw(self, effect=None): """Redraw the display from scratch.""" - display = watch.display + display = wasp.watch.display display.fill(0xffff) diff --git a/wasp/apps/testapp.py b/wasp/apps/testapp.py index 9f512f1..af531eb 100644 --- a/wasp/apps/testapp.py +++ b/wasp/apps/testapp.py @@ -1,7 +1,8 @@ -import watch -import widgets -import manager +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson + import machine +import wasp class TestApp(): """Simple test application. @@ -11,11 +12,11 @@ class TestApp(): self.tests = ('Touch', 'String') self.test = self.tests[0] - def foreground(self, system, effect=None): + def foreground(self, effect=None): """Activate the application.""" self.on_screen = ( -1, -1, -1, -1, -1, -1 ) self.draw(effect) - system.request_event(manager.EVENT_TOUCH | manager.EVENT_SWIPE_LEFTRIGHT) + wasp.system.request_event(wasp.EVENT_TOUCH | wasp.EVENT_SWIPE_UPDOWN) def background(self): """De-activate the application (without losing state).""" @@ -33,7 +34,7 @@ class TestApp(): self.draw() def touch(self, event): - draw = watch.drawable + draw = wasp.watch.drawable if self.test == 'Touch': draw.string('({}, {})'.format(event[1], event[2]), 0, 108, width=240) @@ -55,8 +56,8 @@ class TestApp(): def draw(self, effect=None): """Redraw the display from scratch.""" - watch.display.mute(True) - watch.drawable.fill() - watch.drawable.string('{} test'.format(self.test), + wasp.watch.display.mute(True) + wasp.watch.drawable.fill() + wasp.watch.drawable.string('{} test'.format(self.test), 0, 6, width=240) - watch.display.mute(False) + wasp.watch.display.mute(False) |
