FastLED 3.10.6
Loading...
Searching...
No Matches
TeensyMassiveParallel.h
Go to the documentation of this file.
1
15
16#if !defined(__IMXRT1062__) // Teensy 4.0/4.1 only.
17#include "platforms/sketch_fake.hpp"
18#else
19
20#include "FastLED.h"
21#include "fl/log/log.h"
22
23
24// Hardware configuration
25#define PIN_STRIP1 3
26#define PIN_STRIP2 1
27#define PIN_STRIP3 4
28
29#define NUM_LEDS 100
30fl::CRGB strip1[NUM_LEDS];
31fl::CRGB strip2[NUM_LEDS];
32fl::CRGB strip3[NUM_LEDS];
33
34void wait_for_serial(uint32_t timeout = 3000) {
35 uint32_t start = millis();
36 while (!Serial && (millis() - start) < timeout) {}
37}
38
39void print_startup_info() {
40 Serial.println("\n*********************************************");
41 Serial.println("* TeensyMassiveParallel - ObjectFLED *");
42 Serial.println("*********************************************");
43 FL_DBG("CPU speed: " << (F_CPU_ACTUAL / 1000000) << " MHz Temp: " << tempmonGetTemp()
44 << " C " << (tempmonGetTemp() * 9.0 / 5.0 + 32) << " F");
45 Serial.print("Number of strips: 3\n");
46 Serial.print("LEDs per strip: ");
47 Serial.println(NUM_LEDS);
48 Serial.print("Total LEDs: ");
49 Serial.println(NUM_LEDS * 3);
50}
51
52void setup() {
53 Serial.begin(115200);
54 wait_for_serial(3000);
55
56 // Route every clockless strip through ObjectFLED (Bus::FLEX_IO slot 0
57 // on Teensy 4.x), which drives all strips in parallel via DMA.
58 FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>();
59
60 // Per-strip color correction is set on each controller.
61 FastLED.addLeds<WS2812B, PIN_STRIP1, GRB>(strip1, NUM_LEDS).setCorrection(TypicalLEDStrip);
62 FastLED.addLeds<WS2812B, PIN_STRIP2, GRB>(strip2, NUM_LEDS).setCorrection(TypicalSMD5050);
63 FastLED.addLeds<WS2812B, PIN_STRIP3, GRB>(strip3, NUM_LEDS).setCorrection(UncorrectedColor);
64
65 FastLED.setBrightness(8);
66 print_startup_info();
67}
68
69void fill_all(fl::CRGB color) {
70 for (int i = 0; i < NUM_LEDS; i++) {
71 strip1[i] = color;
72 strip2[i] = color;
73 strip3[i] = color;
74 }
75}
76
77void fill_strip(fl::CRGB* strip, fl::CRGB color) {
78 for (int i = 0; i < NUM_LEDS; i++) {
79 strip[i] = color;
80 }
81}
82
83void blink_all(fl::CRGB color, int times, int delay_ms = 250) {
84 for (int i = 0; i < times; ++i) {
85 fill_all(color);
86 FastLED.show();
87 delay(delay_ms);
88 fill_all(fl::CRGB::Black);
89 FastLED.show();
90 delay(delay_ms);
91 }
92}
93
94void chase_pattern() {
95 // Chase different colors across the three strips
96 fill_strip(strip1, fl::CRGB::Red);
97 fill_strip(strip2, fl::CRGB::Black);
98 fill_strip(strip3, fl::CRGB::Black);
99 FastLED.show();
100 delay(300);
101
102 fill_strip(strip1, fl::CRGB::Black);
103 fill_strip(strip2, fl::CRGB::Green);
104 fill_strip(strip3, fl::CRGB::Black);
105 FastLED.show();
106 delay(300);
107
108 fill_strip(strip1, fl::CRGB::Black);
109 fill_strip(strip2, fl::CRGB::Black);
110 fill_strip(strip3, fl::CRGB::Blue);
111 FastLED.show();
112 delay(300);
113}
114
115void loop() {
116 // Blink all strips simultaneously
117 blink_all(fl::CRGB::White, 1, 200);
118
119 // Chase pattern across strips
120 chase_pattern();
121
122 delay(500);
123}
124
125#endif // __IMXRT1062__
void setup()
void loop()
#define NUM_LEDS
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
constexpr EOrder GRB
Definition eorder.h:19
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
@ TypicalSMD5050
Typical values for SMD5050 LEDs.
Definition color.h:13
@ UncorrectedColor
Uncorrected color (0xFFFFFF)
Definition color.h:24
#define FL_DBG
Definition log.h:564
Centralized logging categories for FastLED hardware interfaces and subsystems.
void delay(u32 ms, bool run_async=true) FL_NO_EXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
@ FLEX_IO
Definition bus.h:36
fl::u32 uint32_t
Definition stdint.h:218
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:565
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:629
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:519
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:653
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:517
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
#define Serial
Definition serial.h:304