aboutsummaryrefslogtreecommitdiff
path: root/hangup.py
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2021-07-12 02:00:54 +0100
committerMark Powers <mark@marks.kitchen>2021-07-12 02:00:54 +0100
commit1edb32ec29ca3c1bf4d1a53215ecb2544aa04a6e (patch)
treed770c0f3dd74dab11a5b13c54f37b14c81daa990 /hangup.py
parenta981a50b0597498a9fc92249f93f940998455ca3 (diff)
Refactor code to support phone hangup button
Diffstat (limited to 'hangup.py')
-rw-r--r--hangup.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/hangup.py b/hangup.py
new file mode 100644
index 0000000..2bfb1a7
--- /dev/null
+++ b/hangup.py
@@ -0,0 +1,25 @@
+import RPi.GPIO as GPIO
+import threading
+import time
+
+BUTTON_GPIO = 24
+
+class HangUpThread(threading.Thread):
+ def __init__(self, phone_held, dial_manager):
+ threading.Thread.__init__(self, args=(), kwargs=None)
+ self.phone_held = phone_held
+ self.dial_manager = dial_manager
+ self.daemon = True
+
+ GPIO.setmode(GPIO.BCM)
+ GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
+
+ def run(self):
+ while True:
+ if not GPIO.input(BUTTON_GPIO):
+ self.phone_held.clear()
+ self.dial_manager.clear_sequence()
+ else:
+ self.phone_held.set()
+ time.sleep(0.1)
+