_button.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:aiyprojects-raspbian 作者: google 项目源码 文件源码
def on_press(self, callback):
        """Calls the callback whenever the button is pressed.

        Args:
          callback: a function to call whenever the button is pressed. It should
            take a single channel number. If the callback is None, the previously
            registered callback, if any, is canceled.

        Example:
          def MyButtonPressHandler(channel):
              print "button pressed: channel = %d" % channel
          my_button.on_press(MyButtonPressHandler)
        """
        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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号