Skip to content

Commit

Permalink
vinscant: the request to leddy is now "asynchronous"
Browse files Browse the repository at this point in the history
  • Loading branch information
draxaris1010 committed Jun 24, 2024
1 parent d401ad3 commit 3b4966e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions vinscant/mpfiles/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from machine import bitstream, Pin, PWM, WDT
from machine import bitstream, Pin, PWM, WDT, Timer
from neopixel import NeoPixel
import esp32
import gc
Expand Down Expand Up @@ -63,11 +63,14 @@ def idle(self):
self.led.setColor(*StatusNotifier.colors[self.state])
self.state = (self.state + 1) % 3

def gotoSleep(self):
def gotoSleep(self, timer: Timer = None):
print("(StatusNotifier will sleep and feed watchdog for some time)")
watchdog.feed()
time.sleep(.5)
watchdog.feed()
if timer:
timer.deinit()
else:
time.sleep(.5)
watchdog.feed()
self.buzzer.stop()
time.sleep(1.5)
watchdog.feed()
Expand All @@ -76,9 +79,9 @@ def gotoSleep(self):
def good(self, name=None):
self.led.setColor(*StatusNotifier.colors[2])
self.buzzer.start(500)
Timer(0).init(period=500, mode=Timer.ONE_SHOT, callback=self.gotoSleep)
if name:
leddy.setText(f"Welkom {name}!")
self.gotoSleep()

def error(self):
self.led.setColor(*StatusNotifier.colors[0])
Expand Down

0 comments on commit 3b4966e

Please sign in to comment.