diff options
author | Mark Powers <mark@marks.kitchen> | 2021-07-12 20:27:50 -0500 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2021-07-12 20:27:50 -0500 |
commit | 5b2a3f0da147f17f6ab32af8e3d14fb29de71fd1 (patch) | |
tree | 6e025bba1712f7f183fe568e2acc5b1f8e5870d5 /dial.py | |
parent | e3f4893b74b97e1de5e126761d9ec6a0f6585888 (diff) |
Fix handler so events cannot be dialed while one is playing, and so events can be terminated
Diffstat (limited to 'dial.py')
-rw-r--r-- | dial.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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) |