diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-03-22 12:37:19 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-03-22 12:37:19 (GMT) |
| commit | f8bd1a74613a79cad56b5b60079402d40a87d131 (patch) | |
| tree | a0ac41ef104c8a39375357e2d730d16b9602f86d /wasp/apps | |
| parent | 5a234c16ada5319228fd2231957ca64d2c9141f8 (diff) | |
Rename manager.py and expose its interfaces to all applications
This is a big change that break compatiblity with existing applications
*and* with existing installed versions of main.py.
When upgrading it is import to update main.py:
./tools/wasptool --upload wasp/main.py
Diffstat (limited to 'wasp/apps')
| -rw-r--r-- | wasp/apps/clock.py | 21 | ||||
| -rw-r--r-- | wasp/apps/flashlight.py | 9 | ||||
| -rw-r--r-- | wasp/apps/testapp.py | 18 |
3 files changed, 22 insertions, 26 deletions
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py index f99091a..55295aa 100644 --- a/wasp/apps/clock.py +++ b/wasp/apps/clock.py @@ -1,7 +1,6 @@ +import wasp + import fonts.clock as digits -import watch -import widgets -import manager DIGITS = ( digits.clock_0, @@ -18,28 +17,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 +55,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 +69,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..13341b0 100644 --- a/wasp/apps/flashlight.py +++ b/wasp/apps/flashlight.py @@ -1,5 +1,4 @@ -import watch -import manager +import wasp class FlashlightApp(object): """Trivial flashlight application. @@ -10,11 +9,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 +27,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 0ab33a3..fc32ea0 100644 --- a/wasp/apps/testapp.py +++ b/wasp/apps/testapp.py @@ -1,7 +1,5 @@ -import watch -import widgets -import manager import machine +import wasp class TestApp(): """Simple test application. @@ -11,11 +9,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_UPDOWN) + wasp.system.request_event(wasp.EVENT_TOUCH | wasp.EVENT_SWIPE_UPDOWN) def background(self): """De-activate the application (without losing state).""" @@ -33,7 +31,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 +53,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) |
