hardware/button_controller.h

GPIO button input controller.

Three active-low buttons are intended for high-level UI control: Start -> GPIO 20 Stop -> GPIO 21 Reset -> GPIO 24

These pins intentionally avoid the mux select pins, mux signal pins, and the Pi’s I2C pins used by the OLED.

Enums

enum class ButtonEvent

Values:

enumerator None
enumerator Start
enumerator Stop
enumerator Reset

Variables

constexpr int DEFAULT_PIN_BUTTON_START = 20
constexpr int DEFAULT_PIN_BUTTON_STOP = 21
constexpr int DEFAULT_PIN_BUTTON_RESET = 24
class ButtonController
#include <button_controller.h>

Public Functions

ButtonController()
ButtonController(int startPin, int stopPin, int resetPin)
~ButtonController()
bool init()
void enableSimulation()
inline bool isInitialized() const
void setSimulatedPressed(ButtonEvent button, bool pressed)
ButtonEvent poll()
const char *eventName(ButtonEvent event) const

Private Functions

bool readRaw(int index)

Private Members

int pins[3]
bool initialized
bool simulationMode
bool simulatedState[3]
bool rawState[3]
bool stableState[3]
std::chrono::steady_clock::time_point lastChange[3]