2020-04-10 21:30:20 +02:00
|
|
|
# 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
|
|
|
|
|
2020-05-24 15:20:20 +02:00
|
|
|
def __init__(self):
|
|
|
|
self._slider = wasp.widgets.Slider(3, 10, 90)
|
|
|
|
|
2020-04-10 21:30:20 +02:00
|
|
|
def foreground(self):
|
|
|
|
self._draw()
|
|
|
|
wasp.system.request_event(wasp.EventMask.TOUCH)
|
|
|
|
|
|
|
|
def touch(self, event):
|
2020-05-24 15:20:20 +02:00
|
|
|
self._slider.touch(event)
|
|
|
|
wasp.system.brightness = self._slider.value + 1
|
2020-04-10 21:30:20 +02:00
|
|
|
self._update()
|
|
|
|
|
|
|
|
def _draw(self):
|
|
|
|
"""Redraw the display from scratch."""
|
|
|
|
wasp.watch.drawable.fill()
|
2020-05-24 15:20:20 +02:00
|
|
|
wasp.watch.drawable.string('Brightness', 0, 6, width=240)
|
2020-04-10 21:30:20 +02:00
|
|
|
self._update()
|
|
|
|
|
|
|
|
def _update(self):
|
|
|
|
if wasp.system.brightness == 3:
|
|
|
|
say = "High"
|
|
|
|
elif wasp.system.brightness == 2:
|
|
|
|
say = "Mid"
|
|
|
|
else:
|
|
|
|
say = "Low"
|
2020-05-24 15:20:20 +02:00
|
|
|
wasp.watch.drawable.string(say, 0, 150, width=240)
|
|
|
|
self._slider.update()
|