mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 09:16:07 +03:00
Cleanup WS2811 code and sanitize API.
Removed many magic numbers. Deduplicated code. Removed unnecessary local variable usage. The LED Strip is initialised to WHITE briefly on power up so that it's possible to visually check that all LEDs are functioning correctly - white uses each individual RGB diode and draws maximum power. Introduced an API to allow any code to change any or all LED colors individually. This takes a little ram since an additional buffer is needed - 3 bytes per LED, in addition to the DMA buffer.
This commit is contained in:
parent
c82754f5dc
commit
651a433718
3 changed files with 129 additions and 110 deletions
|
@ -17,6 +17,32 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
void ws2811LedStripInit(void);
|
||||
void ws2812SetStripColors(const uint8_t (*color)[3], uint16_t ledCount);
|
||||
|
||||
typedef enum {
|
||||
CC_RED = 0,
|
||||
CC_GREEN,
|
||||
CC_BLUE
|
||||
} colorComponent_e;
|
||||
|
||||
#define COLOR_COMPONENT_COUNT (CC_BLUE + 1)
|
||||
|
||||
struct rgbColor24bpp_s {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
typedef union {
|
||||
struct rgbColor24bpp_s rgb;
|
||||
uint8_t raw[COLOR_COMPONENT_COUNT];
|
||||
} rgbColor24bpp_t;
|
||||
|
||||
void ws2811LedStripInit(void);
|
||||
|
||||
void ws2811UpdateStrip(void);
|
||||
void setLedColor(uint16_t index, const rgbColor24bpp_t *color);
|
||||
void setStripColor(const rgbColor24bpp_t *color);
|
||||
void setStripColors(const rgbColor24bpp_t *colors);
|
||||
|
||||
extern const rgbColor24bpp_t black;
|
||||
extern const rgbColor24bpp_t white;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue