FastLED 3.9.15
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// All strips must have the same length in a single BulkClockless instance
30#define NUM_LEDS 100
31fl::CRGB strip1[NUM_LEDS];
32fl::CRGB strip2[NUM_LEDS];
33fl::CRGB strip3[NUM_LEDS];
34
35void wait_for_serial(uint32_t timeout = 3000) {
36 uint32_t start = millis();
37 while (!Serial && (millis() - start) < timeout) {}
38}
39
40void print_startup_info() {
41 Serial.println("\n*********************************************");
42 Serial.println("* TeensyMassiveParallel - BulkClockless *");
43 Serial.println("*********************************************");
44 FL_DBG("CPU speed: " << (F_CPU_ACTUAL / 1000000) << " MHz Temp: " << tempmonGetTemp()
45 << " C " << (tempmonGetTemp() * 9.0 / 5.0 + 32) << " F");
46 Serial.print("Number of strips: 3\n");
47 Serial.print("LEDs per strip: ");
48 Serial.println(NUM_LEDS);
49 Serial.print("Total LEDs: ");
50 Serial.println(NUM_LEDS * 3);
51}
52
53void setup() {
54 Serial.begin(115200);
55 wait_for_serial(3000);
56
57 // Add LED strips using the new BulkClockless API
58 // All strips in a single instance must have the same length
59 auto& bulk = FastLED.addBulkLeds<WS2812B, OFLED>({
60 {PIN_STRIP1, strip1, NUM_LEDS, fl::ScreenMap()},
61 {PIN_STRIP2, strip2, NUM_LEDS, fl::ScreenMap()},
62 {PIN_STRIP3, strip3, NUM_LEDS, fl::ScreenMap()}
63 });
64
65 // Optional: Set per-strip color correction
66 bulk.get(PIN_STRIP1)->setCorrection(TypicalLEDStrip);
67 bulk.get(PIN_STRIP2)->setCorrection(TypicalSMD5050);
68 bulk.get(PIN_STRIP3)->setCorrection(UncorrectedColor);
69
70 FastLED.setBrightness(8);
71 print_startup_info();
72}
73
74void fill_all(fl::CRGB color) {
75 for (int i = 0; i < NUM_LEDS; i++) {
76 strip1[i] = color;
77 strip2[i] = color;
78 strip3[i] = color;
79 }
80}
81
82void fill_strip(fl::CRGB* strip, fl::CRGB color) {
83 for (int i = 0; i < NUM_LEDS; i++) {
84 strip[i] = color;
85 }
86}
87
88void blink_all(fl::CRGB color, int times, int delay_ms = 250) {
89 for (int i = 0; i < times; ++i) {
90 fill_all(color);
91 FastLED.show();
92 delay(delay_ms);
93 fill_all(fl::CRGB::Black);
94 FastLED.show();
95 delay(delay_ms);
96 }
97}
98
99void chase_pattern() {
100 // Chase different colors across the three strips
101 fill_strip(strip1, fl::CRGB::Red);
102 fill_strip(strip2, fl::CRGB::Black);
103 fill_strip(strip3, fl::CRGB::Black);
104 FastLED.show();
105 delay(300);
106
107 fill_strip(strip1, fl::CRGB::Black);
108 fill_strip(strip2, fl::CRGB::Green);
109 fill_strip(strip3, fl::CRGB::Black);
110 FastLED.show();
111 delay(300);
112
113 fill_strip(strip1, fl::CRGB::Black);
114 fill_strip(strip2, fl::CRGB::Black);
115 fill_strip(strip3, fl::CRGB::Blue);
116 FastLED.show();
117 delay(300);
118}
119
120void loop() {
121 // Blink all strips simultaneously
122 blink_all(fl::CRGB::White, 1, 200);
123
124 // Chase pattern across strips
125 chase_pattern();
126
127 delay(500);
128}
129
130#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.
@ 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:388
Centralized logging categories for FastLED hardware interfaces and subsystems.
fl::u32 uint32_t
Definition s16x16x4.h:219
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Definition delay.h:98
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:558
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:622
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:512
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:646
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:510
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
#define Serial
Definition serial.h:304