RASCSI/python/ctrlboard/src/ctrlboard_hw/hardware_button.py
Benjamin Zeiss 0297fe856a
8bit encoder detection + debounced button detection, numpy removal (#710)
* debounce interrupt events for rotary events and button presses with 400 microseconds by default.

* Massive improvements for the encoder detection. Removed numpy as a dependency.

* Debounce button presses which started to jump around.

* formatting cleanup.
2022-03-01 20:27:14 -06:00

19 lines
614 B
Python

"""Module containing an abstraction for the hardware button through the i2c multiplexer"""
# pylint: disable=too-few-public-methods
class HardwareButton:
"""Class implementing a hardware button interface that uses the i2c multiplexer"""
def __init__(self, pca_driver, pin):
self.pca_driver = pca_driver
self.pin = pin
self.state = True
self.state_interrupt = True
self.name = "n/a"
self.last_press = None
def read(self):
"""Reads the configured port of the i2c multiplexer"""
return self.pca_driver.read_input_register_port(self.pin)