ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
MenuHandler< menuCount > Class Template Reference

Manages multiple menus and settings using Adafruit NeoTrellis. More...

#include <NeoTrellisMenuHandler.h>

Static Public Member Functions

static void Update ()
 Updates the menu state and processes user interactions.
 
static bool Initialize ()
 Initializes the MenuHandler and sets up the NeoTrellis keypad.
 
static void SetDefaultValue (uint16_t menu, uint8_t value)
 Sets a default value for a specific menu.
 
static void SetInitialized ()
 Marks the menu system as initialized.
 
static void SetMenuMax (uint8_t menu, uint8_t maxValue)
 Sets the maximum value for a specific menu.
 
static uint8_t GetMenuValue (uint8_t menu)
 Retrieves the current value of a specific menu.
 
static uint8_t GetCurrentMenu ()
 Retrieves the index of the currently active menu.
 
static void Begin ()
 Begins the menu handling process, setting up necessary states.
 
static bool Initialize (uint8_t pin, uint16_t holdingTime)
 Initializes the MenuHandler with specified parameters.
 
static void SetDefaultValue (uint16_t menu, uint8_t value)
 Sets a default value for a specific menu.
 
static void SetInitialized ()
 Marks the menu system as initialized.
 
static void SetMenuMax (uint8_t menu, uint8_t maxValue)
 Sets the maximum value for a specific menu.
 
static uint8_t GetMenuValue (uint8_t menu)
 Retrieves the current value of a specific menu.
 
static uint8_t GetCurrentMenu ()
 Retrieves the index of the currently active menu.
 
static void Begin ()
 Begins the menu handling process, setting up necessary states.
 
static bool Initialize (uint8_t pin, uint16_t holdingTime)
 Initializes the MenuHandler with specified parameters.
 
static void SetDefaultValue (uint16_t menu, uint8_t value)
 Sets a default value for a specific menu.
 
static void SetInitialized ()
 Marks the menu system as initialized.
 
static void SetMenuMax (uint8_t menu, uint8_t maxValue)
 Sets the maximum value for a specific menu.
 
static void Update ()
 Updates the menu system and processes button input.
 
static uint8_t GetMenuValue (uint8_t menu)
 Retrieves the current value of a specific menu.
 
static uint8_t GetCurrentMenu ()
 Retrieves the index of the currently active menu.
 

Static Private Member Functions

static uint32_t Wheel (byte WheelPos)
 Generates a color value based on a position on a color wheel.
 
static TrellisCallback blink (keyEvent evt)
 Callback function for handling key events on the NeoTrellis keypad.
 
static uint8_t ReadEEPROM (uint16_t index)
 Reads a value from EEPROM at the specified index.
 
static void WriteEEPROM (uint16_t index, uint8_t value)
 Writes a value to EEPROM at the specified index.
 
static void ResetI2CBus ()
 Resets the I2C bus to recover from communication issues.
 
static void UpdateState ()
 Updates the button state and menu navigation.
 
static uint8_t ReadEEPROM (uint16_t index)
 Reads a value from EEPROM at the specified index.
 
static void WriteEEPROM (uint16_t index, uint8_t value)
 Writes a value to EEPROM at the specified index.
 
static uint8_t ReadEEPROM (uint16_t index)
 Reads a value from EEPROM at the specified index.
 
static void WriteEEPROM (uint16_t index, uint8_t value)
 Writes a value to EEPROM at the specified index.
 

Static Private Attributes

static Adafruit_NeoTrellis trellis
 Instance of the Adafruit NeoTrellis keypad.
 
static uint8_t currentMenu
 Index of the currently active menu.
 
static uint8_t currentSetting
 Index of the currently active setting within the menu.
 
static uint8_t currentValue [menuCount]
 Array of current values for each menu.
 
static uint8_t maxValue [menuCount]
 Array of maximum values for each menu.
 
static uint8_t faceChoices
 Number of face choices available.
 
static bool menuActive
 Flag indicating whether the menu is active.
 
static bool isReady
 Flag indicating whether the menu system is ready for interaction.
 
static bool didBegin
 Flag indicating whether the initialization process has been completed.
 
static IntervalTimer menuChangeTimer
 Timer for handling menu change intervals.
 
static long previousMillisHold
 Tracks the last hold event time in milliseconds.
 
static uint16_t holdingTime
 Time threshold for detecting holding behavior in milliseconds.
 
static uint8_t pin
 The pin number associated with the button.
 
static bool holdingState
 Indicates whether the button is in a holding state.
 
static bool previousState
 Tracks the previous state of the button.
 
static long previousMillis
 Tracks the last button press time in milliseconds.
 
static uint8_t inputCount
 Number of Morse code inputs received.
 
static uint16_t inputStream [4]
 Buffer for storing Morse code input.
 

Detailed Description

template<uint8_t menuCount>
class MenuHandler< menuCount >

Manages multiple menus and settings using Adafruit NeoTrellis.

Manages single-button menu navigation and settings storage.

The MenuHandler class provides functionality for navigating and managing settings across multiple menus, including support for EEPROM storage, custom settings, and dynamic updates.

Template Parameters
menuCountThe number of menus to manage.

The MenuHandler class provides functionality for navigating through menus and managing settings using a single button. It supports persistent storage through EEPROM and leverages an IntervalTimer for handling button hold and state transitions.

Template Parameters
menuCountThe number of menus to manage.

The MenuHandler class provides functionality for navigating through menus and managing settings using a single button. It supports Morse code input for advanced interaction and persistent storage through EEPROM.

Template Parameters
menuCountThe number of menus to manage.

Definition at line 29 of file NeoTrellisMenuHandler.h.

Member Function Documentation

◆ Begin() [1/2]

template<uint8_t menuCount>
static void Begin ( )
static

Begins the menu handling process, setting up necessary states.

Referenced by Menu::Initialize().

◆ Begin() [2/2]

template<uint8_t menuCount>
static void Begin ( )
static

Begins the menu handling process, setting up necessary states.

◆ blink()

template<uint8_t menuCount>
static TrellisCallback blink ( keyEvent  evt)
staticprivate

Callback function for handling key events on the NeoTrellis keypad.

Parameters
evtThe key event to process.
Returns
True if the event was handled successfully, false otherwise.

◆ GetCurrentMenu() [1/3]

template<uint8_t menuCount>
static uint8_t GetCurrentMenu ( )
static

Retrieves the index of the currently active menu.

Returns
The index of the active menu.

Referenced by Menu::GetCurrentMenu(), Menu::Update(), and GammaAnimation::Update().

◆ GetCurrentMenu() [2/3]

template<uint8_t menuCount>
static uint8_t GetCurrentMenu ( )
static

Retrieves the index of the currently active menu.

Returns
The index of the active menu.

◆ GetCurrentMenu() [3/3]

template<uint8_t menuCount>
static uint8_t GetCurrentMenu ( )
static

Retrieves the index of the currently active menu.

Returns
The index of the active menu.

◆ GetMenuValue() [1/3]

template<uint8_t menuCount>
static uint8_t GetMenuValue ( uint8_t  menu)
static

◆ GetMenuValue() [2/3]

template<uint8_t menuCount>
static uint8_t GetMenuValue ( uint8_t  menu)
static

Retrieves the current value of a specific menu.

Parameters
menuThe menu index to retrieve the value from.
Returns
The current value of the menu.

◆ GetMenuValue() [3/3]

template<uint8_t menuCount>
static uint8_t GetMenuValue ( uint8_t  menu)
static

Retrieves the current value of a specific menu.

Parameters
menuThe menu index to retrieve the value from.
Returns
The current value of the menu.

◆ Initialize() [1/3]

template<uint8_t menuCount>
static bool Initialize ( )
static

Initializes the MenuHandler and sets up the NeoTrellis keypad.

Returns
True if initialization was successful, false otherwise.

◆ Initialize() [2/3]

template<uint8_t menuCount>
static bool Initialize ( uint8_t  pin,
uint16_t  holdingTime 
)
static

Initializes the MenuHandler with specified parameters.

Parameters
pinThe pin number associated with the button.
holdingTimeThe time threshold for detecting holding behavior in milliseconds.
Returns
True if initialization was successful, false otherwise.

◆ Initialize() [3/3]

template<uint8_t menuCount>
static bool Initialize ( uint8_t  pin,
uint16_t  holdingTime 
)
static

Initializes the MenuHandler with specified parameters.

Parameters
pinThe pin number associated with the button.
holdingTimeThe time threshold for detecting holding behavior in milliseconds.
Returns
True if initialization was successful, false otherwise.

◆ ReadEEPROM() [1/3]

template<uint8_t menuCount>
static uint8_t ReadEEPROM ( uint16_t  index)
staticprivate

Reads a value from EEPROM at the specified index.

Parameters
indexThe EEPROM address to read from.
Returns
The value read from EEPROM.

◆ ReadEEPROM() [2/3]

template<uint8_t menuCount>
static uint8_t ReadEEPROM ( uint16_t  index)
staticprivate

Reads a value from EEPROM at the specified index.

Parameters
indexThe EEPROM address to read from.
Returns
The value read from EEPROM.

◆ ReadEEPROM() [3/3]

template<uint8_t menuCount>
static uint8_t ReadEEPROM ( uint16_t  index)
staticprivate

Reads a value from EEPROM at the specified index.

Parameters
indexThe EEPROM address to read from.
Returns
The value read from EEPROM.

◆ ResetI2CBus()

template<uint8_t menuCount>
static void ResetI2CBus ( )
staticprivate

Resets the I2C bus to recover from communication issues.

◆ SetDefaultValue() [1/3]

template<uint8_t menuCount>
static void SetDefaultValue ( uint16_t  menu,
uint8_t  value 
)
static

Sets a default value for a specific menu.

Parameters
menuThe menu index to set the default value for.
valueThe default value to set.

Referenced by Menu::SetDefaultEntries().

◆ SetDefaultValue() [2/3]

template<uint8_t menuCount>
static void SetDefaultValue ( uint16_t  menu,
uint8_t  value 
)
static

Sets a default value for a specific menu.

Parameters
menuThe menu index to set the default value for.
valueThe default value to set.

◆ SetDefaultValue() [3/3]

template<uint8_t menuCount>
static void SetDefaultValue ( uint16_t  menu,
uint8_t  value 
)
static

Sets a default value for a specific menu.

Parameters
menuThe menu index to set the default value for.
valueThe default value to set.

◆ SetInitialized() [1/3]

template<uint8_t menuCount>
static void SetInitialized ( )
static

Marks the menu system as initialized.

Referenced by Menu::SetDefaultEntries().

◆ SetInitialized() [2/3]

template<uint8_t menuCount>
static void SetInitialized ( )
static

Marks the menu system as initialized.

◆ SetInitialized() [3/3]

template<uint8_t menuCount>
static void SetInitialized ( )
static

Marks the menu system as initialized.

◆ SetMenuMax() [1/3]

template<uint8_t menuCount>
static void SetMenuMax ( uint8_t  menu,
uint8_t  maxValue 
)
static

Sets the maximum value for a specific menu.

Parameters
menuThe menu index to set the maximum value for.
maxValueThe maximum value to set.

Referenced by Menu::SetMaxEntries().

◆ SetMenuMax() [2/3]

template<uint8_t menuCount>
static void SetMenuMax ( uint8_t  menu,
uint8_t  maxValue 
)
static

Sets the maximum value for a specific menu.

Parameters
menuThe menu index to set the maximum value for.
maxValueThe maximum value to set.

◆ SetMenuMax() [3/3]

template<uint8_t menuCount>
static void SetMenuMax ( uint8_t  menu,
uint8_t  maxValue 
)
static

Sets the maximum value for a specific menu.

Parameters
menuThe menu index to set the maximum value for.
maxValueThe maximum value to set.

◆ Update() [1/2]

template<uint8_t menuCount>
static void Update ( )
static

Updates the menu state and processes user interactions.

Referenced by Menu::Update().

◆ Update() [2/2]

template<uint8_t menuCount>
static void Update ( )
static

Updates the menu system and processes button input.

◆ UpdateState()

template<uint8_t menuCount>
static void UpdateState ( )
staticprivate

Updates the button state and menu navigation.

◆ Wheel()

template<uint8_t menuCount>
static uint32_t Wheel ( byte  WheelPos)
staticprivate

Generates a color value based on a position on a color wheel.

Parameters
WheelPosThe position on the color wheel (0-255).
Returns
The corresponding 32-bit color value.

◆ WriteEEPROM() [1/3]

template<uint8_t menuCount>
static void WriteEEPROM ( uint16_t  index,
uint8_t  value 
)
staticprivate

Writes a value to EEPROM at the specified index.

Parameters
indexThe EEPROM address to write to.
valueThe value to write to EEPROM.

◆ WriteEEPROM() [2/3]

template<uint8_t menuCount>
static void WriteEEPROM ( uint16_t  index,
uint8_t  value 
)
staticprivate

Writes a value to EEPROM at the specified index.

Parameters
indexThe EEPROM address to write to.
valueThe value to write to EEPROM.

◆ WriteEEPROM() [3/3]

template<uint8_t menuCount>
static void WriteEEPROM ( uint16_t  index,
uint8_t  value 
)
staticprivate

Writes a value to EEPROM at the specified index.

Parameters
indexThe EEPROM address to write to.
valueThe value to write to EEPROM.

Member Data Documentation

◆ currentMenu

template<uint8_t menuCount>
static uint8_t currentMenu
staticprivate

Index of the currently active menu.

Definition at line 32 of file NeoTrellisMenuHandler.h.

◆ currentSetting

template<uint8_t menuCount>
uint8_t currentSetting
staticprivate

Index of the currently active setting within the menu.

Definition at line 33 of file NeoTrellisMenuHandler.h.

◆ currentValue

template<uint8_t menuCount>
static uint8_t currentValue
staticprivate

Array of current values for each menu.

Definition at line 34 of file NeoTrellisMenuHandler.h.

◆ didBegin

template<uint8_t menuCount>
bool didBegin
staticprivate

Flag indicating whether the initialization process has been completed.

Definition at line 39 of file NeoTrellisMenuHandler.h.

◆ faceChoices

template<uint8_t menuCount>
uint8_t faceChoices
staticprivate

Number of face choices available.

Definition at line 36 of file NeoTrellisMenuHandler.h.

◆ holdingState

template<uint8_t menuCount>
bool holdingState
staticprivate

Indicates whether the button is in a holding state.

Definition at line 39 of file SingleButtonMenuHandler.h.

◆ holdingTime

template<uint8_t menuCount>
uint16_t holdingTime
staticprivate

Time threshold for detecting holding behavior in milliseconds.

Definition at line 34 of file SingleButtonMenuHandler.h.

◆ inputCount

template<uint8_t menuCount>
uint8_t inputCount
staticprivate

Number of Morse code inputs received.

Definition at line 31 of file SingleButtonMorseHandler.h.

◆ inputStream

template<uint8_t menuCount>
uint16_t inputStream[4]
staticprivate

Buffer for storing Morse code input.

Definition at line 32 of file SingleButtonMorseHandler.h.

◆ isReady

template<uint8_t menuCount>
bool isReady
staticprivate

Flag indicating whether the menu system is ready for interaction.

Definition at line 38 of file NeoTrellisMenuHandler.h.

◆ maxValue

template<uint8_t menuCount>
static uint8_t maxValue
staticprivate

Array of maximum values for each menu.

Definition at line 35 of file NeoTrellisMenuHandler.h.

◆ menuActive

template<uint8_t menuCount>
bool menuActive
staticprivate

Flag indicating whether the menu is active.

Definition at line 37 of file NeoTrellisMenuHandler.h.

◆ menuChangeTimer

template<uint8_t menuCount>
IntervalTimer menuChangeTimer
staticprivate

Timer for handling menu change intervals.

Definition at line 32 of file SingleButtonMenuHandler.h.

◆ pin

template<uint8_t menuCount>
static uint8_t pin
staticprivate

The pin number associated with the button.

Definition at line 38 of file SingleButtonMenuHandler.h.

◆ previousMillis

template<uint8_t menuCount>
long previousMillis
staticprivate

Tracks the last button press time in milliseconds.

Definition at line 30 of file SingleButtonMorseHandler.h.

◆ previousMillisHold

template<uint8_t menuCount>
long previousMillisHold
staticprivate

Tracks the last hold event time in milliseconds.

Definition at line 33 of file SingleButtonMenuHandler.h.

◆ previousState

template<uint8_t menuCount>
static bool previousState
staticprivate

Tracks the previous state of the button.

Definition at line 40 of file SingleButtonMenuHandler.h.

◆ trellis

template<uint8_t menuCount>
Adafruit_NeoTrellis trellis
staticprivate

Instance of the Adafruit NeoTrellis keypad.

Definition at line 31 of file NeoTrellisMenuHandler.h.


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