Forget to commit to master the lock >.>
This commit is contained in:
parent
72eecaa20c
commit
dea22875e6
1 changed files with 27 additions and 0 deletions
27
lock.py
Normal file
27
lock.py
Normal file
|
@ -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()
|
Reference in a new issue