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:
@@ -32,10 +32,7 @@
|
||||
#include <string.h>
|
||||
|
||||
// Pixel values
|
||||
static uint8_t _led_colors[WS2812_BYTES_PER_LED * WS2812_MAX_LEDS];
|
||||
|
||||
// Timer used
|
||||
// static const stm32_pulse_timer_t* _led_timer;
|
||||
static uint8_t* _led_colors = nullptr;
|
||||
|
||||
// LED strip length
|
||||
static uint8_t _led_strip_len;
|
||||
@@ -200,20 +197,17 @@ static void _init_timer(const stm32_pulse_timer_t* tim)
|
||||
NVIC_SetPriority(tim->DMA_IRQn, WS2812_DMA_IRQ_PRIO);
|
||||
}
|
||||
|
||||
void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t strip_len, uint8_t type)
|
||||
void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t* strip_colors,
|
||||
uint8_t strip_len, uint8_t type)
|
||||
{
|
||||
WS2812_DBG_INIT;
|
||||
pulse_inc = IS_TIM_32B_COUNTER_INSTANCE(timer->TIMx) ? 2 : 1;
|
||||
|
||||
memset(_led_colors, 0, sizeof(_led_colors));
|
||||
_led_colors = strip_colors;
|
||||
_led_strip_len = strip_len;
|
||||
memset(_led_colors, 0, strip_len * WS2812_BYTES_PER_LED);
|
||||
memset(_led_dma_buffer, 0, sizeof(_led_dma_buffer));
|
||||
|
||||
if (strip_len <= WS2812_MAX_LEDS) {
|
||||
_led_strip_len = strip_len;
|
||||
} else {
|
||||
_led_strip_len = WS2812_MAX_LEDS;
|
||||
}
|
||||
|
||||
_r_offset = (type >> 4) & 0b11;
|
||||
_g_offset = (type >> 2) & 0b11;
|
||||
_b_offset = type & 0b11;
|
||||
|
||||
@@ -30,20 +30,16 @@
|
||||
// RGB
|
||||
#define WS2812_BYTES_PER_LED 3
|
||||
|
||||
// Maximum number of supported LEDs
|
||||
#if !defined(WS2812_MAX_LEDS)
|
||||
# define WS2812_MAX_LEDS 48
|
||||
#endif
|
||||
|
||||
// Number of LED periods used for trailing reset
|
||||
#if !defined(WS2812_TRAILING_RESET)
|
||||
# define WS2812_TRAILING_RESET 10
|
||||
#endif
|
||||
|
||||
void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t strip_len, uint8_t type);
|
||||
void ws2812_init(const stm32_pulse_timer_t* timer, uint8_t* strip_colors,
|
||||
uint8_t strip_len, uint8_t type);
|
||||
void ws2812_update(const stm32_pulse_timer_t* timer);
|
||||
bool ws2812_get_state(uint8_t led);
|
||||
void ws2812_dma_isr(const stm32_pulse_timer_t* timer);
|
||||
|
||||
void ws2812_set_color(uint8_t led, uint8_t r, uint8_t g, uint8_t b);
|
||||
uint32_t ws2812_get_color(uint8_t led);
|
||||
uint32_t ws2812_get_color(uint8_t led);
|
||||
|
||||
Reference in New Issue
Block a user