本文整理汇总了Python中RPi.GPIO.remove_event_detect方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.remove_event_detect方法的具体用法?Python GPIO.remove_event_detect怎么用?Python GPIO.remove_event_detect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPi.GPIO
的用法示例。
在下文中一共展示了GPIO.remove_event_detect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def on(buttons, bounce=BOUNCE):
"""Handle a joystick direction or button push
Decorator. Use with @joystick.on(joystick.UP)
:param buttons: List, or single instance of joystick button constant
:param bounce: Debounce delay in milliseconds: default 300
"""
buttons = buttons if isinstance(buttons, list) else [buttons]
def register(handler):
for button in buttons:
GPIO.remove_event_detect(button)
GPIO.add_event_detect(button, GPIO.FALLING, callback=handler, bouncetime=bounce)
return register
示例2: clear_gpio
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def clear_gpio(self):
try:
for gpio_out in list(filter(
lambda item: item['output_type'] == 'regular' or item['output_type'] == 'pwm' or item[
'output_type'] == 'temp_hum_control' or item['output_type'] == 'neopixel_direct',
self.rpi_outputs)):
gpio_pin = self.to_int(gpio_out['gpio_pin'])
if gpio_pin not in self.rpi_outputs_not_changed:
GPIO.cleanup(gpio_pin)
for gpio_in in list(filter(lambda item: item['input_type'] == 'gpio', self.rpi_inputs)):
try:
GPIO.remove_event_detect(self.to_int(gpio_in['gpio_pin']))
except:
pass
GPIO.cleanup(self.to_int(gpio_in['gpio_pin']))
except Exception as ex:
self.log_error(ex)
示例3: pushbutton
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [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)
示例4: cleanup_sensor
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def cleanup_sensor(self):
try:
GPIO.remove_event_detect(self.gpio)
GPIO.cleanup(self.gpio)
except ValueError as ve: # GPIO pin number is not in valid range
logging.error("GPIOSensor: The given pin number is not in a valid range: %s" % ve)
logging.debug("GPIOSensor: Removed sensor at pin %s!" % self.gpio)
# callback for alarm
示例5: gpiocleanup
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def gpiocleanup(self):
pins = [27, 23, 4, 17, 22, 5, 6] # [L, R, C, U, D, A, B]
for i in pins:
GPIO.remove_event_detect(i)
示例6: prepare_irq_pin
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def prepare_irq_pin(self, pin_id):
pin = self.prepare_pin(pin_id, GPIO.IN)
if pin:
pin.set_handler_for_irq_on_rising_edge = \
lambda handler: GPIO.add_event_detect(pin.pin_id,
GPIO.RISING,
callback = handler)
pin.detach_irq = lambda : GPIO.remove_event_detect(pin.pin_id)
return pin
示例7: prepare_irq_pin
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def prepare_irq_pin(self, pin_id):
pin = self.prepare_pin(pin_id, GPIO.IN)
if pin:
pin.set_handler_for_irq_on_rising_edge = \
lambda handler: GPIO.add_event_detect(pin.pin_id,
GPIO.RISING,
callback = handler)
pin.detach_irq = lambda: GPIO.remove_event_detect(pin.pin_id)
return pin
示例8: Close
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def Close(self):
try:
self.Exiting = True
if not self.UseLibCallbacks:
self.KillThread("GPIOInputMonitor")
GPIO.remove_event_detect(self.GPIO)
except Exception as e1:
self.LogErrorLine("Error in Close: " + str(e1))
#---------- Signal Handler ----------------------------------------------------
示例9: wait_for_press
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [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)
示例10: on_press
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def on_press(self, callback):
GPIO.remove_event_detect(self.channel)
if callback is not None:
self.callback = callback
GPIO.add_event_detect(
self.channel, self.polarity, callback=self._debounce_and_callback)
示例11: loop
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [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()
示例12: __del__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def __del__(self):
if self.pin:
GPIO.remove_event_detect(self.pin)
示例13: stop
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def stop(self):
GPIO.remove_event_detect(self.clockPin)
if None != self.switchPin:
GPIO.remove_event_detect(self.switchPin)
示例14: clear_events
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def clear_events(self):
if self._is_gpio_setup():
GPIO.remove_event_detect(self.pin)
self.has_callback = False
# Alias handlers
示例15: stop_filament_detection
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import remove_event_detect [as 别名]
def stop_filament_detection(self):
try:
self.last_filament_end_detected = []
for filament_sensor in list(filter(
lambda item: item['input_type'] == 'gpio' and item['action_type'] == 'printer_control' and item[
'printer_action'] == 'filament', self.rpi_inputs)):
GPIO.remove_event_detect(self.to_int(filament_sensor['gpio_pin']))
except Exception as ex:
self.log_error(ex)