aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2021-07-12 03:15:06 +0100
committerMark Powers <mark@marks.kitchen>2021-07-12 03:15:06 +0100
commitc72abd79e4dbfd9b533d75bb00fea1ded9975d95 (patch)
tree6056796286af31ea09d41faf9d6b57308e450ec4 /main.py
parent1edb32ec29ca3c1bf4d1a53215ecb2544aa04a6e (diff)
Add config, weather event, and demo timer event demoing hang up event
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/main.py b/main.py
index ef51809..674e644 100755
--- a/main.py
+++ b/main.py
@@ -10,27 +10,29 @@ from threading import Event
if __name__ == "__main__":
queue = Queue()
phone_held = Event()
+ phone_hung_up = Event()
# start phone as on hook
phone_held.clear()
+ phone_hung_up.set()
- dial_thread = DialThread(queue, phone_held)
- print("starting dial thread")
+ dial_thread = DialThread(queue)
dial_thread.start()
- dial_manager = DialManager()
+ dial_manager = DialManager(phone_held, phone_hung_up)
- hang_up_thread = HangUpThread(phone_held, dial_manager)
- print("starting hang up thread")
+ hang_up_thread = HangUpThread(phone_held, phone_hung_up, dial_manager)
hang_up_thread.start()
- print("main loop")
while True:
+ # Wait for phone to be picked up
phone_held.wait()
+ # Dial a number
try:
dialed = queue.get(block=True, timeout=0.1)
except:
continue
response = dial_manager.dial(dialed)
+ # If we matched a sequence, play out event
if response is not None:
response.speak()