fix(rgbled): double-buffer WS2812 strip to eliminate races (#7304)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
462b0351ef
commit
ac4c4d7b6b
@@ -27,7 +27,6 @@
|
||||
#include "edgetx.h"
|
||||
#include "mainwindow.h"
|
||||
#include "static.h"
|
||||
#include "stm32_ws2812.h"
|
||||
#include "LvglWrapper.h"
|
||||
|
||||
#define __BATTERY_DRIVER_C__
|
||||
@@ -603,8 +602,8 @@ void setLedGroupColor(uint8_t index, uint8_t color, uint8_t brightness) {
|
||||
scaled_b = brightness;
|
||||
}
|
||||
|
||||
ws2812_set_color(rgbMapping[index], scaled_r, scaled_g, scaled_b);
|
||||
ws2812_set_color(rgbMapping[index] + 1, scaled_r, scaled_g, scaled_b);
|
||||
rgbSetLedColor(rgbMapping[index], scaled_r, scaled_g, scaled_b);
|
||||
rgbSetLedColor(rgbMapping[index] + 1, scaled_r, scaled_g, scaled_b);
|
||||
}
|
||||
|
||||
uint8_t ledBreathBright(float angle, uint8_t maxBright) {
|
||||
@@ -655,11 +654,10 @@ void ledLoop(void) {
|
||||
ledBreathUpdate(led_info.led_state, led_info.led_color, led_info.led_group);
|
||||
}
|
||||
|
||||
extern const stm32_pulse_timer_t _led_timer;
|
||||
static uint8_t _led_charge_colors[WS2812_BYTES_PER_LED * LED_STRIP_LENGTH];
|
||||
void rgbChargeInit(void) {
|
||||
ws2812_init(&_led_timer, _led_charge_colors, LED_STRIP_LENGTH, WS2812_GRB);
|
||||
rgbLedClearAll();
|
||||
// Bring up the WS2812 strip without starting the periodic refresh timer
|
||||
// (the FreeRTOS scheduler isn't running yet during the charging UI).
|
||||
rgbLedHwInit();
|
||||
}
|
||||
|
||||
constexpr uint16_t vbatLedTable[] = {650, 720, 760, 800, 823 };
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/rgbleds.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_ws2812.h"
|
||||
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
#include "board.h"
|
||||
@@ -36,32 +35,37 @@ uint8_t ledMapping[] = {4, 6, 0, 2};
|
||||
|
||||
void fsLedRGB(uint8_t index, uint32_t color)
|
||||
{
|
||||
ws2812_set_color(ledMapping[index], GET_RED(color),
|
||||
rgbSetLedColor(ledMapping[index], GET_RED(color),
|
||||
GET_GREEN(color),GET_BLUE(color));
|
||||
ws2812_set_color(ledMapping[index]+1, GET_RED(color),
|
||||
rgbSetLedColor(ledMapping[index]+1, GET_RED(color),
|
||||
GET_GREEN(color),GET_BLUE(color));
|
||||
rgbLedColorApply();
|
||||
}
|
||||
|
||||
void ledOff()
|
||||
{
|
||||
ws2812_set_color(8, 0, 0, 0);
|
||||
ws2812_set_color(9, 0, 0, 0);
|
||||
rgbSetLedColor(8, 0, 0, 0);
|
||||
rgbSetLedColor(9, 0, 0, 0);
|
||||
rgbLedColorApply();
|
||||
}
|
||||
|
||||
void ledRed()
|
||||
{
|
||||
ws2812_set_color(8, 20, 0, 0);
|
||||
ws2812_set_color(9, 20, 0, 0);
|
||||
rgbSetLedColor(8, 20, 0, 0);
|
||||
rgbSetLedColor(9, 20, 0, 0);
|
||||
rgbLedColorApply();
|
||||
}
|
||||
|
||||
void ledGreen()
|
||||
{
|
||||
ws2812_set_color(8, 0, 20, 0);
|
||||
ws2812_set_color(9, 0, 20, 0);
|
||||
rgbSetLedColor(8, 0, 20, 0);
|
||||
rgbSetLedColor(9, 0, 20, 0);
|
||||
rgbLedColorApply();
|
||||
}
|
||||
|
||||
void ledBlue()
|
||||
{
|
||||
ws2812_set_color(8, 0, 0, 20);
|
||||
ws2812_set_color(9, 0, 0, 20);
|
||||
rgbSetLedColor(8, 0, 0, 20);
|
||||
rgbSetLedColor(9, 0, 0, 20);
|
||||
rgbLedColorApply();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user