1 from libtuer import ThreadFunction, logger
2 import RPi.GPIO as GPIO
11 CMD_UNLOCK: ("unlock", 12, [(None, 0.2), (True, 0.3), (False, 0.5)]),
12 CMD_LOCK: ("lock", 16, [(None, 0.2), (True, 0.3), (False, 0.5)]),
13 CMD_BUZZ: ("buzz", 22, [(None, 0.2), (True, 2.0), (False, 0.5)]),
17 self.act = ThreadFunction(self._act, name="Actor")
18 for (name, pin, todo) in self.CMDs.values():
19 GPIO.setup(pin, GPIO.OUT)
23 (name, pin, todo) = self.CMDs[cmd]
24 logger.info("Actor: Running command %s" % name)
25 for (value, delay) in todo:
27 logger.debug("Setting pin %d to %d" % (pin, value))
28 GPIO.output(pin, value)
31 logger.error("Actor: Gut unknown command %d" % cmd)