1
0
Fork 0

fix: by fgaz, thanks!

Signed-off-by: thiswillbeyourgithub <github@32mail.33mail.com>
This commit is contained in:
thiswillbeyourgithub 2022-04-12 09:53:23 +02:00 committed by Daniel Thompson
parent e5802839ec
commit c63c29fe76

View file

@ -13,6 +13,7 @@ Shows a bright screen that you can tap to change brightness or switch to redligh
import wasp import wasp
import icons import icons
class TorchApp(object): class TorchApp(object):
"""Trivial flashlight application.""" """Trivial flashlight application."""
NAME = 'Torch' NAME = 'Torch'
@ -20,13 +21,13 @@ class TorchApp(object):
def foreground(self): def foreground(self):
"""Activate the application.""" """Activate the application."""
wasp.system.request_tick(1000) wasp.system.request_tick(3000)
wasp.system.request_event(wasp.EventMask.TOUCH) 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._ntouch = 1
self.draw() wasp.watch.drawable.fill(0xffff) # white
def background(self): def background(self):
"""De-activate the application (without losing original state).""" """De-activate the application (without losing original state)."""
@ -35,16 +36,12 @@ class TorchApp(object):
def tick(self, ticks): def tick(self, ticks):
wasp.system.keep_awake() wasp.system.keep_awake()
def draw(self):
"""Redraw the display from scratch."""
if self.n_touch % 6 < 3:
wasp.watch.drawable.fill(0xffff)
else:
wasp.watch.drawable.fill(0xf800)
print("ok")
def touch(self, event): def touch(self, event):
self.n_touch += 1 self._ntouch += 1
n = (wasp.system.brightness - 1) % 3 self._ntouch %= 6
wasp.system.brightness = n if n else 3 wasp.system.brightness = (-self._ntouch) % 3 + 1
self.draw() if (-self._ntouch + 1) % 3 == 0:
if -self._ntouch % 6 < 3:
wasp.watch.drawable.fill(0xf800) # red
else:
wasp.watch.drawable.fill(0xffff) # white