def __init__(self,pinA,pinB,button,callback, parent):
self.pinA = pinA
self.pinB = pinB
self.button = button
self.callback = callback
self.parent = parent
if self.pinA is not None and self.pinB is not None:
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(self.pinA, GPIO.IN)
GPIO.setup(self.pinB, GPIO.IN)
GPIO.add_event_detect(self.pinA, GPIO.FALLING,
callback=self.switch_event)
GPIO.add_event_detect(self.pinB, GPIO.FALLING,
callback=self.switch_event)
if self.button is not None:
GPIO.setup(self.button, GPIO.IN)
GPIO.add_event_detect(self.button, GPIO.BOTH,
callback=self.button_event, bouncetime=200)
return
# Call back routine called by switch events
评论列表
文章目录