From bd41368d2b53091d6f3a841ee87e06621796ed30 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Fri, 12 Jun 2020 08:52:36 +0100 Subject: [PATCH] apps: steps: Fix the overnight step counter reset Signed-off-by: Daniel Thompson --- wasp/apps/steps.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wasp/apps/steps.py b/wasp/apps/steps.py index d114eff..f2b0382 100644 --- a/wasp/apps/steps.py +++ b/wasp/apps/steps.py @@ -37,10 +37,13 @@ class StepCounterApp(): watch.accel.reset() self._meter = wasp.widgets.BatteryMeter() self._count = 0 + self._last_clock = ( -1, -1, -1, -1, -1, -1 ) def foreground(self): """Activate the application.""" - self._last_clock = ( -1, -1, -1, -1, -1, -1 ) + # Force a redraw (without forgetting the current date) + lc = self._last_clock + self._last_clock = (lc[0], lc[1], lc[2], -1, -1, -1) self._draw() wasp.system.request_tick(1000) @@ -68,12 +71,13 @@ class StepCounterApp(): t1 = '{:02}:{:02}'.format(now[3], now[4]) draw.set_font(fonts.sans24) draw.string(t1, 48, 16, 240-96) - self._last_clock = now - self._meter.update() if now[2] != self._last_clock[2]: watch.accel.steps = 0 - draw.fill(60, 132-18, 180, 36) + draw.fill(0, 60, 132-18, 180, 36) + + self._last_clock = now + self._meter.update() count = watch.accel.steps t = str(count)