diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-02-23 20:51:58 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-02-23 20:51:58 (GMT) |
| commit | c3d4ddafbca4b2a4e341b3bcfe42ac4ab73e7146 (patch) | |
| tree | 0ff09cc532ce9c7becb4a8bb0ac93a0c158a6588 /wasp/clock.py | |
| parent | 5c0d86d938731b1dbb35f1cef09698af32fcf6e3 (diff) | |
wasp: clock: Add some docstrings
Diffstat (limited to 'wasp/clock.py')
| -rw-r--r-- | wasp/clock.py | 12 |
1 files changed, 11 insertions, 1 deletions
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() |
