better logging; properly detect whether the bell button was newly pressed
[saartuer.git] / tuerd
1 #!/usr/bin/python3
2 import RPi.GPIO as GPIO
3 import statemachine, actor, pins, tysock, waker
4 from libtuer import logger
5
6 # initialize GPIO stuff
7 GPIO.setmode(GPIO.BOARD)
8
9 # bring 'em all up
10 the_actor = actor.Actor()
11 the_machine = statemachine.StateMachine(the_actor)
12 the_socket = tysock.TySocket(the_machine)
13 the_pins = pins.PinsWatcher(the_machine)
14 the_waker = waker.Waker(the_machine)
15
16 # we do the socket accept thing in the main thread
17 try:
18         the_socket.accept()
19 except KeyboardInterrupt:
20         # this is what we waited for!
21         logger.info("Got SIGINT, terminating...")
22         pass
23
24 # bring 'em all down
25 the_waker.stop()
26 the_pins.stop()
27 the_machine.stop()
28 the_actor.stop()
29
30 # shutdown GPIO stuff
31 GPIO.cleanup()