Skip to content

Commit

Permalink
vinscan: leddy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
draxaris1010 committed Jun 11, 2024
1 parent dda060d commit 63d7ec3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions vinscant/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def get_key():
with open("key.txt", "r") as file:
return file.read().strip()

LEDDY_ADDRESS = "http://10.0.2.3"
def uidToString(uid):
mystring = ""
for i in uid:
Expand Down Expand Up @@ -64,21 +64,38 @@ def good(self, name=None):
self.led.setColor(*StatusNotifier.colors[2])
self.buzzer.start(500)
if name:
req.post("http://10.0.2.3", data=f"ScrollingText Welkom {name}!").close()
leddy.setText(f"Welkom {name}!")
self.gotoSleep()

def error(self):
self.led.setColor(*StatusNotifier.colors[0])
self.buzzer.start(250)
self.gotoSleep()

watchdog = None
class Leddy:
def __init__(self, address="http://10.0.2.3") -> None:
self.address = address

def _post(self, command: str):
try:
req.post(self.address, data=command, timeout=2).close()
except Exception:
print("vinscant: leddy doesn't work :\x28") # indentation does weird

def setText(self, text: str):
self._post(f"Option autoResetMs {5 * 1000}")
self._post(f"ScrollingText {text}")

def do_read():
rdr = mfrc522.MFRC522(rst=16,cs=33,sck=34,mosi=35,miso=36)
lastUid = ''
lastTime = 0

print("vinscant: watchdog starting in 2s, interupt now with Ctrl+C")
time.sleep(2)
watchdog = WDT(timeout=10 * 1000)
print("vinscant: watchdog started")

print("")
print("Place card before reader to read from address 0x08")
print("")
Expand Down Expand Up @@ -122,9 +139,5 @@ def do_read():
notifier = StatusNotifier(Buzzer(Pin(37, Pin.OUT)), Led())
notifier.idle()
key = get_key()
print("vinscant: watchdog starting in 2s, interupt now with Ctrl+C")
time.sleep(2)
watchdog = WDT(timeout=10 * 1000)
print("vinscant: watchdog started")
req.post("http://10.0.2.3", data=f"Option autoResetMs {5 * 1000}").close()
leddy = Leddy()
do_read()

0 comments on commit 63d7ec3

Please sign in to comment.