summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-07-24 16:04:46 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-07-24 16:04:46 (GMT)
commit326e06bc6bda0abf02372c8f23f7c9e60cd5cfff (patch)
tree5ad634f403a0ebf1a9b441dae41b415d66e18b90
parenta01fb7df573e13a6f6b9fbf2e7688d4e9713df6d (diff)
StatusBar: Rename and add BLE connection status icon
Notifier was a dumb name so make it better. Now that we have a decent name it should be obvious how to handle the BLE connection status icon! Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
m---------micropython0
-rw-r--r--wasp/apps/clock.py3
-rw-r--r--wasp/boards/pinetime/watch.py.in2
-rw-r--r--wasp/boards/simulator/watch.py2
-rw-r--r--wasp/icons.py12
-rw-r--r--wasp/widgets.py17
6 files changed, 29 insertions, 7 deletions
diff --git a/micropython b/micropython
-Subproject 13f086deeb8b9195886fbbda0751302a67ff3c1
+Subproject 9d5e23fc71a54c64f21ae762050f4612530d65d
diff --git a/wasp/apps/clock.py b/wasp/apps/clock.py
index a3134a0..4fc2487 100644
--- a/wasp/apps/clock.py
+++ b/wasp/apps/clock.py
@@ -35,7 +35,7 @@ class ClockApp():
def __init__(self):
self.meter = wasp.widgets.BatteryMeter()
- self.notifier = wasp.widgets.Notifier()
+ self.notifier = wasp.widgets.StatusBar()
def foreground(self):
"""Activate the application."""
@@ -72,6 +72,7 @@ class ClockApp():
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.notifier.update()
self.on_screen = now
return False
diff --git a/wasp/boards/pinetime/watch.py.in b/wasp/boards/pinetime/watch.py.in
index aaed767..2e8813f 100644
--- a/wasp/boards/pinetime/watch.py.in
+++ b/wasp/boards/pinetime/watch.py.in
@@ -32,6 +32,8 @@ from drivers.st7789 import ST7789_SPI
from drivers.vibrator import Vibrator
from flash.flash_spi import FLASH
+from ubluepy import uart_connected as connected
+
class Backlight(object):
lo = Pin("BL_LO", Pin.OUT, value=0)
mid = Pin("BL_MID", Pin.OUT, value=1)
diff --git a/wasp/boards/simulator/watch.py b/wasp/boards/simulator/watch.py
index abdf571..de1b584 100644
--- a/wasp/boards/simulator/watch.py
+++ b/wasp/boards/simulator/watch.py
@@ -182,3 +182,5 @@ rtc = RTC()
touch = CST816S(I2C(0), Pin('TP_INT', Pin.IN, quiet=True), Pin('TP_RST', Pin.OUT, quiet=True))
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
+def connected():
+ return not (int(rtc.uptime / 30) & 1)
diff --git a/wasp/icons.py b/wasp/icons.py
index 2b55d9c..f7ecfbd 100644
--- a/wasp/icons.py
+++ b/wasp/icons.py
@@ -163,3 +163,15 @@ notification = (
b'\x12\xc4\x05\xc4\x14\xc4\x03\xc5\x14\xc5\x02\xde\x01\xff\x01\x01'
b'\xde\x0f\xc4\x1d\xc2\x0f'
)
+# 2-bit RLE, generated from res/blestatus.png, 104 bytes
+blestatus = (
+ b'\x02'
+ b'\x11 '
+ b'\x07\xc1\x10\xc2\x0f\xc3\x0e\xc4\r\xc5\x0c\xc6\x0b\xc7\n\xc3'
+ b'\x01\xc4\x03\xc2\x04\xc3\x02\xc4\x01\xc4\x03\xc3\x03\xc4\x01\xc4'
+ b'\x02\xc3\x02\xc4\x03\xc4\x01\xc3\x01\xc4\x05\xcb\x07\xc9\t\xc7'
+ b'\x0b\xc5\x0c\xc5\x0b\xc7\t\xc9\x07\xcb\x05\xc4\x01\xc3\x01\xc4'
+ b'\x03\xc4\x02\xc3\x02\xc4\x01\xc4\x03\xc3\x03\xc4\x01\xc2\x04\xc3'
+ b'\x02\xc4\x08\xc3\x01\xc4\t\xc7\n\xc6\x0b\xc5\x0c\xc4\r\xc3'
+ b'\x0e\xc2\x0f\xc1\t'
+)
diff --git a/wasp/widgets.py b/wasp/widgets.py
index 2fcac9e..7d30993 100644
--- a/wasp/widgets.py
+++ b/wasp/widgets.py
@@ -70,8 +70,8 @@ class BatteryMeter:
self.level = level
-class Notifier:
- """Show if there are pending notifications."""
+class StatusBar:
+ """Show BT status and if there are pending notifications."""
def __init__(self, x=8, y=8):
self._pos = (x, y)
@@ -85,16 +85,21 @@ class Notifier:
def update(self):
"""Update the widget.
-
- For this simple widget :py:meth:~.update` does nothing!
"""
draw = watch.drawable
(x, y) = self._pos
- if wasp.system.notifications:
+ if wasp.watch.connected():
+ draw.blit(icons.blestatus, x, y, fg=0x7bef)
+ if wasp.system.notifications:
+ draw.blit(icons.notification, x+24, y, fg=0x7bef)
+ else:
+ draw.fill(0, x+24, y, 32, 32)
+ elif wasp.system.notifications:
draw.blit(icons.notification, x, y, fg=0x7bef)
+ draw.fill(0, x+32, y, 32, 32)
else:
- draw.fill(0, x, y, 32, 32)
+ draw.fill(0, x, y, 56, 32)
class ScrollIndicator:
"""Scrolling indicator.