1
0
Fork 0

apps: stopwatch: Switch over the status bar widget

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2020-10-21 21:28:49 +01:00
parent 398ce598fc
commit fd4017c729

View file

@ -17,14 +17,12 @@ class StopwatchApp():
ICON = icons.app ICON = icons.app
def __init__(self): def __init__(self):
self._meter = wasp.widgets.BatteryMeter() self._bar = wasp.widgets.StatusBar()
self._reset() self._reset()
self._count = 0 self._count = 0
def foreground(self): def foreground(self):
"""Activate the application.""" """Activate the application."""
self._last_clock = ( -1, -1, -1, -1, -1, -1 )
self._draw() self._draw()
wasp.system.request_tick(97) wasp.system.request_tick(97)
wasp.system.request_event(wasp.EventMask.TOUCH | wasp.system.request_event(wasp.EventMask.TOUCH |
@ -113,7 +111,7 @@ class StopwatchApp():
self._last_count = -1 self._last_count = -1
self._update() self._update()
self._meter.draw() self._bar.draw()
self._draw_splits() self._draw_splits()
def _update(self): def _update(self):
@ -126,17 +124,8 @@ class StopwatchApp():
if self._count > 999*60*100: if self._count > 999*60*100:
self._reset() self._reset()
draw = wasp.watch.drawable # Update the statusbar
self._bar.update()
# Lazy update of the clock and battery meter
now = wasp.watch.rtc.get_localtime()
if now[4] != self._last_clock[4]:
t1 = '{:02}:{:02}'.format(now[3], now[4])
draw.set_font(fonts.sans28)
draw.set_color(0xe73c)
draw.string(t1, 48, 12, 240-96)
self._last_clock = now
self._meter.update()
if self._last_count != self._count: if self._last_count != self._count:
centisecs = self._count centisecs = self._count
@ -148,6 +137,7 @@ class StopwatchApp():
t1 = '{}:{:02}'.format(minutes, secs) t1 = '{}:{:02}'.format(minutes, secs)
t2 = '{:02}'.format(centisecs) t2 = '{:02}'.format(centisecs)
draw = wasp.watch.drawable
draw.set_font(fonts.sans36) draw.set_font(fonts.sans36)
draw.set_color(0xc67f) draw.set_color(0xc67f)
w = fonts.width(fonts.sans36, t1) w = fonts.width(fonts.sans36, t1)