From 5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Mon, 12 Jul 2021 20:27:50 -0500 Subject: Fix handler so events cannot be dialed while one is playing, and so events can be terminated --- dial.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'dial.py') diff --git a/dial.py b/dial.py index b6f3dd9..8fc92a9 100644 --- a/dial.py +++ b/dial.py @@ -10,10 +10,12 @@ REST_TIME = 0.3 # seconds DIAL_RESET_TIME = 5 # seconds class DialThread(threading.Thread): - def __init__(self, queue): + def __init__(self, queue, phone_held, processing_event): threading.Thread.__init__(self, args=(), kwargs=None) self.queue = queue self.daemon = True + self.phone_held = phone_held + self.processing_event = processing_event GPIO.setmode(GPIO.BCM) GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) @@ -37,7 +39,9 @@ class DialThread(threading.Thread): rest_start = datetime.now() pressed = False if self.dial_over(rest_start) and not printed: - self.queue.put(count % 10) # wrap 10 to 0 + # Only add this dial to queue if we should accept numbers at this time + if self.phone_held.is_set() and not self.processing_event.is_set(): + self.queue.put(count % 10) # wrap 10 to 0 count = 0 printed = True time.sleep(0.01) -- cgit v1.2.3