adafruit_debouncedbutton

CircuitPython button debouncer

  • Author(s): hiibot

Implementation Notes

Hardware:

Not all hardware / CircuitPython combinations are capable of running the debouncer correctly for an extended length of time. If this line works on your microcontroller, then the debouncer should work forever:

Software and Dependencies:

# * Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice # * Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register

class adafruit_debouncedbutton.Debouncer(btnpin, dbt=0.01, invert=False)

Debounce an input button

Make am instance. :param DigitalInOut: the DigitalIO to debounce :param int interval: bounce threshold in seconds (default is 0.010, i.e. 10 milliseconds) :param bool: invert

property is_pressed

Return the current is_pressed value.

property is_released

Return the current is_released value.

pressed_for(lent)

Return pressed value.

read()

Update the debouncer state. MUST be called frequently

property was_pressed

Return the current was_pressed value.

property was_released

Return the current was_released value.