aboutsummaryrefslogtreecommitdiff
path: root/dial.py
diff options
context:
space:
mode:
Diffstat (limited to 'dial.py')
-rw-r--r--dial.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/dial.py b/dial.py
index 1d08a05..0d14a32 100644
--- a/dial.py
+++ b/dial.py
@@ -2,7 +2,6 @@ from datetime import datetime, timedelta
import time
import RPi.GPIO as GPIO
import threading
-
import events
BUTTON_GPIO = 25
@@ -10,10 +9,9 @@ REST_TIME = 0.3 # seconds
DIAL_RESET_TIME = 5 # seconds
class DialThread(threading.Thread):
- def __init__(self, queue, pressed):
+ def __init__(self, queue):
threading.Thread.__init__(self, args=(), kwargs=None)
self.queue = queue
- self.pressed = pressed
self.daemon = True
GPIO.setmode(GPIO.BCM)
@@ -44,20 +42,23 @@ class DialThread(threading.Thread):
time.sleep(0.01)
def dial_over(self, rest_start):
+ # After REST_TIME seconds, assume the rotary dial stopped spinning
return datetime.now() - rest_start > timedelta(seconds=REST_TIME)
class DialManager:
- def __init__(self):
+ def __init__(self, phone_held, phone_hung_up):
self.sequence = []
self.update = datetime.now()
- self._load_sequences()
+ self._load_sequences(phone_held, phone_hung_up)
- def _load_sequences(self):
+ def _load_sequences(self, phone_held, phone_hung_up):
self.sequences = {
- 0: events.OperatorEvent(self),
- 4: {1: {1: events.DirectoryEvent(self)}},
- 7: events.FortuneEvent(self),
+ 0: events.OperatorEvent(self, phone_held, phone_hung_up),
+ 1: events.WeatherEvent(self, phone_held, phone_hung_up),
+ 2: events.TimerEvent(self, phone_held, phone_hung_up),
+ 4: {1: {1: events.DirectoryEvent(self, phone_held, phone_hung_up)}},
+ 7: events.FortuneEvent(self, phone_held, phone_hung_up),
}
print(self.sequences)