3 Cleanflight supports the use of addressable LED strips. Addressable LED strips allow each LED in the strip to
4 be programmed with a unique and independant color. This is far more advanced than the normal RGB strips which
5 require that all the LEDs in the strip show the same color.
7 Addressable LED strips can be used to show information from the flight controller system, the current implementation
8 supports the following:
11 * Indicators showing pitch/roll stick positions.
12 * Heading/Orientation lights.
13 * Flight mode specific color schemes.
14 * Low battery warning.
15 * AUX operated on/off switch.
20 Support for more than 32 LEDs is possible, it just requires additional development.
24 Only strips of 32 WS2811/WS2812 LEDs are supported currently. If the strip is longer than 32 LEDs it does not matter,
25 but only the first 32 are used.
27 WS2812 LEDs require an 800khz signal and precise timings and thus requires the use of a dedicated hardware timer.
29 Note: Not all WS2812 ICs use the same timings, some batches use different timings.
31 It could be possible to be able to specify the timings required via CLI if users request it.
35 * [Adafruit NeoPixel Jewel 7](https://www.adafruit.com/products/2226) (preliminary testing)
36 * Measured current consumption in all white mode ~ 350 mA.
37 * Fits well under motors on mini 250 quads.
38 * [Adafruit NeoPixel Stick](https://www.adafruit.com/products/1426) (works well)
39 * Measured current consumption in all white mode ~ 350 mA.
44 The [WS2811](https://cdn-shop.adafruit.com/datasheets/WS2811.pdf) is a LED driver IC which is connected to an RGB LED. It accepts data in the form of 8 bits each of Red-Green-Blue.
46 The [WS2812](https://cdn-shop.adafruit.com/datasheets/WS2812.pdf) is integrated into the package of a 50:50 LED rather than as a separate device. It accepts data in the form of 8 bits each of Green-Red-Blue.
48 It is thus possible, depending on the LED board/strip being used that either Red-Green-Blue or Green-Red-Blue encoding may be required. This may be controlled by setting the following.
51 set ledstrip_grb_rgb = RGB
56 set ledstrip_grb_rgb = GRB
59 Then confirm the required setting by simply setting an LED to be green. If it lights up red, you have the wrong setting.
63 WS2812 LED strips generally require a single data line, 5V and GND.
65 WS2812 LEDs on full brightness can consume quite a bit of current. It is recommended to verify the current draw and ensure your
66 supply can cope with the load. On a multirotor that uses multiple BEC ESC's you can try use a different BEC to the one the FC
67 uses. e.g. ESC1/BEC1 -> FC, ESC2/BEC2 -> LED strip. It's also possible to power one half of the strip from one BEC and the other half
68 from another BEC. Just ensure that the GROUND is the same for all BEC outputs and LEDs.
71 | Target | Pin | LED Strip | Signal |
72 | --------------------- | ---- | --------- | -------|
73 | Naze | RC5 | Data In | PA6 |
74 | CC3D | RCO5 | Data In | PB4 |
75 | ChebuzzF3/F3Discovery | PB8 | Data In | PB8 |
76 | Sparky | PWM5 | Data In | PA6 |
78 Since RC5 is also used for SoftSerial on the Naze it means that you cannot use SoftSerial and led strips at the same time.
79 Additionally, since RC5 is also used for Parallel PWM RC input on both the Naze, Chebuzz and STM32F3Discovery targets, led strips
80 can not be used at the same time at Parallel PWM.
82 If you have LEDs that are intermittent, flicker or show the wrong colors then drop the VIN to less than 4.7v, e.g. by using an inline
83 diode on the VIN to the LED strip. The problem occurs because of the difference in voltage between the data signal and the power
84 signal. The WS2811 LED's require the data signal (Din) to be between 0.3 * Vin (Max) and 0.7 * VIN (Min) to register valid logic
85 low/high signals. The LED pin on the CPU will always be between 0v to ~3.3v, so the Vin should be 4.7v (3.3v / 0.7 = 4.71v).
86 Some LEDs are more tolerant of this than others.
88 The datasheet can be found here: http://www.adafruit.com/datasheets/WS2812.pdf
92 The led strip feature can be configured via the GUI.
95 Enable the Led Strip feature via the GUI under setup.
97 Configure the leds from the Led Strip tab in the cleanflight GUI.
98 First setup how the led's are laid out so that you can visualize it later as you configure and so the flight controller knows how many led's there are available.
100 There is a step by step guide on how to use the GUI to configure the Led Strip feature using the GUI http://blog.oscarliang.net/setup-rgb-led-cleanflight/ which was published early 2015 by Oscar Liang which may or may not be up-to-date by the time you read this.
103 Enable the `LED_STRIP` feature via the cli:
109 If you enable LED_STRIP feature and the feature is turned off again after a reboot then check your config does not conflict with other features, as above.
111 Configure the LEDs using the `led` command.
113 The `led` command takes either zero or two arguments - an zero-based led number and a sequence which indicates pair of coordinates, direction flags and mode flags and a color.
115 If used with zero arguments it prints out the led configuration which can be copied for future reference.
117 Each led is configured using the following template: `x,y:ddd:mmm:cc`
119 `x` and `y` are grid coordinates of a 0 based 16x16 grid, north west is 0,0, south east is 15,15
120 `ddd` specifies the directions, since an led can face in any direction it can have multiple directions. Directions are:
129 For instance, an LED that faces South-east at a 45 degree downwards angle could be configured as `SED`.
131 Note: It is perfectly possible to configure an LED to have all directions `NESWUD` but probably doesn't make sense.
133 `mmm` specifies the modes that should be applied an LED.
135 Each LED has one base function:
138 * `F` - `F`light mode & Orientation
139 * `A` - `A`rmed state.
140 * `R` - `R`ing thrust state.
142 * `S` - R`S`SSI level.
143 * `L` - Battery `L`evel.
145 And each LED has overlays:
149 * `T` - `T`hrust state.
150 * `B` - `B`link (flash twice) mode.
151 * `O` - Lars`O`n Scanner (Cylon Effect).
152 * `N` - Blink on la`N`ding (throttle < 50%).
154 `cc` specifies the color number (0 based index).
168 To erase an led, and to mark the end of the chain, use `0,0::` as the second argument, like this:
174 It is best to erase all LEDs that you do not have connected.
180 This mode simply uses the LEDs to flash when warnings occur.
182 | Warning | LED Pattern | Notes |
183 |---------|-------------|-------|
184 | Arm-lock enabled | flash between green and off | occurs calibration or when unarmed and the aircraft is tilted too much |
185 | Low Battery | flash red and off | battery monitoring must be enabled. May trigger temporarily under high-throttle due to voltage drop |
186 | Failsafe | flash between light blue and yellow | Failsafe must be enabled |
188 Flash patterns appear in order, so that it's clear which warnings are enabled.
192 This mode shows the GPS state and satellite count.
197 The LEDs will blink as many times as the satellite count, then pause and start again.
201 This mode binds the LED color to RSSI level.
204 | ---------- | ---------|
212 When RSSI is below 50% is reached, LEDs will blink slowly, and they will blink fast when under 20%.
217 This mode binds the LED color to remaining battery capacity.
220 | ---------- | ---------|
228 When Warning or Critial voltage is reached, LEDs will blink slowly or fast.
229 Note: this mode requires a current sensor. If you don't have the actual device you can set up a virtual current sensor (see [Battery](Battery.md)).
233 This mode blinks the current LED, alternatively from black to the current active color.
235 #### Blink on landing
237 This mode blinks the current LED, alternatively from black to the current active color, when throttle is below 50% and the craft is armed.
239 #### Larson Scanner (Cylon Effect)
241 The Larson Scanner replicates the scanning "eye" effect seen on the mechanical Cylons and on Kitt from Knight Rider.
243 This overlay merely varies the brightness of each LED's current color.
245 #### Flight Mode & Orientation
247 This mode shows the flight mode and orientation.
249 When flight modes are active then the LEDs are updated to show different colors depending on the mode, placement on the grid and direction.
251 LEDs are set in a specific order:
252 * LEDs that marked as facing up or down.
253 * LEDs that marked as facing west or east AND are on the west or east side of the grid.
254 * LEDs that marked as facing north or south AND are on the north or south side of the grid.
256 That is, south facing LEDs have priority.
258 The mapping between modes led placement and colors is currently fixed and cannot be changed.
262 This mode flashes LEDs that correspond to roll and pitch stick positions. i.e. they indicate the direction the craft is going to turn.
264 | Mode | Direction | LED Color |
265 |------------|--------|---------------------|
266 |Orientation | North | WHITE |
267 |Orientation | East | DARK VIOLET |
268 |Orientation | South | RED |
269 |Orientation | West | DEEP PINK |
270 |Orientation | Up | BLUE |
271 |Orientation | Down | ORANGE |
273 |Head Free | North | LIME GREEN |
274 |Head Free | East | DARK VIOLET |
275 |Head Free | South | ORANGE |
276 |Head Free | West | DEEP PINK |
277 |Head Free | Up | BLUE |
278 |Head Free | Down | ORANGE |
280 |Horizon | North | BLUE |
281 |Horizon | East | DARK VIOLET |
282 |Horizon | South | YELLOW |
283 |Horizon | West | DEEP PINK |
284 |Horizon | Up | BLUE |
285 |Horizon | Down | ORANGE |
287 |Angle | North | CYAN |
288 |Angle | East | DARK VIOLET |
289 |Angle | South | YELLOW |
290 |Angle | West | DEEP PINK |
292 |Angle | Down | ORANGE |
294 |Mag | North | MINT GREEN |
295 |Mag | East | DARK VIOLET |
296 |Mag | South | ORANGE |
297 |Mag | West | DEEP PINK |
299 |Mag | Down | ORANGE |
301 |Baro | North | LIGHT BLUE |
302 |Baro | East | DARK VIOLET |
303 |Baro | South | RED |
304 |Baro | West | DEEP PINK |
306 |Baro | Down | ORANGE |
310 This mode toggles LEDs between green and blue when disarmed and armed, respectively.
312 Note: Armed State cannot be used with Flight Mode.
316 This mode fades the LED current LED color to the previous/next color in the HSB color space depending on throttle stick position. When the
317 throttle is in the middle position the color is unaffected, thus it can be mixed with orientation colors to indicate orientation and throttle at
318 the same time. Thrust should normally be combined with Color or Mode/Orientation.
320 #### Thrust ring state
322 This mode is allows you to use one or multiple led rings (e.g. NeoPixel ring) for an afterburner effect. The light pattern rotates clockwise as throttle increases.
324 A better effect is acheived when LEDs configured for thrust ring have no other functions.
326 LED direction and X/Y positions are irrelevant for thrust ring LED state. The order of the LEDs that have the state determines how the LED behaves.
328 Each LED of the ring can be a different color. The color can be selected between the 16 colors availables.
330 For example, led 0 is set as a `R`ing thrust state led in color 13 as follow.
336 LED strips and rings can be combined.
340 The mode allows you to set an LED to be permanently on and set to a specific color.
342 x,y position and directions are ignored when using this mode.
344 Other modes will override or combine with the color mode.
346 For example, to set led 0 to always use color 10 you would issue this command.
354 Colors can be configured using the cli `color` command.
356 The `color` command takes either zero or two arguments - an zero-based color number and a sequence which indicates pair of hue, saturation and value (HSV).
358 See http://en.wikipedia.org/wiki/HSL_and_HSV
360 If used with zero arguments it prints out the color configuration which can be copied for future reference.
362 The default color configuration is as follows:
365 | ----- | ----------- |
402 ### Mode Colors Assignement
404 Mode Colors can be configured using the cli `mode_color` command.
406 - No arguments: lists all mode colors
407 - arguments: mode, function, color
409 First 6 groups of ModeIndexes are :
412 |------|-------------|
421 Modes 0 to 5 functions:
432 Mode 6 use these functions:
435 |----------|--------------------|
440 | 4 | blink background |
441 | 5 | gps: no satellites |
445 The ColorIndex is picked from the colors array ("palette").
447 Examples (using the default colors):
449 - set armed color to red: ```mode_color 6 1 2```
450 - set disarmed color to yellow: ```mode_color 6 0 4```
451 - set Headfree mode 'south' to Cyan: ```mode_color 1 2 8```
455 Cut the strip into sections as per diagrams below. When the strips are cut ensure you reconnect each output to each input with cable where the break is made.
456 e.g. connect 5V out to 5V in, GND to GND and Data Out to Data In.
458 Orientation is when viewed with the front of the aircraft facing away from you and viewed from above.
460 ### Example 12 LED config
462 The default configuration is as follows
498 Which translates into the following positions:
513 LEDs 0,3,6 and 9 should be placed underneath the quad, facing downwards.
514 LEDs 1-2, 4-5, 7-8 and 10-11 should be positioned so the face east/north/west/south, respectively.
515 LEDs 12-13 should be placed facing down, in the middle
516 LEDs 14-15 should be placed facing up, in the middle
517 LEDs 16-17 should be placed in a ring and positioned at the rear facing south.
519 This is the default so that if you don't want to place LEDs top and bottom in the middle just connect the first 12 LEDs.
521 ### Example 16 LED config
542 Which translates into the following positions:
556 LEDs 0,3,6 and 9 should be placed underneath the quad, facing downwards.
557 LEDs 1-2, 4-5, 7-8 and 10-11 should be positioned so the face east/north/west/south, respectively.
558 LEDs 12-13 should be placed facing down, in the middle
559 LEDs 14-15 should be placed facing up, in the middle
561 ### Exmple 28 LED config
571 # right front cluster
578 # center front cluster
610 All LEDs should face outwards from the chassis in this configuration.
613 This configuration is specifically designed for the [Alien Spider AQ50D PRO 250mm frame](http://www.goodluckbuy.com/alien-spider-aq50d-pro-250mm-mini-quadcopter-carbon-fiber-micro-multicopter-frame.html).
618 On initial power up the LEDs on the strip will be set to WHITE. This means you can attach a current meter to verify
619 the current draw if your measurement equipment is fast enough. Most 5050 LEDs will draw 0.3 Watts a piece.
620 This also means that you can make sure that each R,G and B LED in each LED module on the strip is also functioning.
622 After a short delay the LEDs will show the unarmed color sequence and or low-battery warning sequence.
624 Also check that the feature `LED_STRIP` was correctly enabled and that it does not conflict with other features, as above.