summaryrefslogtreecommitdiff
path: root/wasp/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'wasp/widgets.py')
-rw-r--r--wasp/widgets.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/wasp/widgets.py b/wasp/widgets.py
index 9aa39a0..9271fe6 100644
--- a/wasp/widgets.py
+++ b/wasp/widgets.py
@@ -1,18 +1,35 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
+"""Widget library
+~~~~~~~~~~~~~~~~~
+
+The widget library allows common fragments of logic and drawing code to be
+shared between applications.
+"""
+
import icons
import watch
class BatteryMeter(object):
+ """Battery meter widget.
+
+ A simple battery meter with a charging indicator, will draw at the
+ top-right of the display.
+ """
def __init__(self):
self.level = -2
def draw(self):
+ """Draw from meter (from scratch)."""
self.level = -2
self.update()
def update(self):
+ """Update the meter.
+
+ The update is lazy and won't redraw unless the level has changed.
+ """
icon = icons.battery
draw = watch.drawable
@@ -52,15 +69,26 @@ class BatteryMeter(object):
self.level = level
class ScrollIndicator():
+ """Scrolling indicator.
+
+ A simple battery meter with a charging indicator, will draw at the
+ top-right of the display.
+ """
def __init__(self, x=240-18, y=240-24):
self._pos = (x, y)
self.up = True
self.down = True
def draw(self):
+ """Draw from scrolling indicator.
+
+ For this simple widget :py:meth:`~.draw` is simply a synonym for
+ :py:meth:`~.update`.
+ """
self.update()
def update(self):
+ """Update from scrolling indicator."""
draw = watch.drawable
if self.up:
draw.rleblit(icons.up_arrow, pos=self._pos, fg=0x7bef)