python类add_event_callback()的实例源码

anemometer.py 文件源码 项目:Sample-Code 作者: meigrafd 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号