new: brightness and color change of flashlight
Signed-off-by: thiswillbeyourgithub <github@32mail.33mail.com>
This commit is contained in:
parent
9adeea17bb
commit
e5802839ec
|
@ -4,14 +4,13 @@
|
||||||
"""Flashlight
|
"""Flashlight
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
Shows a pure white screen with the backlight set to maximum.
|
Shows a bright screen that you can tap to change brightness or switch to redlight.
|
||||||
|
|
||||||
.. figure:: res/TorchApp.png
|
.. figure:: res/TorchApp.png
|
||||||
:width: 179
|
:width: 179
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import wasp
|
import wasp
|
||||||
|
|
||||||
import icons
|
import icons
|
||||||
|
|
||||||
class TorchApp(object):
|
class TorchApp(object):
|
||||||
|
@ -21,14 +20,16 @@ class TorchApp(object):
|
||||||
|
|
||||||
def foreground(self):
|
def foreground(self):
|
||||||
"""Activate the application."""
|
"""Activate the application."""
|
||||||
self.draw()
|
|
||||||
wasp.system.request_tick(1000)
|
wasp.system.request_tick(1000)
|
||||||
|
wasp.system.request_event(wasp.EventMask.TOUCH)
|
||||||
|
|
||||||
self._brightness = wasp.system.brightness
|
self._brightness = wasp.system.brightness
|
||||||
wasp.system.brightness = 3
|
wasp.system.brightness = 3
|
||||||
|
self.n_touch = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
def background(self):
|
def background(self):
|
||||||
"""De-activate the application (without losing state)."""
|
"""De-activate the application (without losing original state)."""
|
||||||
wasp.system.brightness = self._brightness
|
wasp.system.brightness = self._brightness
|
||||||
|
|
||||||
def tick(self, ticks):
|
def tick(self, ticks):
|
||||||
|
@ -36,4 +37,14 @@ class TorchApp(object):
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
"""Redraw the display from scratch."""
|
"""Redraw the display from scratch."""
|
||||||
wasp.watch.drawable.fill(0xffff)
|
if self.n_touch % 6 < 3:
|
||||||
|
wasp.watch.drawable.fill(0xffff)
|
||||||
|
else:
|
||||||
|
wasp.watch.drawable.fill(0xf800)
|
||||||
|
print("ok")
|
||||||
|
|
||||||
|
def touch(self, event):
|
||||||
|
self.n_touch += 1
|
||||||
|
n = (wasp.system.brightness - 1) % 3
|
||||||
|
wasp.system.brightness = n if n else 3
|
||||||
|
self.draw()
|
||||||
|
|
Loading…
Reference in a new issue