diff --git a/lock.py b/lock.py new file mode 100644 index 0000000..455787d --- /dev/null +++ b/lock.py @@ -0,0 +1,27 @@ +from gpiozero import LED +import shelve + +led = LED(17) + +def state(current : bool = None): + if current != None: + with shelve.open("Settings.conf") as settings: + settings["state"] = current + else: + with shelve.open("Settings.conf") as settings: + return settings["state"] + + +def unlock(): + led.on() + state(True) + +def lock(): + led.off() + state(False) + +def switch(): + if state(): + lock() + else: + unlock()