FastLED 3.9.15
Loading...
Searching...
No Matches

◆ setup()

void setup ( )

Definition at line 182 of file Chromancer.ino.

182 {
183 Serial.begin(115200);
184
185 Serial.println("*** LET'S GOOOOO ***");
186
187 Serial.println("JSON SCREENMAP");
188 Serial.println(JSON_SCREEN_MAP);
189
192
193 fl::printf("Parsed %d segment maps\n", int(segmentMaps.size()));
194 for (auto kv : segmentMaps) {
195 Serial.print(kv.first.c_str());
196 Serial.print(" ");
197 Serial.println(kv.second.getLength());
198 }
199
200
201 // fl::ScreenMap screenmaps[4];
202 fl::ScreenMap red, black, green, blue;
203 bool ok = true;
204
205 auto red_it = segmentMaps.find("red_segment");
206 ok = (red_it != segmentMaps.end()) && ok;
207 if (red_it != segmentMaps.end()) red = red_it->second;
208
209 auto black_it = segmentMaps.find("back_segment");
210 ok = (black_it != segmentMaps.end()) && ok;
211 if (black_it != segmentMaps.end()) black = black_it->second;
212
213 auto green_it = segmentMaps.find("green_segment");
214 ok = (green_it != segmentMaps.end()) && ok;
215 if (green_it != segmentMaps.end()) green = green_it->second;
216
217 auto blue_it = segmentMaps.find("blue_segment");
218 ok = (blue_it != segmentMaps.end()) && ok;
219 if (blue_it != segmentMaps.end()) blue = blue_it->second;
220 if (!ok) {
221 Serial.println("Failed to get all segment maps");
222 return;
223 }
224
225
226 CRGB* red_leds = leds[RedStrip];
227 CRGB* black_leds = leds[BlackStrip];
228 CRGB* green_leds = leds[GreenStrip];
229 CRGB* blue_leds = leds[BlueStrip];
230
231 FastLED.addLeds<WS2812, 2>(black_leds, lengths[BlackStrip]).setScreenMap(black);
232 FastLED.addLeds<WS2812, 3>(green_leds, lengths[GreenStrip]).setScreenMap(green);
233 FastLED.addLeds<WS2812, 1>(red_leds, lengths[RedStrip]).setScreenMap(red);
234 FastLED.addLeds<WS2812, 4>(blue_leds, lengths[BlueStrip]).setScreenMap(blue);
235
236 FastLED.show();
237}
fl::CRGB leds[NUM_LEDS]
@ GreenStrip
@ RedStrip
@ BlackStrip
@ BlueStrip
constexpr int lengths[]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
static bool ParseJson(const char *jsonStrScreenMap, fl::flat_map< string, ScreenMap > *segmentMaps, string *err=nullptr) FL_NOEXCEPT
size_type size() const FL_NOEXCEPT
Definition flat_map.h:96
fl::CRGB CRGB
Definition crgb.h:25
void printf(const char *format, const Args &... args) FL_NOEXCEPT
Printf-like formatting function that prints directly to the platform output.
Definition stdio.h:635
const char JSON_SCREEN_MAP[]
#define Serial
Definition serial.h:304

References BlackStrip, BlueStrip, fl::flat_map< Key, Value, Less >::end(), FastLED, fl::flat_map< Key, Value, Less >::find(), GreenStrip, JSON_SCREEN_MAP, leds, lengths, fl::ScreenMap::ParseJson(), fl::printf(), RedStrip, Serial, and fl::flat_map< Key, Value, Less >::size().

+ Here is the call graph for this function: