From c3d4ddafbca4b2a4e341b3bcfe42ac4ab73e7146 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 23 Feb 2020 20:51:58 +0000 Subject: [PATCH] wasp: clock: Add some docstrings --- wasp/clock.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wasp/clock.py b/wasp/clock.py index 68dc52f..54a5a0e 100644 --- a/wasp/clock.py +++ b/wasp/clock.py @@ -19,12 +19,17 @@ DIGITS = ( MONTH = 'JanFebMarAprMayJunJulAugSepOctNovDec' class ClockApp(object): + """Simple digital clock application. + + Shows a time (as HH:MM) together with a battery meter and the date. + """ def __init__(self): self.on_screen = ( -1, -1, -1, -1, -1, -1 ) self.meter = widgets.BatteryMeter() def draw(self, watch): + """Redraw the display from scratch.""" display = watch.display display.fill(0) @@ -34,6 +39,11 @@ class ClockApp(object): self.meter.draw() def update(self, watch): + """Update the display (if needed). + + The updates are a lazy as possible and rely on an prior call to + draw() to ensure the screen is suitably prepared. + """ now = watch.rtc.get_localtime() if now[3] == self.on_screen[3] and now[4] == self.on_screen[4]: if now[5] != self.on_screen[5]: @@ -51,7 +61,7 @@ class ClockApp(object): draw = Draw565(display) month = now[1] - 1 month = MONTH[month*3:(month+1)*3] - draw.string('{}-{}-{}'.format(now[2], month, now[0]), + draw.string('{} {} {}'.format(now[2], month, now[0]), 0, 180, width=240) self.meter.update()