blob: 2bfb1a77b9061a3db98d096b1128005baeb4307d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)
|