X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/cf244d9312e36b30583da60d3b9918db57ab3610..41111d6443061891dd2ec7d5bf5ab856c0546fc0:/actor.py?ds=inline diff --git a/actor.py b/actor.py index 439a7bb..25939a6 100644 --- a/actor.py +++ b/actor.py @@ -3,9 +3,13 @@ import RPi.GPIO as GPIO import time class Actor: - CMD_BUZZ = 0 - CMD_UNLOCK = 1 - CMD_LOCK = 2 + CMD_BUZZ = 0 + CMD_UNLOCK = 1 + CMD_LOCK = 2 + CMD_GREEN_ON = 3 + CMD_GREEN_OFF = 4 + CMD_RED_ON = 5 + CMD_RED_OFF = 6 class CMD(): def __init__(self, name, pin, tid, todo): @@ -21,12 +25,17 @@ class Actor: if value is not None: logger.debug("Actor: Setting pin %d to %d" % (self.pin, value)) GPIO.output(self.pin, value) - time.sleep(delay) + if delay > 0: + time.sleep(delay) CMDs = { - CMD_UNLOCK: CMD("unlock", pin=12, tid=0, todo=[(True, 0.3), (False, 0.1)]), - CMD_LOCK: CMD("lock", pin=16, tid=0, todo=[(True, 0.3), (False, 0.1)]), - CMD_BUZZ: CMD("buzz", pin=22, tid=1, todo=[(True, 2.0), (False, 0.1)]), + CMD_UNLOCK: CMD("unlock", pin=12, tid=0, todo=[(True, 0.3), (False, 0.1)]), + CMD_LOCK: CMD("lock", pin=16, tid=0, todo=[(True, 0.3), (False, 0.1)]), + CMD_BUZZ: CMD("buzz", pin=22, tid=1, todo=[(True, 2.5), (False, 0.1)]), + CMD_GREEN_ON: CMD("green on", pin=23, tid=2, todo=[(True, 0)]), + CMD_GREEN_OFF: CMD("green off", pin=23, tid=2, todo=[(False, 0)]), + CMD_RED_ON: CMD("red on", pin=26, tid=2, todo=[(True, 0)]), + CMD_RED_OFF: CMD("red on", pin=26, tid=2, todo=[(False, 0)]), } def __init__(self): @@ -34,6 +43,7 @@ class Actor: self.threads = {} for cmd in Actor.CMDs.values(): GPIO.setup(cmd.pin, GPIO.OUT) + GPIO.output(cmd.pin, False) if not cmd.tid in self.threads: self.threads[cmd.tid] = ThreadFunction(self._execute, "Actor TID %d" % cmd.tid)