Namespace: DadGUI::cPaletteBuilder Files: cPaletteBuilder.h / cPaletteBuilder.cpp Directory: DAD_FORGE/GUI/Themes/ Inheritance: N/A Description: Parses and processes color palette definitions received via a USB serial connection (ASCII format) to update a palette structure in real-time.
π Class Description
The cPaletteBuilder class implements a lightweight incremental parser based on a state machine. It is designed to process ASCII data streams arriving character by character (via a FIFO buffer). The expected format is ColorName=#RRGGBB. When a valid command is detected, the corresponding color in the local palette is updated, enabling dynamic customization of the user interface.
π External Dependencies
File Inclusions
Included File
Source
Role
"main.h"
System
Basic project definitions
"cBuff.h"
DAD_FORGE/Utils
FIFO buffer management for serial data
"GUI_Defines.h"
DAD_FORGE/GUI
Graphics type definitions (e.g., sColor)
"@Options.h"
DAD_FORGE/
Project configuration
Global Variables
Variable / Object
Type
Source
Role
__DataBuff
DadUtilities::cBuff
extern in cPaletteBuilder.cpp
Global FIFO buffer receiving USB data
External Functions Called
Function
Source
Usage
UsbCallback
USB Driver
Callback function called by the USB driver to fill the __DataBuff buffer
π― Enumerations and Associated Structures
State (Enum)
Represents the current state of the parserβs state machine. | Element | Value | Description | |:β|:β|:β| | WAITING_NAME | - | Waiting for the first valid character of the color name | | READING_NAME | - | Reading the color name until the β=β character | | WAITING_HASH | - | Waiting for the β#β character preceding the hex code | | READING_COLOR | - | Reading the 6-character hex sequence (RRGGBB) |
sColorPalette (Structure)
Structure containing all the interface color properties (Menu, Settings, Info, VU Meter, etc.).
π Public Methods
cPaletteBuilder
Element
Details
Method
cPaletteBuilder()
Description
Constructor. Initializes the parser and resets the change flags.