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/>.
20 #define MAX_LED_STRIP_LENGTH 32
21 #define CONFIGURABLE_COLOR_COUNT 16
23 #define LED_X_BIT_OFFSET 4
24 #define LED_Y_BIT_OFFSET 0
26 #define LED_XY_MASK (0x0F)
28 #define GET_LED_X(ledConfig) ((ledConfig->xy >> LED_X_BIT_OFFSET) & LED_XY_MASK)
29 #define GET_LED_Y(ledConfig) ((ledConfig->xy >> LED_Y_BIT_OFFSET) & LED_XY_MASK)
31 #define CALCULATE_LED_X(x) ((x & LED_XY_MASK) << LED_X_BIT_OFFSET)
32 #define CALCULATE_LED_Y(y) ((y & LED_XY_MASK) << LED_Y_BIT_OFFSET)
35 #define CALCULATE_LED_XY(x,y) (CALCULATE_LED_X(x) | CALCULATE_LED_Y(y))
39 LED_DIRECTION_NORTH
= (1 << 0),
40 LED_DIRECTION_EAST
= (1 << 1),
41 LED_DIRECTION_SOUTH
= (1 << 2),
42 LED_DIRECTION_WEST
= (1 << 3),
43 LED_DIRECTION_UP
= (1 << 4),
44 LED_DIRECTION_DOWN
= (1 << 5),
45 LED_FUNCTION_INDICATOR
= (1 << 6),
46 LED_FUNCTION_WARNING
= (1 << 7),
47 LED_FUNCTION_FLIGHT_MODE
= (1 << 8),
48 LED_FUNCTION_ARM_STATE
= (1 << 9),
49 LED_FUNCTION_THROTTLE
= (1 << 10),
50 LED_FUNCTION_THRUST_RING
= (1 << 11),
51 LED_FUNCTION_COLOR
= (1 << 12),
54 #define LED_DIRECTION_BIT_OFFSET 0
55 #define LED_DIRECTION_MASK ( \
56 LED_DIRECTION_NORTH | \
57 LED_DIRECTION_EAST | \
58 LED_DIRECTION_SOUTH | \
59 LED_DIRECTION_WEST | \
63 #define LED_FUNCTION_BIT_OFFSET 6
64 #define LED_FUNCTION_MASK ( \
65 LED_FUNCTION_INDICATOR | \
66 LED_FUNCTION_WARNING | \
67 LED_FUNCTION_FLIGHT_MODE | \
68 LED_FUNCTION_ARM_STATE | \
69 LED_FUNCTION_THROTTLE | \
70 LED_FUNCTION_THRUST_RING | \
75 typedef struct ledConfig_s
{
76 uint8_t xy
; // see LED_X/Y_MASK defines
77 uint8_t color
; // see colors (config_master)
78 uint16_t flags
; // see ledFlag_e
81 extern uint8_t ledCount
;
82 extern uint8_t ledsInRingCount
;
86 bool parseLedStripConfig(uint8_t ledIndex
, const char *config
);
87 void updateLedStrip(void);
88 void updateLedRing(void);
90 void applyDefaultLedStripConfig(ledConfig_t
*ledConfig
);
91 void generateLedConfig(uint8_t ledIndex
, char *ledConfigBuffer
, size_t bufferSize
);
93 bool parseColor(uint8_t index
, const char *colorConfig
);
94 void applyDefaultColors(hsvColor_t
*colors
, uint8_t colorCount
);
96 void ledStripEnable(void);
97 void reevalulateLedConfig(void);