1
0
Fork 0

[MERGE][Core] Add dirty chunk checking for all RGB and LED drivers (24872)

This commit is contained in:
Drashna Jael're 2025-01-26 04:52:39 -08:00
parent 0324612c37
commit 4a138dd93c
Signed by: drashna
GPG key ID: DBA1FD3A860D1B11
28 changed files with 690 additions and 286 deletions

View file

@ -77,6 +77,7 @@ void sendByte(uint8_t byte) {
}
ws2812_led_t ws2812_leds[WS2812_LED_COUNT];
bool ws2812_dirty = false;
void ws2812_init(void) {
palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE);
@ -86,6 +87,7 @@ void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
ws2812_leds[index].r = red;
ws2812_leds[index].g = green;
ws2812_leds[index].b = blue;
ws2812_dirty = true;
#if defined(WS2812_RGBW)
ws2812_rgb_to_rgbw(&ws2812_leds[index]);
#endif
@ -98,6 +100,8 @@ void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}
void ws2812_flush(void) {
if (!ws2812_dirty) return;
ws2812_dirty = false;
// this code is very time dependent, so we need to disable interrupts
chSysLock();

View file

@ -291,6 +291,7 @@ typedef uint8_t ws2812_buffer_t;
#endif
static ws2812_buffer_t ws2812_frame_buffer[WS2812_BIT_N + 1]; /**< Buffer for a frame */
bool ws2812_dirty = false;
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
/*
@ -310,7 +311,7 @@ void ws2812_init(void) {
palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE);
// PWM Configuration
//#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
// #pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
static const PWMConfig ws2812_pwm_config = {
.frequency = WS2812_PWM_TICK_FREQUENCY,
.period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben
@ -328,7 +329,7 @@ void ws2812_init(void) {
.dier = TIM_DIER_UDE, // DMA on update event for next period
#endif
};
//#pragma GCC diagnostic pop // Restore command-line warning options
// #pragma GCC diagnostic pop // Restore command-line warning options
// Configure DMA
// dmaInit(); // Joe added this
@ -398,6 +399,7 @@ void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
ws2812_leds[index].r = red;
ws2812_leds[index].g = green;
ws2812_leds[index].b = blue;
ws2812_dirty = true;
#if defined(WS2812_RGBW)
ws2812_rgb_to_rgbw(&ws2812_leds[index]);
#endif
@ -410,6 +412,8 @@ void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}
void ws2812_flush(void) {
if (!ws2812_dirty) return;
ws2812_dirty = false;
for (int i = 0; i < WS2812_LED_COUNT; i++) {
#if defined(WS2812_RGBW)
ws2812_write_led_rgbw(i, ws2812_leds[i].r, ws2812_leds[i].g, ws2812_leds[i].b, ws2812_leds[i].w);

View file

@ -165,6 +165,7 @@ static void set_led_color_rgb(ws2812_led_t color, int pos) {
}
ws2812_led_t ws2812_leds[WS2812_LED_COUNT];
bool ws2812_dirty = false;
void ws2812_init(void) {
palSetLineMode(WS2812_DI_PIN, WS2812_MOSI_OUTPUT_MODE);
@ -228,6 +229,7 @@ void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
ws2812_leds[index].r = red;
ws2812_leds[index].g = green;
ws2812_leds[index].b = blue;
ws2812_dirty = true;
#if defined(WS2812_RGBW)
ws2812_rgb_to_rgbw(&ws2812_leds[index]);
#endif
@ -240,6 +242,9 @@ void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}
void ws2812_flush(void) {
if (!ws2812_dirty) return;
ws2812_dirty = false;
for (int i = 0; i < WS2812_LED_COUNT; i++) {
set_led_color_rgb(ws2812_leds[i], i);
}