X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/e99d4446af1d2f2419c4de4fe3874f17b0873a48..58cb71a3e864fbad3e90a9518a367e28ee458467:/actor.py?ds=inline diff --git a/actor.py b/actor.py index 248edeb..8f57d9f 100644 --- a/actor.py +++ b/actor.py @@ -1,5 +1,6 @@ from libtuer import ThreadFunction, logger import RPi.GPIO as GPIO +import time class Actor: CMD_BUZZ = 0 @@ -7,13 +8,13 @@ class Actor: CMD_LOCK = 2 CMDs = { - CMD_BUZZ: ("buzz", 12, [(True, 0.3), (False, 2.0)]), - CMD_UNLOCK: ("unlock", 16, [(None, 0.2), (True, 0.3), (False, 1.0)]), - CMD_LOCK: ("lock", 22, [(None, 0.2), (True, 0.3), (False, 1.0)]), + CMD_UNLOCK: ("unlock", 12, [(None, 0.2), (True, 0.3), (False, 0.5)]), + CMD_LOCK: ("lock", 16, [(None, 0.2), (True, 0.3), (False, 0.5)]), + CMD_BUZZ: ("buzz", 22, [(None, 0.2), (True, 2.0), (False, 0.5)]), } def __init__(self): - self.act = ThreadFunction(self._act) + self.act = ThreadFunction(self._act, name="Actor") for (name, pin, todo) in self.CMDs.values(): GPIO.setup(pin, GPIO.OUT) @@ -23,10 +24,11 @@ class Actor: logger.info("Actor: Running command %s" % name) for (value, delay) in todo: if value is not None: + logger.debug("Setting pin %d to %d" % (pin, value)) GPIO.output(pin, value) time.sleep(delay) else: logger.error("Actor: Gut unknown command %d" % cmd) def stop(self): - pass + self.act.stop()