-
Notifications
You must be signed in to change notification settings - Fork 3
RaftCoreLEDPixels
The LEDPixels module is responsible for managing and controlling LED strips and segments (arbitrary groupings of LEDs). It handles the setup, management of LED patterns, and updates to LED states. The module also includes functionality for starting/stopping patterns, showing pixels, and handling per-pixel settings.
- LED Strip Management: Supports multiple LED strips with individual drivers.
- Segmented Control: Allows for dividing the pixel array into logical segments.
- Pattern Support: Allows custom patterns to be applied to the LEDs.
- Callbacks: Pre and post-show callbacks for additional control during pixel updates.
Configuration is generally done via JSON although a LEDPixelConfig object can also be constructed directly and setup in this way. For JSON configuration see LEDPixels JSON Configuration
The constructor initializes the LEDPixels object.
The destructor is responsible for cleaning up resources used by the LEDPixels object.
This setup function configures the LED pixels based on a provided configuration in JSON format. It initializes the number of pixels, the LED strip drivers, and the segments.
-
config: The configuration object (RaftJsonIF) that contains the settings for the LED pixel setup.
-
bool: Returnstrueif the setup was successful,falseotherwise.
An alternative setup method that directly accepts a LEDPixelConfig object. It initializes the pixel array, LED strip drivers, and LED segments.
-
config: A configuration object containing the LED pixel settings (LEDPixelConfig).
-
bool: Returnstrueif the setup was successful,falseotherwise.
The main loop function that updates the LED strips and segments. It processes each segment, updating patterns and handling stop requests.
This function adds a custom pattern to the LED system. If a pattern with the same name exists, it replaces the old pattern with the new one.
-
patternName: The name of the new pattern to add. -
createFn: The function that creates the pattern (LEDPatternCreateFn).
This function retrieves the names of all available patterns.
-
patternNames: A vector to store the names of all available patterns.
Retrieves the index of a segment by its name.
-
segmentName: The name of the segment to find.
-
int32_t: The index of the segment, or-1if the segment is not found.
Updates the LEDs by sending the current pixel values to the hardware drivers. It also triggers pre and post-show callbacks if defined.
-
bool: Always returnstrueafter showing the pixels.
Waits until the hardware drivers finish updating the LEDs.
Clears all pixels by setting their color values to zero. Optionally, it can call show() after clearing.
-
showAfterClear: Iftrue, theshow()function is called after clearing the pixels.
Several compile-time debug options are available to log pixel and segment data:
-
DEBUG_LED_PIXEL_VALUES: Logs the color values of each pixel during theshow()process. -
DEBUG_LED_PIXELS_LOOP_SHOW: Logs information about segment updates and stop requests during theloop()process.