NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
light_ws2811strip.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #define WS2811_LED_STRIP_LENGTH 32
21 #define WS2811_BITS_PER_LED 24
22 #define WS2811_DELAY_BUFFER_LENGTH 42 // for 50us delay
23 
24 #define WS2811_DATA_BUFFER_SIZE (WS2811_BITS_PER_LED * WS2811_LED_STRIP_LENGTH)
25 
26 #define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) // number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes)
27 
28 #define BIT_COMPARE_1 17 // timer compare value for logical 1
29 #define BIT_COMPARE_0 9 // timer compare value for logical 0
30 
31 void ws2811LedStripInit(void);
32 
34 void ws2811LedStripDMAEnable(void);
35 
36 void ws2811UpdateStrip(void);
37 
38 void setLedHsv(int index, const hsvColor_t *color);
39 void getLedHsv(int index, hsvColor_t *color);
40 
41 void scaleLedValue(int index, const uint8_t scalePercent);
42 void setLedValue(int index, const uint8_t value);
43 
44 void setStripColor(const hsvColor_t *color);
45 void setStripColors(const hsvColor_t *colors);
46 
47 bool isWS2811LedStripReady(void);
48 
50 extern volatile uint8_t ws2811LedDataTransferInProgress;
uint8_t ledStripDMABuffer[WS2811_DMA_BUFFER_SIZE]
Definition: light_ws2811strip.c:39
void ws2811LedStripInit(void)
Definition: light_ws2811strip.c:87
volatile uint8_t ws2811LedDataTransferInProgress
Definition: light_ws2811strip.c:40
void setLedHsv(int index, const hsvColor_t *color)
Definition: light_ws2811strip.c:44
void setStripColor(const hsvColor_t *color)
Definition: light_ws2811strip.c:64
void setStripColors(const hsvColor_t *colors)
Definition: light_ws2811strip.c:70
bool isWS2811LedStripReady(void)
Definition: light_ws2811strip.c:95
void ws2811LedStripHardwareInit(void)
Definition: light_ws2811strip_stm32f10x.c:27
#define WS2811_DMA_BUFFER_SIZE
Definition: light_ws2811strip.h:26
uint8_t color[LED_SPECIAL_COLOR_COUNT]
Definition: ledstrip.h:9
void ws2811UpdateStrip(void)
Definition: light_ws2811strip.c:116
struct hsvColor_s colors[LED_CONFIGURABLE_COLOR_COUNT]
Definition: ledstrip.h:10
void getLedHsv(int index, hsvColor_t *color)
Definition: light_ws2811strip.c:49
void scaleLedValue(int index, const uint8_t scalePercent)
Definition: light_ws2811strip.c:59
void ws2811LedStripDMAEnable(void)
Definition: light_ws2811strip_stm32f10x.c:115
Definition: color.h:49
void setLedValue(int index, const uint8_t value)
Definition: light_ws2811strip.c:54