chore(radio): save some ram in radios with RGB LEDs (#5973)

Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: Risto <rotorman@users.noreply.github.com>
This commit is contained in:
3djc
2025-03-11 12:04:12 +10:00
committed by GitHub
co-authored by 3djc Risto
parent 538c5fcf40
commit 5bb7612040
8 changed files with 50 additions and 60 deletions
+18 -3
View File
@@ -36,6 +36,8 @@
#include <FreeRTOS/include/timers.h>
#endif
static uint8_t _led_colors[WS2812_BYTES_PER_LED * LED_STRIP_LENGTH];
extern const stm32_pulse_timer_t _led_timer;
static TimerHandle_t rgbLedTimer = nullptr;
@@ -55,7 +57,6 @@ uint32_t rgbGetLedColor(uint8_t led)
return ws2812_get_color(led);
}
bool rgbGetState(uint8_t led)
{
return ws2812_get_state(led);
@@ -63,7 +64,15 @@ bool rgbGetState(uint8_t led)
void rgbLedColorApply()
{
ws2812_update(&_led_timer);;
ws2812_update(&_led_timer);
}
void rgbLedClearAll()
{
for (uint8_t i = 0; i < LED_STRIP_LENGTH; i++) {
ws2812_set_color(i, 0, 0, 0);
}
ws2812_update(&_led_timer);
}
static void rgbLedTimerCb(TimerHandle_t xTimer)
@@ -111,6 +120,12 @@ const stm32_pulse_timer_t _led_timer = {
.DMA_TC_CallbackPtr = nullptr,
};
void rgbLedInit()
{
ws2812_init(&_led_timer, _led_colors, LED_STRIP_LENGTH, WS2812_GRB);
rgbLedClearAll();
}
// Make sure the timer channel is supported
static_assert(__STM32_PULSE_IS_TIMER_CHANNEL_SUPPORTED(LED_STRIP_TIMER_CHANNEL),
"Unsupported timer channel");
@@ -128,4 +143,4 @@ extern "C" void LED_STRIP_TIMER_DMA_IRQHandler()
ws2812_dma_isr(&_led_timer);
}
#endif
#endif
+10 -3
View File
@@ -21,9 +21,16 @@
#pragma once
#include <stdint.h>
void rgbLedInit();
void rgbLedStart();
void rgbLedStop();
void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char);
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b);
uint32_t rgbGetLedColor(uint8_t led);
bool rgbGetState(unsigned char);
void rgbLedColorApply();
void rgbLedClearAll();
bool rgbGetState(uint8_t led);
void rgbLedColorApply();