From 1edb32ec29ca3c1bf4d1a53215ecb2544aa04a6e Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 12 Jul 2021 02:00:54 +0100 Subject: Refactor code to support phone hangup button --- dial.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'dial.py') diff --git a/dial.py b/dial.py index c5f556f..1d08a05 100644 --- a/dial.py +++ b/dial.py @@ -3,14 +3,17 @@ import time import RPi.GPIO as GPIO import threading +import events + BUTTON_GPIO = 25 REST_TIME = 0.3 # seconds DIAL_RESET_TIME = 5 # seconds class DialThread(threading.Thread): - def __init__(self, queue): + def __init__(self, queue, pressed): threading.Thread.__init__(self, args=(), kwargs=None) self.queue = queue + self.pressed = pressed self.daemon = True GPIO.setmode(GPIO.BCM) @@ -52,18 +55,9 @@ class DialManager: def _load_sequences(self): self.sequences = { - 0: "operator", - 1: { - 2: "test_multiple" - }, - 2: "weather", - 3: "horrorscope", - 4: "", - 5: "", - 6: "", - 7: "fortune", - 8: "", - 9: "" + 0: events.OperatorEvent(self), + 4: {1: {1: events.DirectoryEvent(self)}}, + 7: events.FortuneEvent(self), } print(self.sequences) @@ -90,3 +84,6 @@ class DialManager: return sequences[digit] return recursive_find(self.sequence, self.sequences) + def clear_sequence(self): + self.sequence = [] + -- cgit v1.2.3