FastLED 3.9.15
Loading...
Searching...
No Matches
RGBWW.ino
Go to the documentation of this file.
1// FL_AGENT_ALLOW_NEW_EXAMPLE — first example sketch for the 5-channel
2// RGB + warm-W + cool-W path landed in PR #2560 (issue #2558).
3//
4// @filter: (memory is large)
5//
6// Pulls in the full Channels API plus the colorimetric RGB→RGBWW solvers;
7// total code size is ~54 KB on AVR (overflows attiny85's 8 KB and uno's
8// 32 KB flash). Restrict CI compile matrix to boards with >= "large"
9// memory tier (Apollo3 / nRF52 / SAMD21+ / SAMD51 / STM32F4+ /
10// teensy 3.5+ / teensy 4.x / ESP32 / native / web / rp2040).
11//
12// Add the following to platformio.ini for full colorimetric output:
13// build_flags =
14// -DFASTLED_RGBW_COLORIMETRIC=1 ; provides the underlying math
15//
16// Without that flag the channel falls back to 5 zero bytes per pixel + a
17// one-time startup warning. The example still compiles either way; the
18// 5-channel pipeline itself is always available — gc-sections drops it for
19// sketches that don't configure an Rgbww channel.
20
21#include <FastLED.h>
22#include "fl/channels/channel.h"
23#include "fl/channels/config.h"
24#include "fl/gfx/rgbww.h"
25
26#define NUM_LEDS 60
27#define DATA_PIN 3
28
30
31void setup() {
32 Serial.begin(115200);
33 delay(2000); // Upload safety delay.
34
35 // ----- Channels API setup ------------------------------------------------
36 // ChannelOptions.mWhiteCfg is a fl::variant<fl::Empty, Rgbw, Rgbww>.
37 // Assigning Rgbww selects the 5-channel alternative; everything downstream
38 // (encoder, dispatch, driver) routes through the RGBWW pipeline.
41 opts.mWhiteCfg = fl::Rgbww(
42 /* warm_cct */ 2700,
43 /* cool_cct */ 6500,
45 /* placement */ fl::EOrderWW::WwWcEnd // RGB, then warm-W, cool-W
46 );
47
50 DATA_PIN, timing,
52 GRB,
53 opts));
54
55 FastLED.setBrightness(128);
56}
57
58void loop() {
59 // Animate a slow warm <-> cool transition. The colorimetric solver
60 // chooses the warm/cool blend per pixel based on the input chromaticity,
61 // so writing CRGB stays the same as a normal sketch — only the wire
62 // format and color science change.
63 uint32_t ms = millis();
64 uint8_t blend = sin8(ms / 16); // 0..255 triangle-ish
65
66 // Lerp between a warm white tint (255, 200, 130) and a cool one (180, 200, 255).
67 CRGB warm(255, 200, 130);
68 CRGB cool(180, 200, 255);
69 CRGB mixed;
70 mixed.r = lerp8by8(warm.r, cool.r, blend);
71 mixed.g = lerp8by8(warm.g, cool.g, blend);
72 mixed.b = lerp8by8(warm.b, cool.b, blend);
73
74 fill_solid(leds, NUM_LEDS, mixed);
75 FastLED.show();
76 delay(20);
77}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define DATA_PIN
Definition ClientReal.h:82
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
void setup()
Definition RGBWW.ino:31
void loop()
Definition RGBWW.ino:58
ESP32-P4 Parallel IO (PARLIO) LED channel.
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
constexpr EOrder GRB
Definition eorder.h:19
@ TypicalSMD5050
Typical values for SMD5050 LEDs.
Definition color.h:13
fl::CRGB CRGB
Definition crgb.h:25
LIB8STATIC fl::u8 lerp8by8(fl::u8 a, fl::u8 b, fract8 frac)
Linear interpolation between two unsigned 8-bit values, with 8-bit fraction.
Definition lib8tion.h:363
@ WwWcEnd
RGB followed by warm-W, cool-W.
Definition rgbww.h:28
constexpr ChipsetTimingConfig makeTimingConfig() FL_NOEXCEPT
Convert compile-time CHIPSET type to runtime timing config.
@ kRGBWWColorimetric
Definition rgbww.h:44
5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) configuration types (issue #2558,...
Configuration for a single LED channel.
Definition config.h:163
fl::variant< fl::Empty, Rgbw, Rgbww > mWhiteCfg
White-channel selection (variant): Empty = plain RGB, Rgbw = 4-channel, Rgbww = 5-channel.
Definition options.h:49
Optional channel configuration parameters All fields have sensible defaults and can be overridden as ...
Definition options.h:43
Per-strip RGBWW configuration.
Definition rgbww.h:60
#define Serial
Definition serial.h:304