FastLED 3.7.8
Loading...
Searching...
No Matches
RGBWEmulated.ino
1
2
3#define FASTLED_RMT_BUILTIN_DRIVER 0
4#define FASTLED_EXPERIMENTAL_ESP32_RGBW_ENABLED 0
5#define FASTLED_EXPERIMENTAL_ESP32_RGBW_MODE kRGBWExactColors
6
7#include <FastLED.h>
8
9// How many leds in your strip?
10#define NUM_LEDS 10
11
12// For led chips like WS2812, which have a data line, ground, and power, you just
13// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
14// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
15// Clock pin only needed for SPI based chipsets when not using hardware SPI
16#define DATA_PIN 3
17
18// Define the array of leds
19CRGB leds[NUM_LEDS];
20
21// Time scaling factors for each component
22#define TIME_FACTOR_HUE 60
23#define TIME_FACTOR_SAT 100
24#define TIME_FACTOR_VAL 100
25
26Rgbw rgbw = Rgbw(
27 kRGBWDefaultColorTemp,
28 kRGBWExactColors, // Mode
29 W3 // W-placement
30);
31
32typedef WS2812<DATA_PIN, RGB> ControllerT; // RGB mode must be RGB, no re-ordering allowed.
33static RGBWEmulatedController<ControllerT, GRB> rgbwEmu(rgbw); // ordering goes here.
34
35void setup() {
36 Serial.begin(115200);
37 //FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS).setRgbw(RgbwDefault());
38 FastLED.addLeds(&rgbwEmu, leds, NUM_LEDS);
39 FastLED.setBrightness(128); // Set global brightness to 50%
40 delay(2000); // If something ever goes wrong this delay will allow upload.
41}
42
43void fillAndShow(CRGB color) {
44 for (int i = 0; i < NUM_LEDS; ++i) {
45 leds[i] = color;
46 }
47 FastLED.show();
48}
49
50// Cycle r,g,b,w. Red will blink once, green twice, ... white 4 times.
51void loop() {
52 static size_t frame_count = 0;
53 int frame_cycle = frame_count % 4;
54 frame_count++;
55
56 CRGB pixel;
57 switch (frame_cycle) {
58 case 0:
59 pixel = CRGB::Red;
60 break;
61 case 1:
62 pixel = CRGB::Green;
63 break;
64 case 2:
65 pixel = CRGB::Blue;
66 break;
67 case 3:
68 pixel = CRGB::White;
69 break;
70 }
71
72 for (int i = -1; i < frame_cycle; ++i) {
73 fillAndShow(pixel);
74 delay(200);
75 fillAndShow(CRGB::Black);
76 delay(200);
77 }
78 delay(1000);
79}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:21
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:715
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:59
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:47
WS2812 controller class.
Definition FastLED.h:186
@ White
Definition crgb.h:604
@ Green
Definition crgb.h:516
@ Blue
Definition crgb.h:470
@ Red
Definition crgb.h:580
@ Black
Definition crgb.h:468
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:25
Definition rgbw.h:25