some optimizations regarding LED color
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
29
firmware/components/insa/include/common/ColorSettingsMenu.h
Normal file
29
firmware/components/insa/include/common/ColorSettingsMenu.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Menu.h"
|
||||
|
||||
namespace ColorSettingsMenuOptions
|
||||
{
|
||||
constexpr auto RED = "red_";
|
||||
constexpr auto GREEN = "green_";
|
||||
constexpr auto BLUE = "blue_";
|
||||
} // namespace ColorSettingsMenuOptions
|
||||
|
||||
class ColorSettingsMenu : public Menu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a ColorSettingsMenu with the specified options
|
||||
* @param options Pointer to menu configuration options structure
|
||||
* @details Initializes the menu with color settings options
|
||||
*/
|
||||
explicit ColorSettingsMenu(menu_options_t *options, std::string prefix);
|
||||
|
||||
void onButtonPressed(const MenuItem &menuItem, const ButtonType button) override;
|
||||
|
||||
void onExit() override;
|
||||
|
||||
private:
|
||||
std::string m_suffix;
|
||||
menu_options_t *m_options;
|
||||
};
|
@@ -159,7 +159,7 @@ class Menu : public Widget
|
||||
* @note New items are created as selection items with auto-generated names
|
||||
* in the format "Section X" where X is the item number
|
||||
*/
|
||||
void setItemSize(size_t size);
|
||||
void setItemSize(size_t size, int8_t startIndex = 0);
|
||||
|
||||
/**
|
||||
* @brief Toggles the boolean state of a toggle menu item
|
||||
|
@@ -63,7 +63,7 @@ class Widget
|
||||
* @note This method is typically called by the UI management system during
|
||||
* screen transitions or focus changes.
|
||||
*/
|
||||
virtual void enter();
|
||||
virtual void onEnter();
|
||||
|
||||
/**
|
||||
* @brief Called when the widget is temporarily paused or loses focus
|
||||
@@ -76,7 +76,7 @@ class Widget
|
||||
* only if pause behavior is needed.
|
||||
* @note The widget should be prepared to resume from this state when resume() is called.
|
||||
*/
|
||||
virtual void pause();
|
||||
virtual void onPause();
|
||||
|
||||
/**
|
||||
* @brief Called when the widget resumes from a paused state
|
||||
@@ -89,7 +89,7 @@ class Widget
|
||||
* only if resume behavior is needed.
|
||||
* @note This method should restore the widget to the state it was in before pause() was called.
|
||||
*/
|
||||
virtual void resume();
|
||||
virtual void onResume();
|
||||
|
||||
/**
|
||||
* @brief Called when the widget is being destroyed or exits the system
|
||||
@@ -99,11 +99,11 @@ class Widget
|
||||
* save final state, or release resources that are not automatically freed.
|
||||
*
|
||||
* @note The base implementation is empty, allowing derived classes to override
|
||||
* only if exit behavior is needed.
|
||||
* only if onExit behavior is needed.
|
||||
* @note This method is called before the widget's destructor and provides
|
||||
* an opportunity for controlled shutdown of widget-specific resources.
|
||||
*/
|
||||
virtual void exit();
|
||||
virtual void onExit();
|
||||
|
||||
/**
|
||||
* @brief Updates the widget's internal state based on elapsed time
|
||||
|
14
firmware/components/insa/include/ui/DayColorSettingsMenu.h
Normal file
14
firmware/components/insa/include/ui/DayColorSettingsMenu.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/ColorSettingsMenu.h"
|
||||
|
||||
class DayColorSettingsMenu final : public ColorSettingsMenu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a DayColorSettingsMenu with the specified options
|
||||
* @param options Pointer to menu configuration options structure
|
||||
* @details Initializes the menu with day color settings options
|
||||
*/
|
||||
explicit DayColorSettingsMenu(menu_options_t *options);
|
||||
};
|
@@ -19,84 +19,84 @@
|
||||
* @details This final class inherits from Menu and represents the main menu interface
|
||||
* of the application. It serves as the primary entry point for user interaction
|
||||
* and provides navigation to all major application features and sub-menus.
|
||||
*
|
||||
*
|
||||
* The MainMenu class customizes the base Menu functionality by:
|
||||
* - Defining application-specific menu items during construction
|
||||
* - Implementing custom button handling for main menu navigation
|
||||
* - Managing transitions to sub-menus and application features
|
||||
*
|
||||
*
|
||||
* This class is typically the first screen presented to users after the splash
|
||||
* screen and serves as the central hub for all application functionality.
|
||||
*
|
||||
*
|
||||
* @note This class is marked as final and cannot be inherited from.
|
||||
*
|
||||
*
|
||||
* @see Menu for base menu functionality
|
||||
* @see menu_options_t for configuration structure
|
||||
*/
|
||||
class MainMenu final : public Menu
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs the main menu with the specified configuration
|
||||
* @param options Pointer to menu options configuration structure
|
||||
*
|
||||
*
|
||||
* @pre options must not be nullptr and must remain valid for the menu's lifetime
|
||||
* @pre options->u8g2 must be initialized and ready for graphics operations
|
||||
* @pre All callback functions in options must be properly configured
|
||||
* @post MainMenu is initialized with application-specific menu items and ready for use
|
||||
*
|
||||
*
|
||||
* @details The constructor initializes the main menu by setting up all the
|
||||
* primary application menu items such as:
|
||||
* - Settings access
|
||||
* - Feature-specific menus
|
||||
* - System controls
|
||||
* - Application exit options
|
||||
*
|
||||
* - Application onExit options
|
||||
*
|
||||
* @note The menu does not take ownership of the options structure and assumes
|
||||
* it remains valid throughout the menu's lifetime.
|
||||
*/
|
||||
explicit MainMenu(menu_options_t *options);
|
||||
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* @brief Handles button press events specific to main menu items
|
||||
* @param menuItem
|
||||
* @param button Type of button that was pressed
|
||||
*
|
||||
*
|
||||
* @details Overrides the base Menu class method to provide main menu-specific
|
||||
* button handling logic. This method processes user interactions with
|
||||
* main menu items and initiates appropriate actions such as:
|
||||
* - Navigation to sub-menus (Settings, Light Control, etc.)
|
||||
* - Direct feature activation
|
||||
* - System operations
|
||||
*
|
||||
*
|
||||
* The method uses the menu item ID to determine which action to take and
|
||||
* utilizes the callback functions provided in m_options to perform screen
|
||||
* transitions or other application-level operations.
|
||||
*
|
||||
*
|
||||
* @note This method is called by the base Menu class when a button press
|
||||
* occurs on a menu item, after the base class has handled standard
|
||||
* navigation operations.
|
||||
*
|
||||
*
|
||||
* @see Menu::onButtonPressed for the base implementation
|
||||
* @see ButtonType for available button types
|
||||
*/
|
||||
void onButtonPressed(const MenuItem& menuItem, ButtonType button) override;
|
||||
void onButtonPressed(const MenuItem &menuItem, ButtonType button) override;
|
||||
|
||||
/**
|
||||
* @brief Pointer to menu options configuration structure
|
||||
* @details Stores a reference to the menu configuration passed during construction.
|
||||
* This pointer provides access to the display context and callback functions
|
||||
* needed for menu operations, screen transitions, and user interaction handling.
|
||||
*
|
||||
*
|
||||
* The configuration includes:
|
||||
* - Display context for rendering operations
|
||||
* - Screen management callbacks for navigation
|
||||
* - Input handling callbacks for button events
|
||||
*
|
||||
*
|
||||
* @note This pointer is not owned by the MainMenu and must remain valid
|
||||
* throughout the menu's lifetime. It is managed by the application framework.
|
||||
*
|
||||
*
|
||||
* @warning Must not be modified after construction as it may be shared
|
||||
* with other components.
|
||||
*/
|
||||
|
15
firmware/components/insa/include/ui/NightColorSettingsMenu.h
Normal file
15
firmware/components/insa/include/ui/NightColorSettingsMenu.h
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/ColorSettingsMenu.h"
|
||||
|
||||
class NightColorSettingsMenu final : public ColorSettingsMenu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a NightColorSettingsMenu with the specified options
|
||||
* @param options Pointer to menu configuration options structure
|
||||
* @details Initializes the menu with night color settings options
|
||||
*/
|
||||
explicit NightColorSettingsMenu(menu_options_t *options);
|
||||
};
|
Reference in New Issue
Block a user