AnalogButtonAdapter

class ButtonConfig

Public Static Attributes

static constexpr int16_t MAX_VALUE = 1023
static constexpr unsigned long PRESS_TIME_MS = 300
static constexpr uint16_t DEFAULT_MARGIN = 20
class AnalogButtonAdapter : public InputInterface
#include <AnalogButtonAdapter.h>

Adapter class to handle analog button array as input for an LCD menu.

Wiring example https://www.instructables.com/How-to-Multiple-Buttons-on-1-Analog-Pin-Arduino-Tu/

This class implements the InputInterface to provide button input handling for an LCD menu. It observes analog button presses and processes commands accordingly. Made for LCD 1602 LCD Keypad Shield

It initializes the button and observes its state to trigger menu commands when the button is pressed.

Param menu:

Pointer to the LcdMenu object that this adapter will interact with.

Param pinNumber:

is analog pin where is connected the array of buttons

Param triggerValue:

Value of input pin, when button press is registered

Param margin:

How much input value can change to be still valid button press

Param command:

The command byte that will be sent to the menu when the button is pressed.

Public Functions

inline AnalogButtonAdapter(LcdMenu *menu, uint8_t pinNumber, uint16_t triggerValue, uint16_t margin, byte command)
inline AnalogButtonAdapter(LcdMenu *menu, uint8_t pinNumber, uint16_t triggerValue, byte command)
inline virtual void observe() override

Private Members

uint8_t pinNumber
uint16_t triggerValue
uint16_t margin
byte command
unsigned long lastPressTime = 0