Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / light_ws2811strip.h
blob94c36445ec7532cb2868e3e6cae2c51cad2d9d8f
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight 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.
9 * Cleanflight 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.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
19 #include "common/color.h"
20 #include "config/parameter_group.h"
22 #define WS2811_LED_STRIP_LENGTH 128
23 #define WS2811_BITS_PER_LED 24
24 #define WS2811_DELAY_BUFFER_LENGTH 42 // for 50us delay
26 #define WS2811_DATA_BUFFER_SIZE (WS2811_BITS_PER_LED * WS2811_LED_STRIP_LENGTH)
28 #define WS2811_DMA_BUFFER_SIZE (WS2811_DELAY_BUFFER_LENGTH + WS2811_DATA_BUFFER_SIZE + 1) // leading bytes (reset low 302us) + data bytes LEDS*3 + 1 byte(keep line high optionally)
30 #define WS2811_TIMER_HZ 2400000
31 #define WS2811_CARRIER_HZ 800000
33 typedef enum {
34 LED_PIN_PWM_MODE_SHARED_LOW = 0,
35 LED_PIN_PWM_MODE_SHARED_HIGH = 1,
36 LED_PIN_PWM_MODE_LOW = 2,
37 LED_PIN_PWM_MODE_HIGH = 3
38 } led_pin_pwm_mode_e;
40 typedef struct ledPinConfig_s {
41 uint8_t led_pin_pwm_mode; //led_pin_pwm_mode_e
42 } ledPinConfig_t;
44 PG_DECLARE(ledPinConfig_t, ledPinConfig);
46 void ws2811LedStripInit(void);
47 void ws2811LedStripHardwareInit(void);
48 void ws2811LedStripDMAEnable(void);
49 bool ws2811LedStripDMAInProgress(void);
51 //value 0...100
52 void ledPinStartPWM(uint16_t value);
53 void ledPinStopPWM(void);
55 void ws2811UpdateStrip(void);
57 void setLedHsv(uint16_t index, const hsvColor_t *color);
58 void getLedHsv(uint16_t index, hsvColor_t *color);
60 void scaleLedValue(uint16_t index, const uint8_t scalePercent);
61 void setLedValue(uint16_t index, const uint8_t value);
63 void setStripColor(const hsvColor_t *color);
64 void setStripColors(const hsvColor_t *colors);
66 bool isWS2811LedStripReady(void);