From be6c6b02b0cba2850c2d19ac175577c664a1f7e8 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Tue, 4 Feb 2020 08:47:14 +0000 Subject: [PATCH] wasp: clock: Reduce battery meter redraws The ADC on nRF doesn't run precisely stable which means the battery meter can flicker if updated too often. This will eventually be fixed by the framework but, for now, let's just force the update rate to be fairly slow. --- wasp/clock.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wasp/clock.py b/wasp/clock.py index a19398e..2eff802 100644 --- a/wasp/clock.py +++ b/wasp/clock.py @@ -25,14 +25,16 @@ class ClockApp(object): display.fill(0) display.rleblit(fonts.clock_colon, pos=(2*48, 80), fg=0xb5b6) + self.on_screen = ( -1, -1 ) self.update(watch) self.meter.draw() - def update(self, watch): now = watch.rtc.get_time() if now[0] == self.on_screen[0] and now[1] == self.on_screen[1]: - self.meter.update() + if now[1] % 2 == 0: + self.meter.update() + return False display = watch.display display.rleblit(DIGITS[now[1] % 10], pos=(4*48, 80)) @@ -42,3 +44,4 @@ class ClockApp(object): self.on_screen = now self.meter.update() + return True