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


Python GPIO.remove_event_detect方法代码示例

本文整理汇总了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 
开发者ID:pimoroni,项目名称:displayotron,代码行数:20,代码来源:joystick.py

示例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) 
开发者ID:vitormhenrique,项目名称:OctoPrint-Enclosure,代码行数:21,代码来源:__init__.py

示例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) 
开发者ID:shivasiddharth,项目名称:GassistPi,代码行数:27,代码来源:main.py

示例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 
开发者ID:SecPi,项目名称:SecPi,代码行数:11,代码来源:gpio_sensor.py

示例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) 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:6,代码来源:Midi.py

示例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 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:11,代码来源:controller_rpi.py

示例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 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:11,代码来源:controller_rpi.py

示例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 ---------------------------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:13,代码来源:gengpioin.py

示例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) 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:9,代码来源:_button.py

示例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) 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:8,代码来源:_button.py

示例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() 
开发者ID:namco1992,项目名称:voicetools,代码行数:16,代码来源:assistant.py

示例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) 
开发者ID:swehner,项目名称:foos,代码行数:5,代码来源:io_raspberry.py

示例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) 
开发者ID:martinohanlon,项目名称:KY040,代码行数:7,代码来源:KY040.py

示例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 
开发者ID:pimoroni,项目名称:explorer-hat,代码行数:8,代码来源:__init__.py

示例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) 
开发者ID:vitormhenrique,项目名称:OctoPrint-Enclosure,代码行数:11,代码来源:__init__.py


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