1
0
Fork 0

wasp: apps: Add a new (super simple) settings app

pull/24/head
Daniel Thompson 2020-04-10 20:30:20 +01:00
parent f734568ad2
commit 23368a659b
3 changed files with 43 additions and 0 deletions

View File

@ -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)

View File

@ -7,6 +7,7 @@ freeze('../..',
'apps/clock.py',
'apps/flashlight.py',
'apps/launcher.py',
'apps/settings.py',
'apps/testapp.py',
'boot.py',
'demo.py',

View File

@ -16,6 +16,7 @@ import widgets
from apps.clock import ClockApp
from apps.flashlight import FlashlightApp
from apps.launcher import LauncherApp
from apps.settings import SettingsApp
from apps.testapp import TestApp
class EventType():
@ -95,6 +96,7 @@ class Manager():
# TODO: Eventually these should move to main.py
self.register(ClockApp(), True)
self.register(FlashlightApp(), True)
self.register(SettingsApp(), True)
self.register(TestApp(), True)
def register(self, app, quick_ring=True):