FastLED 3.10.8
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
48 // For ordinary continuous 5-byte RGBWW chipsets:
50 // For TM1812 RGBCCT strips that pack two pixels into each 12-channel IC,
51 // use this instead (issue #995):
52 // auto chipset = fl::makeClockless<fl::TIMING_TM1812_RGBWW_800KHZ>(DATA_PIN);
54 chipset,
56 GRB,
57 opts));
58
59 FastLED.setBrightness(128);
60}
61
62void loop() {
63 // Animate a slow warm <-> cool transition. The colorimetric solver
64 // chooses the warm/cool blend per pixel based on the input chromaticity,
65 // so writing CRGB stays the same as a normal sketch — only the wire
66 // format and color science change.
67 uint32_t ms = millis();
68 uint8_t blend = sin8(ms / 16); // 0..255 triangle-ish
69
70 // Lerp between a warm white tint (255, 200, 130) and a cool one (180, 200, 255).
71 CRGB warm(255, 200, 130);
72 CRGB cool(180, 200, 255);
73 CRGB mixed;
74 mixed.r = lerp8by8(warm.r, cool.r, blend);
75 mixed.g = lerp8by8(warm.g, cool.g, blend);
76 mixed.b = lerp8by8(warm.b, cool.b, blend);
77
78 fill_solid(leds, NUM_LEDS, mixed);
79 FastLED.show();
80 delay(20);
81}
CRGB leds[1]
#define 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:62
ESP32-P4 Parallel IO (PARLIO) LED channel.
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NO_EXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:10
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2) FL_NO_EXCEPT
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) FL_NO_EXCEPT
Linear interpolation between two unsigned 8-bit values, with 8-bit fraction.
Definition lib8tion.h:364
@ WwWcEnd
RGB followed by warm-W, cool-W.
Definition rgbww.h:28
@ kRGBWWColorimetric
Definition rgbww.h:44
constexpr ClocklessChipset makeClockless(int pin) FL_NO_EXCEPT
Build a ClocklessChipset from a compile-time TIMING trait.
Definition config.h:95
5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) configuration types (issue #2558,...
unsigned char uint8_t
Definition stdint.h:208
fl::u32 uint32_t
Definition stdint.h:218
Configuration for a single LED channel.
Definition config.h:167
fl::variant< fl::Empty, Rgbw, Rgbww > mWhiteCfg
White-channel selection (variant): Empty = plain RGB, Rgbw = 4-channel, Rgbww = 5-channel.
Definition options.h:99
Optional channel configuration parameters All fields have sensible defaults and can be overridden as ...
Definition options.h:92
#define Serial
Definition serial.h:309