FastLED 3.9.15
Loading...
Searching...
No Matches
Esp32S3I2SDemo.h
Go to the documentation of this file.
1
2#ifdef ESP32
3
27// ArduinoIDE
28// Should already be enabled.
29//
30// PLATFORMIO BUILD FLAGS:
31// Define your platformio.ini like so:
32//
33// PlatformIO
34// [env:esp32s3]
35// platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip
36// framework = arduino
37// board = seeed_xiao_esp32s3
38
39
40#define FASTLED_USES_ESP32S3_I2S // Must define this before including FastLED.h
41
42
43#include "FastLED.h"
44#include "fl/assert.h"
45
46
47#define NUMSTRIPS 16
48#define NUM_LEDS_PER_STRIP 256
49#define NUM_LEDS (NUM_LEDS_PER_STRIP * NUMSTRIPS)
50
51// Note that you can use less strips than this.
52
53#define EXAMPLE_PIN_NUM_DATA0 19 // B0
54#define EXAMPLE_PIN_NUM_DATA1 45 // B1
55#define EXAMPLE_PIN_NUM_DATA2 21 // B2
56#define EXAMPLE_PIN_NUM_DATA3 6 // B3
57#define EXAMPLE_PIN_NUM_DATA4 7 // B4
58#define EXAMPLE_PIN_NUM_DATA5 8 // G0
59#define EXAMPLE_PIN_NUM_DATA6 9 // G1
60#define EXAMPLE_PIN_NUM_DATA7 10 // G2
61#define EXAMPLE_PIN_NUM_DATA8 11 // G3
62#define EXAMPLE_PIN_NUM_DATA9 12 // G4
63#define EXAMPLE_PIN_NUM_DATA10 13 // G5
64#define EXAMPLE_PIN_NUM_DATA11 14 // R0
65#define EXAMPLE_PIN_NUM_DATA12 15 // R1
66#define EXAMPLE_PIN_NUM_DATA13 16 // R2
67#define EXAMPLE_PIN_NUM_DATA14 17 // R3
68#define EXAMPLE_PIN_NUM_DATA15 18 // R4
69
70
71// Users say you can use a lot less strips. Experiment around and find out!
72// Please comment at reddit.com/r/fastled and let us know if you have problems.
73// Or send us a picture of your Triumps!
74int PINS[] = {
75 EXAMPLE_PIN_NUM_DATA0,
76 EXAMPLE_PIN_NUM_DATA1,
77 EXAMPLE_PIN_NUM_DATA2,
78 EXAMPLE_PIN_NUM_DATA3,
79 EXAMPLE_PIN_NUM_DATA4,
80 EXAMPLE_PIN_NUM_DATA5,
81 EXAMPLE_PIN_NUM_DATA6,
82 EXAMPLE_PIN_NUM_DATA7,
83 EXAMPLE_PIN_NUM_DATA8,
84 EXAMPLE_PIN_NUM_DATA9,
85 EXAMPLE_PIN_NUM_DATA10,
86 EXAMPLE_PIN_NUM_DATA11,
87 EXAMPLE_PIN_NUM_DATA12,
88 EXAMPLE_PIN_NUM_DATA13,
89 EXAMPLE_PIN_NUM_DATA14,
90 EXAMPLE_PIN_NUM_DATA15
91};
92
94
95void setup_i2s() {
96 // Note, in this case we are using contingious memory for the leds. But this is not required.
97 // Each strip can be a different size and the FastLED api will upscale the smaller strips to the largest strip.
98 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA0, GRB>(
100 );
101 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA1, GRB>(
103 );
104 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA2, GRB>(
106 );
107 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA3, GRB>(
109 );
110 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA4, GRB>(
112 );
113 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA5, GRB>(
115 );
116 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA6, GRB>(
118 );
119 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA7, GRB>(
121 );
122 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA8, GRB>(
124 );
125 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA9, GRB>(
127 );
128 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA10, GRB>(
130 );
131 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA11, GRB>(
133 );
134 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA12, GRB>(
136 );
137 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA13, GRB>(
139 );
140 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA14, GRB>(
142 );
143 FastLED.addLeds<WS2812, EXAMPLE_PIN_NUM_DATA15, GRB>(
145 );
146}
147
148
149
150void setup() {
151 // put your setup code here, to run once:
152 Serial.begin(57600);
153
154 // This is used so that you can see if PSRAM is enabled. If not, we will crash in setup() or in loop().
155 log_d("Total heap: %d", ESP.getHeapSize());
156 log_d("Free heap: %d", ESP.getFreeHeap());
157 log_d("Total PSRAM: %d", ESP.getPsramSize()); // If this prints out 0, then PSRAM is not enabled.
158 log_d("Free PSRAM: %d", ESP.getFreePsram());
159
160 log_d("waiting 6 seconds before startup");
161 delay(6000); // The long reset time here is to make it easier to flash the device during the development process.
162
163 setup_i2s();
164 FastLED.setBrightness(32);
165
166}
167
168void fill_rainbow(CRGB* all_leds) {
169 static int s_offset = 0;
170 for (int j = 0; j < NUMSTRIPS; j++) {
171 for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
172 int idx = (i + s_offset) % NUM_LEDS_PER_STRIP + NUM_LEDS_PER_STRIP * j;
173 all_leds[idx] = CHSV(i, 255, 255);
174 }
175 }
176 s_offset++;
177}
178
179void loop() {
181 FastLED.show();
182
183}
184
185#else // ESP32
186
187// Non-ESP32 platform - provide minimal example for compilation testing
188#include "FastLED.h"
189
190#define NUM_LEDS 16
191#define DATA_PIN 3
192
194
195void setup() {
197}
198
199void loop() {
200 fill_rainbow(leds, NUM_LEDS, 0, 7);
201 FastLED.show();
202 delay(50);
203}
204
205#endif // ESP32
CRGB leds[NUM_LEDS]
#define NUM_LEDS
#define DATA_PIN
#define NUM_LEDS_PER_STRIP
Definition ColorBoost.h:51
void setup()
void loop()
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
central include file for FastLED, defines the CFastLED class/object
LED controller for WS2812 LEDs with GRB color order.
Definition FastLED.h:158
WS2812 controller class.
Definition FastLED.h:218
void fill_rainbow(struct CRGB *targetArray, int numToFill, fl::u8 initialhue, fl::u8 deltahue=5)
Fill a range of LEDs with a rainbow of colors.
Definition fill.cpp:29
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition hsv.h:15