diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-10 19:30:20 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-10 19:30:20 (GMT) |
| commit | 23368a659b6fcd69b62e2024dacb18bdf8146840 (patch) | |
| tree | 4ded87534a5734c78d8b410ed44ed9fcfa7ecee6 /wasp/apps/settings.py | |
| parent | f734568ad20b47fdd121b13aae8cebda4ea57d5a (diff) | |
wasp: apps: Add a new (super simple) settings app
Diffstat (limited to 'wasp/apps/settings.py')
| -rw-r--r-- | wasp/apps/settings.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/wasp/apps/settings.py b/wasp/apps/settings.py new file mode 100644 index 0000000..6a268a9 --- /dev/null +++ b/wasp/apps/settings.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson +"""Ultra-simple settings application. + +Currently the settings application contains only one setting: brightness +""" + +import wasp +import icons + +class SettingsApp(): + NAME = 'Settings' + ICON = icons.settings + + def foreground(self): + self._draw() + wasp.system.request_event(wasp.EventMask.TOUCH) + + def touch(self, event): + brightness = wasp.system.brightness + 1 + if brightness > 3: + brightness = 1 + wasp.system.brightness = brightness + self._update() + + def _draw(self): + """Redraw the display from scratch.""" + wasp.watch.drawable.fill() + wasp.watch.drawable.string('Settings', 0, 6, width=240) + wasp.watch.drawable.string('Brightness', 0, 120 - 3 - 24, width=240) + self._update() + + def _update(self): + if wasp.system.brightness == 3: + say = "High" + elif wasp.system.brightness == 2: + say = "Mid" + else: + say = "Low" + wasp.watch.drawable.string(say, 0, 120 + 3, width=240) |
