Python RPi.GPIO 模块,add_event_callback() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用RPi.GPIO.add_event_callback()

项目:Sample-Code    作者:meigrafd    | 项目源码 | 文件源码
def __init__(self):
        ''' initialize the pin for the anemometer sensor '''
        self.SENSOR_PIN = 4
        self.count = 0
        # tell the GPIO module that we want to use the chip's pin numbering scheme
        GPIO.setmode(GPIO.BCM)
        # setup pin as an input with pullup
        GPIO.setup(self.SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        # threaded event, to detect voltage falling on anemometer
        # bouncetime is in ms - edges within this time will be ignored
        GPIO.add_event_detect(self.SENSOR_PIN, GPIO.FALLING, bouncetime=30)
        self.starttime = time.time()
        # deal with events by calling a function
        GPIO.add_event_callback(self.SENSOR_PIN, self.inputEventHandler)