2020-03-22 09:40:18 -06:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
# Copyright (C) 2020 Daniel Thompson
|
|
|
|
|
2020-05-14 15:29:35 -06:00
|
|
|
"""Flashlight
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Shows a pure white screen with the backlight set to maximum.
|
2021-01-13 14:51:17 -07:00
|
|
|
|
|
|
|
.. figure:: res/TorchApp.png
|
|
|
|
:width: 179
|
2020-05-14 15:29:35 -06:00
|
|
|
"""
|
|
|
|
|
2020-03-22 06:37:19 -06:00
|
|
|
import wasp
|
2020-03-08 04:18:08 -06:00
|
|
|
|
2020-04-06 15:03:05 -06:00
|
|
|
import icons
|
|
|
|
|
2021-01-03 07:54:34 -07:00
|
|
|
class TorchApp(object):
|
2021-01-13 14:51:17 -07:00
|
|
|
"""Trivial flashlight application."""
|
2020-04-06 15:03:05 -06:00
|
|
|
NAME = 'Torch'
|
|
|
|
ICON = icons.torch
|
2020-03-08 04:18:08 -06:00
|
|
|
|
2020-03-28 11:19:34 -06:00
|
|
|
def foreground(self):
|
2020-03-08 04:18:08 -06:00
|
|
|
"""Activate the application."""
|
2020-03-28 11:19:34 -06:00
|
|
|
self.draw()
|
2020-03-22 06:37:19 -06:00
|
|
|
wasp.system.request_tick(1000)
|
2020-03-08 04:18:08 -06:00
|
|
|
|
2020-03-26 16:12:05 -06:00
|
|
|
self._brightness = wasp.system.brightness
|
|
|
|
wasp.system.brightness = 3
|
|
|
|
|
2020-03-08 04:18:08 -06:00
|
|
|
def background(self):
|
|
|
|
"""De-activate the application (without losing state)."""
|
2020-03-26 16:12:05 -06:00
|
|
|
wasp.system.brightness = self._brightness
|
2020-03-08 04:18:08 -06:00
|
|
|
|
|
|
|
def tick(self, ticks):
|
2020-03-26 16:12:05 -06:00
|
|
|
wasp.system.keep_awake()
|
2020-03-08 04:18:08 -06:00
|
|
|
|
2020-03-28 11:19:34 -06:00
|
|
|
def draw(self):
|
2020-03-08 04:18:08 -06:00
|
|
|
"""Redraw the display from scratch."""
|
2020-06-22 15:21:13 -06:00
|
|
|
wasp.watch.drawable.fill(0xffff)
|