Python RPi.GPIO.event_detected() Examples
The following are 9
code examples of RPi.GPIO.event_detected().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
RPi.GPIO
, or try the search function
.
Example #1
Source File: _button.py From ai-makers-kit with MIT License | 6 votes |
def wait_for_press(self): GPIO.add_event_detect(self.channel, self.polarity) while True: if GPIO.event_detected(self.channel) and self._debounce(): GPIO.remove_event_detect(self.channel) return time.sleep(0.02)
Example #2
Source File: listui.py From opc with MIT License | 6 votes |
def loadFirmware(device): if os.path.exists("/media/pi/OP-1")==1: drawText(device,["op1 connection success","load firmware?"," -yup"," -back"]) while True: if GPIO.event_detected(key['key2']): print "copying firmware" drawText(device,["copying firmware..."]) spath="/home/pi/Desktop/misc/op1_225.op1" dpath="/media/pi/OP-1/" sh.copy(spath,dpath) return elif GPIO.event_detected(key['key1']): return else: drawText(device,["op1 not detected","","returning to menu..."]) time.sleep(1) return
Example #3
Source File: main.py From GassistPi with GNU General Public License v3.0 | 6 votes |
def pushbutton(self): if GPIOcontrol: while mutestopbutton: time.sleep(.1) if GPIO.event_detected(stoppushbutton): GPIO.remove_event_detect(stoppushbutton) now = time.time() count = 1 GPIO.add_event_detect(stoppushbutton,GPIO.RISING) while time.time() < now + 1: if GPIO.event_detected(stoppushbutton): count +=1 time.sleep(.25) if count == 2: self.buttonsinglepress() GPIO.remove_event_detect(stoppushbutton) GPIO.add_event_detect(stoppushbutton,GPIO.FALLING) elif count == 3: self.buttondoublepress() GPIO.remove_event_detect(stoppushbutton) GPIO.add_event_detect(stoppushbutton,GPIO.FALLING) elif count == 4: self.buttontriplepress() GPIO.remove_event_detect(stoppushbutton) GPIO.add_event_detect(stoppushbutton,GPIO.FALLING)
Example #4
Source File: gengpioin.py From genmon with GNU General Public License v2.0 | 5 votes |
def GPIOInputMonitor(self): try: while not self.Exiting: if GPIO.event_detected(self.GPIO): self.LogError('Edge detected on pin ' + str(self.GPIO)) if self.Callback != None and callable(self.Callback): self.Callback(self.GPIO) if self.WaitForExit("GPIOInputMonitor", 1): return except Exception as e1: self.LogErrorLine("Error GPIOInputMonitor: " + str(self.GPIO) + ": "+ str(e1)) #-----------------Close-----------------------------------------------------
Example #5
Source File: _button.py From ai-makers-kit with MIT License | 5 votes |
def wait_for_press(self): GPIO.add_event_detect(self.channel, self.polarity) while True: if GPIO.event_detected(self.channel) and self._debounce(): GPIO.remove_event_detect(self.channel) return time.sleep(0.02)
Example #6
Source File: assistant.py From voicetools with Apache License 2.0 | 5 votes |
def loop(): # 初始化 handler = BaseHandler() try: while True: # 下降沿检测 if GPIO.event_detected(GPIOConfig.VOICE_SENSOR): GPIO.remove_event_detect(GPIOConfig.VOICE_SENSOR) handler.worker() GPIO.add_event_detect(GPIOConfig.VOICE_SENSOR, GPIO.FALLING) time.sleep(0.5) except KeyboardInterrupt: pass GPIO.cleanup()
Example #7
Source File: control.py From mudpi-core with MIT License | 5 votes |
def read(self): #Read the sensor(s), parse the data and store it in redis if redis is configured #If edge detection is being used return the detection event instead return self.readPin() if self.edge_detection is None else GPIO.event_detected(self.pin)
Example #8
Source File: listui.py From opc with MIT License | 5 votes |
def wait(keys,waitkey): done=0 while done==0: if GPIO.event_detected(key[waitkey]): done=1 time.sleep(.01) return
Example #9
Source File: __init__.py From picroft-google-aiy-voicekit-skill with GNU General Public License v3.0 | 5 votes |
def handle_button(self, message): longpress_threshold = 2 if GPIO.event_detected(BUTTON): self.log.info("GPIO.event_detected") pressed_time = time.time() while not GPIO.input(BUTTON): time.sleep(0.2) pressed_time = time.time() - pressed_time if pressed_time < longpress_threshold: self.bus.emit(Message("mycroft.mic.listen")) else: self.bus.emit(Message("mycroft.stop"))