ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ButtonHandler Class Reference

Manages button input and state with interrupt support. More...

#include <ButtonHandler.h>

Static Public Member Functions

static void Initialize (uint8_t pin, uint8_t maxValue, uint16_t holdingToggle)
 Initializes the ButtonHandler with specified parameters.
 
static bool GetHoldingState ()
 Retrieves the holding state of the button.
 
static uint8_t GetValue ()
 Retrieves the current value of the button.
 

Static Private Member Functions

static void isr ()
 Interrupt service routine (ISR) for handling button presses.
 

Static Private Attributes

static long previousMillisISR
 Tracks the last interrupt service routine (ISR) trigger time in milliseconds.
 
static long previousMillisHold
 Tracks the last hold event time in milliseconds.
 
static uint16_t holdingToggle
 Time threshold for detecting holding behavior in milliseconds.
 
static uint8_t currentValue
 The current value of the button (e.g., press count).
 
static uint8_t maxValue
 The maximum value for the button press count.
 
static uint8_t pin
 The pin number associated with the button.
 
static bool holdingState
 Indicates whether the button is in a holding state.
 

Detailed Description

Manages button input and state with interrupt support.

The ButtonHandler class provides static methods for initializing a button, handling button press and hold logic, and retrieving the current state and value.

Definition at line 23 of file ButtonHandler.h.

Member Function Documentation

◆ GetHoldingState()

bool GetHoldingState ( )
static

Retrieves the holding state of the button.

Returns
True if the button is being held, false otherwise.

Definition at line 29 of file ButtonHandler.cpp.

References holdingState, holdingToggle, pin, and previousMillisHold.

◆ GetValue()

uint8_t GetValue ( )
static

Retrieves the current value of the button.

Returns
The current button value (e.g., press count).

Definition at line 42 of file ButtonHandler.cpp.

References currentValue.

Referenced by ProtogenArtleckAnimation::Update(), and WaffleDaProtoAnimation::Update().

◆ Initialize()

void Initialize ( uint8_t  pin,
uint8_t  maxValue,
uint16_t  holdingToggle 
)
static

Initializes the ButtonHandler with specified parameters.

Parameters
pinThe pin number associated with the button.
maxValueThe maximum value for the button press count.
holdingToggleThe time threshold for detecting holding behavior in milliseconds.

Definition at line 20 of file ButtonHandler.cpp.

References holdingToggle, isr(), maxValue, and pin.

Referenced by NukudeFaceAnimation::NukudeFaceAnimation(), ProtogenArtleckAnimation::ProtogenArtleckAnimation(), and WaffleDaProtoAnimation::WaffleDaProtoAnimation().

◆ isr()

void isr ( )
staticprivate

Interrupt service routine (ISR) for handling button presses.

Definition at line 11 of file ButtonHandler.cpp.

References currentValue, maxValue, and previousMillisISR.

Referenced by Initialize().

Member Data Documentation

◆ currentValue

uint8_t currentValue
staticprivate

The current value of the button (e.g., press count).

Definition at line 28 of file ButtonHandler.h.

Referenced by GetValue(), and isr().

◆ holdingState

bool holdingState
staticprivate

Indicates whether the button is in a holding state.

Definition at line 31 of file ButtonHandler.h.

Referenced by GetHoldingState().

◆ holdingToggle

uint16_t holdingToggle
staticprivate

Time threshold for detecting holding behavior in milliseconds.

Definition at line 27 of file ButtonHandler.h.

Referenced by GetHoldingState(), and Initialize().

◆ maxValue

uint8_t maxValue
staticprivate

The maximum value for the button press count.

Definition at line 29 of file ButtonHandler.h.

Referenced by Initialize(), and isr().

◆ pin

uint8_t pin
staticprivate

The pin number associated with the button.

Definition at line 30 of file ButtonHandler.h.

Referenced by GetHoldingState(), and Initialize().

◆ previousMillisHold

long previousMillisHold
staticprivate

Tracks the last hold event time in milliseconds.

Definition at line 26 of file ButtonHandler.h.

Referenced by GetHoldingState().

◆ previousMillisISR

long previousMillisISR
staticprivate

Tracks the last interrupt service routine (ISR) trigger time in milliseconds.

Definition at line 25 of file ButtonHandler.h.

Referenced by isr().


The documentation for this class was generated from the following files: