summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
Diffstat (limited to 'wasp')
-rw-r--r--wasp/apps/clock.py24
-rw-r--r--wasp/apps/flashlight.py12
-rw-r--r--wasp/apps/testapp.py21
-rw-r--r--wasp/boards/dsd6/manifest.py3
-rw-r--r--wasp/boards/dsd6/watch.py3
-rw-r--r--wasp/boards/nitrogen/manifest.py3
-rw-r--r--wasp/boards/nitrogen/watch.py3
-rw-r--r--wasp/boards/pinetime/manifest.py5
-rw-r--r--wasp/boards/pinetime/watch.py3
-rw-r--r--wasp/boards/simulator/display.py3
-rw-r--r--wasp/boards/simulator/machine.py3
-rw-r--r--wasp/boards/simulator/micropython.py3
-rw-r--r--wasp/boards/simulator/watch.py3
-rw-r--r--wasp/boards/sphinx/machine.py3
-rw-r--r--wasp/boards/sphinx/watch.py3
-rw-r--r--wasp/boot.py3
-rw-r--r--wasp/demo.py3
-rw-r--r--wasp/draw565.py3
-rw-r--r--wasp/drivers/battery.py3
-rw-r--r--wasp/drivers/cst816s.py3
-rw-r--r--wasp/drivers/nrf_rtc.py3
-rw-r--r--wasp/drivers/signal.py3
-rw-r--r--wasp/drivers/st7789.py3
-rw-r--r--wasp/drivers/vibrator.py3
-rw-r--r--wasp/icons.py3
-rw-r--r--wasp/logo.py3
-rw-r--r--wasp/main.py8
-rw-r--r--wasp/shell.py3
-rw-r--r--wasp/wasp.py (renamed from wasp/manager.py)72
-rw-r--r--wasp/widgets.py3
30 files changed, 153 insertions, 61 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)
diff --git a/wasp/boards/dsd6/manifest.py b/wasp/boards/dsd6/manifest.py
index 9efab20..bee48c0 100644
--- a/wasp/boards/dsd6/manifest.py
+++ b/wasp/boards/dsd6/manifest.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
freeze('../..',
(
'demo.py',
diff --git a/wasp/boards/dsd6/watch.py b/wasp/boards/dsd6/watch.py
index fdfdba9..0148d95 100644
--- a/wasp/boards/dsd6/watch.py
+++ b/wasp/boards/dsd6/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
from machine import RTCounter as RTC
# Start measuring time (and feeding the watchdog)
diff --git a/wasp/boards/nitrogen/manifest.py b/wasp/boards/nitrogen/manifest.py
index f60ebd9..b17711b 100644
--- a/wasp/boards/nitrogen/manifest.py
+++ b/wasp/boards/nitrogen/manifest.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
freeze('../..',
(
'demo.py',
diff --git a/wasp/boards/nitrogen/watch.py b/wasp/boards/nitrogen/watch.py
index fdfdba9..0148d95 100644
--- a/wasp/boards/nitrogen/watch.py
+++ b/wasp/boards/nitrogen/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
from machine import RTCounter as RTC
# Start measuring time (and feeding the watchdog)
diff --git a/wasp/boards/pinetime/manifest.py b/wasp/boards/pinetime/manifest.py
index 6a19c1a..191ee3d 100644
--- a/wasp/boards/pinetime/manifest.py
+++ b/wasp/boards/pinetime/manifest.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
freeze('.', 'watch.py', opt=3)
freeze('../..',
(
@@ -17,8 +20,8 @@ freeze('../..',
'fonts/sans24.py',
'icons.py',
'logo.py',
- 'manager.py',
'shell.py',
+ 'wasp.py',
'widgets.py',
),
opt=3
diff --git a/wasp/boards/pinetime/watch.py b/wasp/boards/pinetime/watch.py
index 332d761..e4c4106 100644
--- a/wasp/boards/pinetime/watch.py
+++ b/wasp/boards/pinetime/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
# Start measuring time (and feeding the watchdog) before *anything* else
from machine import RTCounter
from drivers.nrf_rtc import RTC
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index 3d7d388..1a1e0c9 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
""" Simulated ST7789 display and CST816S touchscreen. """
import sys
diff --git a/wasp/boards/simulator/machine.py b/wasp/boards/simulator/machine.py
index 62a95c5..2fc9754 100644
--- a/wasp/boards/simulator/machine.py
+++ b/wasp/boards/simulator/machine.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import display
import time
diff --git a/wasp/boards/simulator/micropython.py b/wasp/boards/simulator/micropython.py
index 578a12d..41c30a4 100644
--- a/wasp/boards/simulator/micropython.py
+++ b/wasp/boards/simulator/micropython.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
def const(fn):
return fn
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index f38d7a1..ce281f4 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import time
def sleep_ms(ms):
time.sleep(ms / 1000)
diff --git a/wasp/boards/sphinx/machine.py b/wasp/boards/sphinx/machine.py
index b35a2a7..dfddb6d 100644
--- a/wasp/boards/sphinx/machine.py
+++ b/wasp/boards/sphinx/machine.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
class ADC():
pass
diff --git a/wasp/boards/sphinx/watch.py b/wasp/boards/sphinx/watch.py
index dccee44..57b590e 100644
--- a/wasp/boards/sphinx/watch.py
+++ b/wasp/boards/sphinx/watch.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import time
def sleep_ms(ms):
time.sleep(ms / 1000)
diff --git a/wasp/boot.py b/wasp/boot.py
index de05e13..3e9cae3 100644
--- a/wasp/boot.py
+++ b/wasp/boot.py
@@ -1 +1,4 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import watch
diff --git a/wasp/demo.py b/wasp/demo.py
index 6d3f6f5..a16c306 100644
--- a/wasp/demo.py
+++ b/wasp/demo.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
#
# Logo demo for PineTime
#
diff --git a/wasp/draw565.py b/wasp/draw565.py
index bd72c65..3f1f6cc 100644
--- a/wasp/draw565.py
+++ b/wasp/draw565.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import fonts.sans24
import micropython
diff --git a/wasp/drivers/battery.py b/wasp/drivers/battery.py
index cc1eafb..c13f117 100644
--- a/wasp/drivers/battery.py
+++ b/wasp/drivers/battery.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
# Generic lithium ion battery driver
from machine import Pin, ADC
diff --git a/wasp/drivers/cst816s.py b/wasp/drivers/cst816s.py
index 323b9cc..d0f3cd2 100644
--- a/wasp/drivers/cst816s.py
+++ b/wasp/drivers/cst816s.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
"""Hynitron CST816S touch contoller driver for MicroPython.
After modifying this file we can test the changes by replacing the
diff --git a/wasp/drivers/nrf_rtc.py b/wasp/drivers/nrf_rtc.py
index d907461..497c3d6 100644
--- a/wasp/drivers/nrf_rtc.py
+++ b/wasp/drivers/nrf_rtc.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
""" Real Time Clock based on the nRF-family low power counter """
import time
diff --git a/wasp/drivers/signal.py b/wasp/drivers/signal.py
index 18ce8bf..974adb5 100644
--- a/wasp/drivers/signal.py
+++ b/wasp/drivers/signal.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
class Signal(object):
'''Simplified Signal class
diff --git a/wasp/drivers/st7789.py b/wasp/drivers/st7789.py
index 89ebc4c..980435b 100644
--- a/wasp/drivers/st7789.py
+++ b/wasp/drivers/st7789.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
"""Sitronix ST7789 display driver for MicroPython.
Note: Although the ST7789 supports a variety of communication protocols
diff --git a/wasp/drivers/vibrator.py b/wasp/drivers/vibrator.py
index eba6018..3aee674 100644
--- a/wasp/drivers/vibrator.py
+++ b/wasp/drivers/vibrator.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
# Generic PWM capable vibrator
import time
diff --git a/wasp/icons.py b/wasp/icons.py
index 409a3d6..891b429 100644
--- a/wasp/icons.py
+++ b/wasp/icons.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
# 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')
diff --git a/wasp/logo.py b/wasp/logo.py
index f526e2a..2020550 100644
--- a/wasp/logo.py
+++ b/wasp/logo.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
pine64 = (240, 240, b'x\x01\xee\x03\xec\x05\xea\x07\xe8\t\xe6\x0b\xe4\r\xe2\x0f\xe0\x11\xde\x13\xdc\x15\xda\x17\xd8\x19\xd6\x1b\xd4\x1d\xd2\x1f\xd1 \xcf!\xce#\xcc%\xca\'\xc8)\xc6+\xc4-\xc3-\xc6\'\xcb#\xd0\x1d\xb6\x02\x1d\x19\x1b\x03\x99\x05\x1e\x13\x1c\x05\x99\x08\x1d\x0f\x1c\x08\x98\n\x1e\t\x1d\n\x97\r\x1e\x05\x1c\r\x97\x10:\x10\x96\x126\x12\x95\x151\x15\x95\x17-\x18\x93\x1b(\x1a\x93\x1d$\x1c\x93\x1e!\x1f\x91\x1d%\x1d\x91\x1b*\x1a\x91\x19.\x19\x8f\x17\x19\x01\x19\x17\x8f\x15\x19\x05\x19\x15\x8f\x13\x19\t\x1a\x13\x8d\x12\x19\r\x1a\x11\x8d\x10\x18\x12\x1a\x10\x8c\r\x19\x17\x19\x0e\x8b\x0c\x19\x1b\x19\x0c\x8b\n\x19\x1f\x1a\n\x89\t\x18$\x1a\x08\x89\x07\x18)\x19\x06\x89\x04\x19-\x19\x05\x87\x03\x191\x19\x03\x87\x01\x186\x19\x01\x9e;\xb3?\xafC\xabG\xa6L\xa2Q\x9dU\x98Z\x94^\x90c\x8bg\x87k\x85kn\x01\x18f\x1a\x01V\x03\x19a\x1a\x03V\x05\x19]\x1a\x05V\x07\x19Y\x19\x08V\n\x18T\x1a\nV\x0c\x19O\x1a\x0cV\x0e\x19K\x19\x0fV\x11\x18G\x19\x11V\x13\x18B\x1a\x13V\x16\x18=\x19\x16V\x18\x189\x19\x18V\x1a\x185\x19\x1aV\x1c\x181\x19\x1cV\x1f\x18+\x19\x1fV!\x18\'\x19!V#\x18#\x19#V%\x18\x1f\x18&V(\x17\x1a\x19(V*\x18\x15\x19*V,\x18\x11\x18-V/\x17\r\x18/V1\x17\x08\x191V4\x17\x03\x184V6.6V8*8V:&:V= =V<"<V:&:V7+8V505V3\x19\x01\x1a3V0\x1a\x05\x1b0V.\x19\x0b\x1a.V,\x19\x0f\x1a,V)\x1a\x13\x1b)V\'\x1a\x17\x1b\'V%\x19\x1d\x1a%V#\x19!\x1a#V \x1a%\x1b V\x1e\x1a)\x1b\x1eV\x1c\x1a.\x1a\x1cV\x19\x1b2\x1b\x19V\x17\x1a7\x1b\x17V\x14\x1b<\x1a\x15V\x12\x1b@\x1b\x12V\x10\x1aE\x1b\x10V\x0e\x1aI\x1b\x0eV\x0b\x1bM\x1c\x0bV\t\x1bQ\x1c\tV\x07\x1aW\x1b\x07V\x04\x1b[\x1b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c\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-\tc\t\x12\x0c\x0f!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-!-\tc\t-\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\xff\x00\x11')
diff --git a/wasp/main.py b/wasp/main.py
index cc4c8b6..88fb87e 100644
--- a/wasp/main.py
+++ b/wasp/main.py
@@ -1,3 +1,5 @@
-import manager, watch
-wasp = manager.Manager(watch)
-wasp.run()
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
+import wasp
+wasp.system.run()
diff --git a/wasp/shell.py b/wasp/shell.py
index 5ad9623..ace9513 100644
--- a/wasp/shell.py
+++ b/wasp/shell.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
# SPDX-License-Identifier: MIT
# Copyright (c) 2020 Daniel Thompson
# Copyright (c) 2016 Paul Sokolovsky
diff --git a/wasp/manager.py b/wasp/wasp.py
index 3dafebe..58607b2 100644
--- a/wasp/manager.py
+++ b/wasp/wasp.py
@@ -1,5 +1,10 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import gc
import machine
+import watch
+import widgets
from apps.clock import ClockApp
from apps.flashlight import FlashlightApp
@@ -16,9 +21,7 @@ EVENT_SWIPE_UPDOWN = 0x0004
EVENT_BUTTON = 0x0008
class Manager(object):
- def __init__(self, watch):
- self.watch = watch
-
+ def __init__(self):
self.app = None
self.applications = [
@@ -26,17 +29,17 @@ class Manager(object):
FlashlightApp(),
TestApp()
]
-
- self.watch.display.poweron()
- self.switch(self.applications[0])
- self.watch.backlight.set(2)
-
- self.sleep_at = watch.rtc.uptime + 90
self.charging = True
def switch(self, app):
if self.app:
self.app.background()
+ else:
+ # System start up...
+ watch.display.poweron()
+ watch.display.mute(True)
+ watch.backlight.set(2)
+ self.sleep_at = watch.rtc.uptime + 90
# Clear out any configuration from the old application
self.event_mask = 0
@@ -44,9 +47,9 @@ class Manager(object):
self.tick_expiry = None
self.app = app
- self.watch.display.mute(True)
- app.foreground(self)
- self.watch.display.mute(False)
+ watch.display.mute(True)
+ app.foreground()
+ watch.display.mute(False)
def navigate(self, direction=None):
"""Navigate between different applications.
@@ -55,12 +58,12 @@ class Manager(object):
"""
app_list = self.applications
- if direction == DOWN:
+ if direction == LEFT:
i = app_list.index(self.app) + 1
if i >= len(app_list):
i = 0
self.switch(app_list[i])
- elif direction == UP:
+ elif direction == RIGHT:
i = app_list.index(self.app) - 1
if i < 0:
i = len(app_list)-1
@@ -76,10 +79,10 @@ class Manager(object):
tick intervals are not possible.
"""
self.tick_period_ms = period_ms
- self.tick_expiry = self.watch.rtc.get_uptime_ms() + period_ms
+ self.tick_expiry = watch.rtc.get_uptime_ms() + period_ms
def handle_event(self, event):
- self.sleep_at = self.watch.rtc.uptime + 15
+ self.sleep_at = watch.rtc.uptime + 15
event_mask = self.event_mask
if event[0] < 5:
@@ -94,7 +97,7 @@ class Manager(object):
self.app.touch(event)
def tick(self):
- rtc = self.watch.rtc
+ rtc = watch.rtc
if self.sleep_at:
if rtc.update() and self.tick_expiry:
@@ -107,36 +110,36 @@ class Manager(object):
ticks += 1
self.app.tick(ticks)
- if self.watch.button.value():
- self.sleep_at = self.watch.rtc.uptime + 15
+ if watch.button.value():
+ self.sleep_at = watch.rtc.uptime + 15
- event = self.watch.touch.get_event()
+ event = watch.touch.get_event()
if event:
self.handle_event(event)
- if self.watch.rtc.uptime > self.sleep_at:
- self.watch.backlight.set(0)
+ if watch.rtc.uptime > self.sleep_at:
+ watch.backlight.set(0)
if not self.app.sleep():
self.switch(self.applications[0])
self.app.sleep()
- self.watch.display.poweroff()
- self.charging = self.watch.battery.charging()
+ watch.display.poweroff()
+ self.charging = watch.battery.charging()
self.sleep_at = None
gc.collect()
else:
- self.watch.rtc.update()
+ watch.rtc.update()
- charging = self.watch.battery.charging()
- if self.watch.button.value() or self.charging != charging:
- self.watch.display.poweron()
+ charging = watch.battery.charging()
+ if watch.button.value() or self.charging != charging:
+ watch.display.poweron()
self.app.wake()
- self.watch.backlight.set(2)
+ watch.backlight.set(2)
# Discard any pending touch events
- _ = self.watch.touch.get_event()
+ _ = watch.touch.get_event()
- self.sleep_at = self.watch.rtc.uptime + 15
+ self.sleep_at = watch.rtc.uptime + 15
def run(self):
"""Run the system manager synchronously.
@@ -145,6 +148,13 @@ class Manager(object):
normal execution context meaning any exceptions and other problems
can be observed interactively via the console.
"""
+ if not self.app:
+ self.switch(self.applications[0])
+
+ print('Watch is running, use Ctrl-C to stop')
+
while True:
self.tick()
machine.deepsleep()
+
+system = Manager()
diff --git a/wasp/widgets.py b/wasp/widgets.py
index 3b2d6e1..aac56da 100644
--- a/wasp/widgets.py
+++ b/wasp/widgets.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+
import icons
import watch