Skip to content

Commit c978c78

Browse files
author
3djc
committedApr 1, 2025
fix: prevent allocated RGB leds to be used
1 parent 00d0384 commit c978c78

File tree

6 files changed

+13
-5
lines changed

6 files changed

+13
-5
lines changed
 

‎radio/src/boards/generic_stm32/rgb_leds.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
4747
{
4848
#if defined(SIXPOS_SWITCH_INDEX)
4949
ws2812_set_color(led + 6, r, g, b);
50+
#elif defined(RGB_LED_OFFSET)
51+
ws2812_set_color(led + RGB_LED_OFFSET, r, g, b);
5052
#else
5153
ws2812_set_color(led, r, g, b);
5254
#endif

‎radio/src/gui/gui_common.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ bool isAssignableFunctionAvailable(int function, bool modelFunctions)
672672
#if !defined(LED_STRIP_GPIO)
673673
case FUNC_RGB_LED:
674674
return false;
675+
#elif defined(RGB_LED_OFFSET)
676+
case FUNC_RGB_LED:
677+
return (LED_STRIP_LENGTH > RGB_LED_OFFSET);
675678
#endif
676679
#if !defined(DEBUG)
677680
case FUNC_TEST:

‎radio/src/lua/api_general.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -3197,6 +3197,8 @@ LROT_BEGIN(etxcst, NULL, 0)
31973197
#if defined(LED_STRIP_GPIO)
31983198
#if defined(RADIO_V16)
31993199
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - 6)
3200+
#elif defined(RGB_LED_OFFSET)
3201+
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH - RGB_LED_OFFSET)
32003202
#else
32013203
LROT_NUMENTRY( LED_STRIP_LENGTH, LED_STRIP_LENGTH )
32023204
#endif

‎radio/src/targets/taranis/gx12/bsp_io.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "drivers/pca95xx.h"
2525
#include "stm32_i2c_driver.h"
2626
#include "timers_driver.h"
27-
#include "boards/generic_stm32/rgb_leds.h"
27+
#include "stm32_ws2812.h"
2828

2929
#include <FreeRTOS/include/FreeRTOS.h>
3030
#include <FreeRTOS/include/timers.h>
@@ -180,10 +180,10 @@ static SwitchHwPos _get_switch_pos(uint8_t idx)
180180
}
181181

182182
if(pos == SWITCH_HW_UP) {
183-
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
183+
ws2812_set_color(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
184184
}
185185
else {
186-
rgbSetLedColor(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
186+
ws2812_set_color(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
187187
}
188188
}
189189
else if (!def->pin_low) {

‎radio/src/targets/taranis/hal.h

+1
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@
19651965
#if defined(RGBLEDS)
19661966
#if defined(RADIO_GX12)
19671967
#define LED_STRIP_LENGTH 8
1968+
#define RGB_LED_OFFSET 8
19681969
#else
19691970
#define LED_STRIP_LENGTH 7
19701971
#endif

‎radio/src/targets/taranis/led_driver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "boards/generic_stm32/rgb_leds.h"
2626
#include "board.h"
2727
#if defined(LED_STRIP_GPIO)
28-
#include "boards/generic_stm32/rgb_leds.h"
28+
#include "stm32_ws2812.h"
2929
#endif
3030

3131
#define GET_RED(color) (((color) & 0xFF0000) >>16)
@@ -65,7 +65,7 @@ uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6};
6565

6666
void fsLedRGB(uint8_t index, uint32_t color)
6767
{
68-
rgbSetLedColor(ledMapping[index], GET_RED(color), \
68+
ws2812_set_color(ledMapping[index], GET_RED(color), \
6969
GET_GREEN(color),GET_BLUE(color));
7070
}
7171

0 commit comments

Comments
 (0)