当前位置: 首页>>代码示例>>Python>>正文


Python GPIO.event_detected方法代码示例

本文整理汇总了Python中RPi.GPIO.event_detected方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.event_detected方法的具体用法?Python GPIO.event_detected怎么用?Python GPIO.event_detected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RPi.GPIO的用法示例。


在下文中一共展示了GPIO.event_detected方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadFirmware

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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 
开发者ID:tink3rtanner,项目名称:opc,代码行数:23,代码来源:listui.py

示例2: pushbutton

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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) 
开发者ID:shivasiddharth,项目名称:GassistPi,代码行数:27,代码来源:main.py

示例3: GPIOInputMonitor

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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----------------------------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:16,代码来源:gengpioin.py

示例4: wait_for_press

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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) 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:9,代码来源:_button.py

示例5: loop

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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() 
开发者ID:namco1992,项目名称:voicetools,代码行数:16,代码来源:assistant.py

示例6: read

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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) 
开发者ID:mudpi,项目名称:mudpi-core,代码行数:6,代码来源:control.py

示例7: wait

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
def wait(keys,waitkey):

	done=0
	while done==0:
		if GPIO.event_detected(key[waitkey]):
			done=1
		time.sleep(.01)
	return 
开发者ID:tink3rtanner,项目名称:opc,代码行数:10,代码来源:listui.py

示例8: handle_button

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import event_detected [as 别名]
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")) 
开发者ID:andlo,项目名称:picroft-google-aiy-voicekit-skill,代码行数:14,代码来源:__init__.py


注:本文中的RPi.GPIO.event_detected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。