1
0
Fork 0
wasp-os/wasp/apps/flashlight.py
Daniel Thompson 231f3b6fdd apps: software: Add an apps to enable/disable other apps
Currently wasp-os enables a narrow set of applications because we don't
want to consume RAM by importing the module and constructing the
application. We can improve on this situation by providing a small
(stateless) application that can be used to enable or diable applications.
This allows all the ROMed applications to be enabled using the GUI
without compromising on the ability to develop applications.

In fact this application significantlly reduces the RAM consumed in the
default case becasue the Self Test app does not need to maintain its
state.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2021-01-03 14:54:34 +00:00

42 lines
947 B
Python

# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
"""Flashlight
~~~~~~~~~~~~~
Shows a pure white screen with the backlight set to maximum.
"""
import wasp
import icons
class TorchApp(object):
"""Trivial flashlight application.
.. figure:: res/TorchApp.png
:width: 179
Screenshot of the flashlight application
"""
NAME = 'Torch'
ICON = icons.torch
def foreground(self):
"""Activate the application."""
self.draw()
wasp.system.request_tick(1000)
self._brightness = wasp.system.brightness
wasp.system.brightness = 3
def background(self):
"""De-activate the application (without losing state)."""
wasp.system.brightness = self._brightness
def tick(self, ticks):
wasp.system.keep_awake()
def draw(self):
"""Redraw the display from scratch."""
wasp.watch.drawable.fill(0xffff)