From fd4017c729c8aa7f493efc8b1cd2db57d5988499 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Wed, 21 Oct 2020 21:28:49 +0100 Subject: [PATCH] apps: stopwatch: Switch over the status bar widget Signed-off-by: Daniel Thompson --- wasp/apps/stopwatch.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/wasp/apps/stopwatch.py b/wasp/apps/stopwatch.py index 8eab273..807830c 100644 --- a/wasp/apps/stopwatch.py +++ b/wasp/apps/stopwatch.py @@ -17,14 +17,12 @@ class StopwatchApp(): ICON = icons.app def __init__(self): - self._meter = wasp.widgets.BatteryMeter() + self._bar = wasp.widgets.StatusBar() self._reset() self._count = 0 def foreground(self): """Activate the application.""" - self._last_clock = ( -1, -1, -1, -1, -1, -1 ) - self._draw() wasp.system.request_tick(97) wasp.system.request_event(wasp.EventMask.TOUCH | @@ -113,7 +111,7 @@ class StopwatchApp(): self._last_count = -1 self._update() - self._meter.draw() + self._bar.draw() self._draw_splits() def _update(self): @@ -126,17 +124,8 @@ class StopwatchApp(): if self._count > 999*60*100: self._reset() - draw = wasp.watch.drawable - - # 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() + # Update the statusbar + self._bar.update() if self._last_count != self._count: centisecs = self._count @@ -148,6 +137,7 @@ class StopwatchApp(): t1 = '{}:{:02}'.format(minutes, secs) t2 = '{:02}'.format(centisecs) + draw = wasp.watch.drawable draw.set_font(fonts.sans36) draw.set_color(0xc67f) w = fonts.width(fonts.sans36, t1)