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:
parent
a01fb7df57
commit
326e06bc6b
6 changed files with 30 additions and 8 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 13f086deeb8b9195886fbbda0751302a67ff3c15
|
Subproject commit 9d5e23fc71a54c64f21ae762050f4612530d65d6
|
|
@ -35,7 +35,7 @@ class ClockApp():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.meter = wasp.widgets.BatteryMeter()
|
self.meter = wasp.widgets.BatteryMeter()
|
||||||
self.notifier = wasp.widgets.Notifier()
|
self.notifier = wasp.widgets.StatusBar()
|
||||||
|
|
||||||
def foreground(self):
|
def foreground(self):
|
||||||
"""Activate the application."""
|
"""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[3] == self.on_screen[3] and now[4] == self.on_screen[4]:
|
||||||
if now[5] != self.on_screen[5]:
|
if now[5] != self.on_screen[5]:
|
||||||
self.meter.update()
|
self.meter.update()
|
||||||
|
self.notifier.update()
|
||||||
self.on_screen = now
|
self.on_screen = now
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ from drivers.st7789 import ST7789_SPI
|
||||||
from drivers.vibrator import Vibrator
|
from drivers.vibrator import Vibrator
|
||||||
from flash.flash_spi import FLASH
|
from flash.flash_spi import FLASH
|
||||||
|
|
||||||
|
from ubluepy import uart_connected as connected
|
||||||
|
|
||||||
class Backlight(object):
|
class Backlight(object):
|
||||||
lo = Pin("BL_LO", Pin.OUT, value=0)
|
lo = Pin("BL_LO", Pin.OUT, value=0)
|
||||||
mid = Pin("BL_MID", Pin.OUT, value=1)
|
mid = Pin("BL_MID", Pin.OUT, value=1)
|
||||||
|
|
|
@ -182,3 +182,5 @@ rtc = RTC()
|
||||||
touch = CST816S(I2C(0), Pin('TP_INT', Pin.IN, quiet=True), Pin('TP_RST', Pin.OUT, quiet=True))
|
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)
|
vibrator = Vibrator(Pin('MOTOR', Pin.OUT, value=0), active_low=True)
|
||||||
|
|
||||||
|
def connected():
|
||||||
|
return not (int(rtc.uptime / 30) & 1)
|
||||||
|
|
|
@ -163,3 +163,15 @@ notification = (
|
||||||
b'\x12\xc4\x05\xc4\x14\xc4\x03\xc5\x14\xc5\x02\xde\x01\xff\x01\x01'
|
b'\x12\xc4\x05\xc4\x14\xc4\x03\xc5\x14\xc5\x02\xde\x01\xff\x01\x01'
|
||||||
b'\xde\x0f\xc4\x1d\xc2\x0f'
|
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'
|
||||||
|
)
|
||||||
|
|
|
@ -70,8 +70,8 @@ class BatteryMeter:
|
||||||
|
|
||||||
self.level = level
|
self.level = level
|
||||||
|
|
||||||
class Notifier:
|
class StatusBar:
|
||||||
"""Show if there are pending notifications."""
|
"""Show BT status and if there are pending notifications."""
|
||||||
def __init__(self, x=8, y=8):
|
def __init__(self, x=8, y=8):
|
||||||
self._pos = (x, y)
|
self._pos = (x, y)
|
||||||
|
|
||||||
|
@ -85,16 +85,21 @@ class Notifier:
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the widget.
|
"""Update the widget.
|
||||||
|
|
||||||
For this simple widget :py:meth:~.update` does nothing!
|
|
||||||
"""
|
"""
|
||||||
draw = watch.drawable
|
draw = watch.drawable
|
||||||
(x, y) = self._pos
|
(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.blit(icons.notification, x, y, fg=0x7bef)
|
||||||
|
draw.fill(0, x+32, y, 32, 32)
|
||||||
else:
|
else:
|
||||||
draw.fill(0, x, y, 32, 32)
|
draw.fill(0, x, y, 56, 32)
|
||||||
|
|
||||||
class ScrollIndicator:
|
class ScrollIndicator:
|
||||||
"""Scrolling indicator.
|
"""Scrolling indicator.
|
||||||
|
|
Loading…
Reference in a new issue