fix(radio): prevent dedicated RGB LEDs flickering (#6045)

This commit is contained in:
3djc
2025-04-04 12:44:53 +10:00
committed by GitHub
parent 51b38dd4c6
commit 07ea98db4a
6 changed files with 21 additions and 14 deletions
@@ -47,6 +47,8 @@ void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
{
#if defined(SIXPOS_SWITCH_INDEX)
ws2812_set_color(led + 6, r, g, b);
#elif defined(RGB_LED_OFFSET)
ws2812_set_color(led + RGB_LED_OFFSET, r, g, b);
#else
ws2812_set_color(led, r, g, b);
#endif
+3
View File
@@ -672,6 +672,9 @@ bool isAssignableFunctionAvailable(int function, bool modelFunctions)
#if !defined(LED_STRIP_GPIO)
case FUNC_RGB_LED:
return false;
#elif defined(RGB_LED_OFFSET)
case FUNC_RGB_LED:
return (LED_STRIP_LENGTH > RGB_LED_OFFSET);
#endif
#if !defined(DEBUG)
case FUNC_TEST:
+2
View File
@@ -3197,6 +3197,8 @@ LROT_BEGIN(etxcst, NULL, 0)
#if defined(LED_STRIP_GPIO)
#if defined(RADIO_V16)
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - 6)
#elif defined(RGB_LED_OFFSET)
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - RGB_LED_OFFSET)
#else
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH )
#endif
+10 -11
View File
@@ -20,17 +20,17 @@
*/
#include "bsp_io.h"
#include "hal/switch_driver.h"
#include "drivers/pca95xx.h"
#include "stm32_i2c_driver.h"
#include "timers_driver.h"
#include "boards/generic_stm32/rgb_leds.h"
#include <FreeRTOS/include/FreeRTOS.h>
#include <FreeRTOS/include/timers.h>
#include "myeeprom.h"
#include "bitfield.h"
#include "drivers/pca95xx.h"
#include "hal/switch_driver.h"
#include "myeeprom.h"
#include "stm32_i2c_driver.h"
#include "stm32_ws2812.h"
#include "timers_driver.h"
struct bsp_io_expander {
pca95xx_t exp;
@@ -179,11 +179,10 @@ static SwitchHwPos _get_switch_pos(uint8_t idx)
}
if(pos == SWITCH_HW_UP) {
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
}
else {
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
if (pos == SWITCH_HW_UP) {
ws2812_set_color(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
} else {
ws2812_set_color(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
}
}
else if (!def->pin_low) {
+1
View File
@@ -1965,6 +1965,7 @@
#if defined(RGBLEDS)
#if defined(RADIO_GX12)
#define LED_STRIP_LENGTH 8
#define RGB_LED_OFFSET 8
#else
#define LED_STRIP_LENGTH 7
#endif
+3 -3
View File
@@ -25,7 +25,7 @@
#include "boards/generic_stm32/rgb_leds.h"
#include "board.h"
#if defined(LED_STRIP_GPIO)
#include "boards/generic_stm32/rgb_leds.h"
#include "stm32_ws2812.h"
#endif
#define GET_RED(color) (((color) & 0xFF0000) >>16)
@@ -65,8 +65,8 @@ uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6};
void fsLedRGB(uint8_t index, uint32_t color)
{
rgbSetLedColor(ledMapping[index], GET_RED(color), \
GET_GREEN(color),GET_BLUE(color));
ws2812_set_color(ledMapping[index], GET_RED(color), GET_GREEN(color),
GET_BLUE(color));
}
uint8_t getRGBColorIndex(uint32_t color)