def init_gpio(self) -> None:
"""Initializes the GPIO interface."""
# Set SoC as reference.
GPIO.setmode(GPIO.BCM)
# Set pin as input and activate pull-down resistor.
GPIO.setup(self._pin,
GPIO.IN,
pull_up_down=GPIO.PUD_DOWN)
# Add interrupt event.
GPIO.add_event_detect(self._pin,
GPIO.RISING,
callback=self._interrupt,
bouncetime=self._bounce_time)
评论列表
文章目录