2020-03-22 16:40:18 +01:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
# Copyright (C) 2020 Daniel Thompson
|
|
|
|
|
2020-03-22 13:37:19 +01:00
|
|
|
import wasp
|
2020-03-08 11:18:08 +01:00
|
|
|
|
|
|
|
class FlashlightApp(object):
|
|
|
|
"""Trivial flashlight application.
|
|
|
|
|
|
|
|
Shows a pure white screen with the backlight set to maximum.
|
|
|
|
"""
|
|
|
|
|
2020-03-22 13:37:19 +01:00
|
|
|
def foreground(self, effect=None):
|
2020-03-08 11:18:08 +01:00
|
|
|
"""Activate the application."""
|
|
|
|
self.on_screen = ( -1, -1, -1, -1, -1, -1 )
|
|
|
|
self.draw(effect)
|
2020-03-22 13:37:19 +01:00
|
|
|
wasp.system.request_tick(1000)
|
2020-03-08 11:18:08 +01:00
|
|
|
|
2020-03-26 23:12:05 +01:00
|
|
|
self._brightness = wasp.system.brightness
|
|
|
|
wasp.system.brightness = 3
|
|
|
|
|
2020-03-08 11:18:08 +01:00
|
|
|
def background(self):
|
|
|
|
"""De-activate the application (without losing state)."""
|
2020-03-26 23:12:05 +01:00
|
|
|
wasp.system.brightness = self._brightness
|
2020-03-08 11:18:08 +01:00
|
|
|
|
|
|
|
def sleep(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def tick(self, ticks):
|
2020-03-26 23:12:05 +01:00
|
|
|
wasp.system.keep_awake()
|
2020-03-08 11:18:08 +01:00
|
|
|
|
|
|
|
def draw(self, effect=None):
|
|
|
|
"""Redraw the display from scratch."""
|
2020-03-22 13:37:19 +01:00
|
|
|
display = wasp.watch.display
|
2020-03-08 11:18:08 +01:00
|
|
|
display.fill(0xffff)
|