LED API
Overview
The LED system in Matrix OS is very powerful and handles different layer, self timed update, and cross fade animations.
For some LED API, you can specific an layer ID. If you don't specify a layer ID, the API will use 255, which means the top most layer.
After making changes on the layer, it will only take effect and render onto the device by using the Update()
However, you can make your changes take effect immediately by write to layer 0, which is the active buffer. Your changes will be rendered to the device immediately. (Unless you pause the update with PauseUpdate(true)
)
This is great for real time rendering for like light show, but it might cause flickering and tearing. Also it will not be able to persevere if you create a new layer unless you copy the layer 0 to a layer first.
The header file for this API is part of os/MatrixOS.h and the implementation is in os/system/LED.cpp.
MatrixOS::LED::NextBrightness
void NextBrightness();
Cycles to the next predefined brightness level for the LEDs.
MatrixOS::LED::SetBrightness
void SetBrightness(uint8_t brightness);
Sets the brightness level of the LEDs.
Parameters:
brightness
(uint8_t
): Brightness level (0-255).
MatrixOS::LED::SetBrightnessMultiplier
void SetBrightnessMultiplier(string partition_name, float multiplier);
Applies a multiplier to the brightness of a specific partition.
Parameters:
partition_name
: Name of the LED partition.multiplier
(float
): Multiplier value for brightness.
MatrixOS::LED::SetColor
(by position)
void SetColor(Point xy, Color color, uint8_t layer = 255);
Sets the color of an LED at the specified position.
Parameters:
xy
(Point
): The position of the LED.color
(Color
): The color to set.layer
(uint8_t
, optional): The layer to apply the color to. Defaults to255
- the top layer.
MatrixOS::LED::SetColor
(by ID)
void SetColor(uint16_t ID, Color color, uint8_t layer = 255);
Sets the color of an LED by its ID.
Parameters:
ID
(uint16_t
): The ID of the LED.color
(Color
): The color to set.layer
(uint8_t
, optional): The layer to apply the color to. Defaults to255
.
MatrixOS::LED::Fill
void Fill(Color color, uint8_t layer = 255);
Fills all LEDs with a specified color.
Parameters:
color
(Color
): The color to fill with.layer
(uint8_t
, optional): The layer to apply the color to. Defaults to255
- the top layer.