1 from libtuer import ThreadFunction, logger
2 import RPi.GPIO as GPIO
11 CMD_UNLOCK: ("unlock", 12, [(True, 0.3), (False, 0.1)]),
12 CMD_LOCK: ("lock", 16, [(True, 0.3), (False, 0.1)]),
13 CMD_BUZZ: ("buzz", 22, [(True, 2.0), (False, 0.1)]),
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("Actor: Setting pin %d to %d" % (pin, value))
28 GPIO.output(pin, value)
31 logger.critical("Actor: Got unknown command %d" % cmd)