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>
This commit is contained in:
Daniel Thompson 2020-07-24 17:04:46 +01:00
parent a01fb7df57
commit 326e06bc6b
6 changed files with 30 additions and 8 deletions

@ -1 +1 @@
Subproject commit 13f086deeb8b9195886fbbda0751302a67ff3c15
Subproject commit 9d5e23fc71a54c64f21ae762050f4612530d65d6

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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'
)

View file

@ -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.