send screen names to ESP Insights
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file Common.h
|
||||
* @brief Common definitions and types for the INSA component
|
||||
* @details This header file contains shared enumerations, type definitions, and
|
||||
* @details This header file contains shared enumerations, type definitions, and
|
||||
* callback function types used throughout the INSA component system.
|
||||
* It provides the foundation for button handling and event management.
|
||||
* @author System Control Team
|
||||
@@ -16,19 +16,19 @@
|
||||
* @enum ButtonType
|
||||
* @brief Enumeration defining the different types of buttons available in the system
|
||||
* @details This enumeration represents all possible button types that can be handled
|
||||
* by the system's input management. NONE represents no button pressed or
|
||||
* by the system's input management. NONE represents no button pressed or
|
||||
* an invalid button state, while the other values correspond to specific
|
||||
* directional and action buttons.
|
||||
*/
|
||||
enum class ButtonType
|
||||
{
|
||||
NONE, ///< No button pressed or invalid button state
|
||||
UP, ///< Up directional button for navigation
|
||||
DOWN, ///< Down directional button for navigation
|
||||
LEFT, ///< Left directional button for navigation
|
||||
RIGHT, ///< Right directional button for navigation
|
||||
NONE, ///< No button pressed or invalid button state
|
||||
UP, ///< Up directional button for navigation
|
||||
DOWN, ///< Down directional button for navigation
|
||||
LEFT, ///< Left directional button for navigation
|
||||
RIGHT, ///< Right directional button for navigation
|
||||
SELECT, ///< Select/confirm button for accepting choices
|
||||
BACK ///< Back/cancel button for returning to previous state
|
||||
BACK ///< Back/cancel button for returning to previous state
|
||||
};
|
||||
|
||||
// Forward declaration of MenuItem to avoid circular dependency
|
||||
@@ -40,13 +40,13 @@ class MenuItem;
|
||||
* @details This function type is used to define callback functions that handle
|
||||
* button press events. The callback receives information about which
|
||||
* button was pressed and any additional context data.
|
||||
*
|
||||
*
|
||||
* @param MenuItem menu item for the specific action
|
||||
* @param ButtonType The type of button that was pressed
|
||||
*
|
||||
*
|
||||
* @note The first parameter can be used to distinguish between multiple instances
|
||||
* of the same button type or to pass additional event-specific data.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* @code
|
||||
* ButtonCallback myCallback = [](const MenuItem& item, ButtonType type) {
|
||||
@@ -59,5 +59,37 @@ class MenuItem;
|
||||
*/
|
||||
typedef std::function<void(MenuItem, ButtonType)> ButtonCallback;
|
||||
|
||||
/**
|
||||
* @def IMPLEMENT_GET_NAME
|
||||
* @brief Macro to implement getName() method using __FILE__
|
||||
* @details Extracts the class name from the source filename automatically.
|
||||
* Use this macro in .cpp files to implement Widget::getName().
|
||||
* @param ClassName The class name for the method scope (e.g., MainMenu)
|
||||
*/
|
||||
#define IMPLEMENT_GET_NAME(ClassName) \
|
||||
const char *ClassName::getName() const \
|
||||
{ \
|
||||
static const char *cachedName = nullptr; \
|
||||
if (!cachedName) \
|
||||
{ \
|
||||
const char *file = __FILE__; \
|
||||
const char *lastSlash = file; \
|
||||
for (const char *p = file; *p; ++p) \
|
||||
{ \
|
||||
if (*p == '/' || *p == '\\') \
|
||||
lastSlash = p + 1; \
|
||||
} \
|
||||
static char buffer[64]; \
|
||||
size_t i = 0; \
|
||||
for (; lastSlash[i] && lastSlash[i] != '.' && i < sizeof(buffer) - 1; ++i) \
|
||||
{ \
|
||||
buffer[i] = lastSlash[i]; \
|
||||
} \
|
||||
buffer[i] = '\0'; \
|
||||
cachedName = buffer; \
|
||||
} \
|
||||
return cachedName; \
|
||||
}
|
||||
|
||||
// Include MenuItem.h after the typedef to avoid circular dependency
|
||||
#include "data/MenuItem.h"
|
||||
@@ -150,6 +150,19 @@ class Widget
|
||||
*/
|
||||
virtual void OnButtonClicked(ButtonType button);
|
||||
|
||||
/**
|
||||
* @brief Returns the name of this widget for diagnostic purposes
|
||||
* @return A string identifying the widget type
|
||||
*
|
||||
* @details This method returns a human-readable name for the widget which
|
||||
* is used for logging and diagnostic events. Derived classes should
|
||||
* override this method to return their specific screen/widget name.
|
||||
*
|
||||
* @note The base implementation returns "Widget". Override in derived classes
|
||||
* to provide meaningful screen names for diagnostics.
|
||||
*/
|
||||
virtual const char *getName() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Pointer to the u8g2 display context used for rendering operations
|
||||
|
||||
@@ -24,6 +24,7 @@ class ClockScreenSaver final : public Widget
|
||||
void Update(uint64_t dt) override;
|
||||
void Render() override;
|
||||
void OnButtonClicked(ButtonType button) override;
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
static constexpr int MOVE_INTERVAL = 50; // milliseconds between movements
|
||||
|
||||
@@ -7,6 +7,8 @@ class ExternalDevices final : public Menu
|
||||
public:
|
||||
explicit ExternalDevices(menu_options_t *options);
|
||||
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
void onButtonPressed(const MenuItem &menuItem, ButtonType button) override;
|
||||
menu_options_t *m_options;
|
||||
|
||||
@@ -80,6 +80,8 @@ class LightMenu final : public Menu
|
||||
*/
|
||||
explicit LightMenu(menu_options_t *options);
|
||||
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Handles button press events specific to light control menu items
|
||||
|
||||
@@ -57,6 +57,8 @@ class MainMenu final : public Menu
|
||||
*/
|
||||
explicit MainMenu(menu_options_t *options);
|
||||
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Handles button press events specific to main menu items
|
||||
|
||||
@@ -26,6 +26,7 @@ class ScreenSaver final : public Widget
|
||||
void Update(uint64_t dt) override;
|
||||
void Render() override;
|
||||
void OnButtonClicked(ButtonType button) override;
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -20,40 +20,40 @@
|
||||
* interface for the application. It allows users to configure various aspects
|
||||
* of the system including display preferences, system behavior, network
|
||||
* settings, and other configurable parameters.
|
||||
*
|
||||
*
|
||||
* The SettingsMenu class extends the base Menu functionality by:
|
||||
* - Providing settings-specific menu items (toggles, selections, number inputs)
|
||||
* - Managing configuration persistence and validation
|
||||
* - Organizing settings into logical categories and sections
|
||||
* - Implementing real-time preview of setting changes where applicable
|
||||
*
|
||||
*
|
||||
* Typical settings categories include:
|
||||
* - Display settings (brightness, contrast, theme)
|
||||
* - System preferences (timeouts, auto-save, etc.)
|
||||
* - Network configuration (if applicable)
|
||||
* - User interface preferences
|
||||
* - Hardware-specific parameters
|
||||
*
|
||||
*
|
||||
* @note This class is marked as final and cannot be inherited from.
|
||||
* @note Settings changes are typically applied immediately or after confirmation,
|
||||
* depending on the specific setting type and system requirements.
|
||||
*
|
||||
*
|
||||
* @see Menu for base menu functionality
|
||||
* @see menu_options_t for configuration structure
|
||||
* @see MainMenu for navigation back to main interface
|
||||
*/
|
||||
class SettingsMenu final : public Menu
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs the settings 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 SettingsMenu is initialized with all available configuration options and ready for use
|
||||
*
|
||||
*
|
||||
* @details The constructor initializes the settings menu by creating all the
|
||||
* configuration menu items based on the current system state and
|
||||
* available options. This includes:
|
||||
@@ -61,17 +61,19 @@ public:
|
||||
* - Creating appropriate menu items (toggles, selections, number inputs)
|
||||
* - Setting up validation ranges and allowed values
|
||||
* - Organizing items in a logical, user-friendly order
|
||||
*
|
||||
*
|
||||
* The menu automatically detects which settings are available based on
|
||||
* hardware capabilities and system configuration, ensuring only relevant
|
||||
* options are presented to the user.
|
||||
*
|
||||
*
|
||||
* @note The menu does not take ownership of the options structure and assumes
|
||||
* it remains valid throughout the menu's lifetime.
|
||||
* @note Setting values are loaded from persistent storage during construction
|
||||
* and changes are typically saved automatically or on confirmation.
|
||||
*
|
||||
*
|
||||
* @see Menu::Menu for base class construction details
|
||||
*/
|
||||
explicit SettingsMenu(menu_options_t *options);
|
||||
|
||||
const char *getName() const override;
|
||||
};
|
||||
@@ -151,6 +151,8 @@ class SplashScreen final : public Widget
|
||||
*/
|
||||
void Render() override;
|
||||
|
||||
const char *getName() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Pointer to menu options configuration structure
|
||||
|
||||
@@ -31,3 +31,8 @@ void Widget::Render()
|
||||
void Widget::OnButtonClicked(ButtonType button)
|
||||
{
|
||||
}
|
||||
|
||||
const char *Widget::getName() const
|
||||
{
|
||||
return "Widget";
|
||||
}
|
||||
|
||||
@@ -132,3 +132,5 @@ void ClockScreenSaver::OnButtonClicked(ButtonType button)
|
||||
m_options->popScreen();
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(ClockScreenSaver)
|
||||
|
||||
@@ -23,3 +23,5 @@ void ExternalDevices::onButtonPressed(const MenuItem &menuItem, const ButtonType
|
||||
ble_connect_to_device(menuItem.getId());
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(ExternalDevices)
|
||||
|
||||
@@ -123,3 +123,5 @@ void LightMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType butto
|
||||
m_options->pushScreen(widget);
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(LightMenu)
|
||||
|
||||
@@ -48,3 +48,5 @@ void MainMenu::onButtonPressed(const MenuItem &menuItem, const ButtonType button
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(MainMenu)
|
||||
|
||||
@@ -326,4 +326,6 @@ void ScreenSaver::OnButtonClicked(ButtonType button)
|
||||
{
|
||||
m_options->popScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(ScreenSaver)
|
||||
|
||||
@@ -8,4 +8,6 @@ constexpr uint8_t OTA_UPLOAD = 0;
|
||||
SettingsMenu::SettingsMenu(menu_options_t *options) : Menu(options)
|
||||
{
|
||||
addText(SettingsMenuItem::OTA_UPLOAD, "OTA Einspielen");
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(SettingsMenu)
|
||||
|
||||
@@ -28,3 +28,5 @@ void SplashScreen::Render()
|
||||
u8g2_SetFont(u8g2, u8g2_font_haxrcorp4089_tr);
|
||||
u8g2_DrawStr(u8g2, 35, 50, "Initialisierung...");
|
||||
}
|
||||
|
||||
IMPLEMENT_GET_NAME(SplashScreen)
|
||||
|
||||
Reference in New Issue
Block a user