FastLED 3.9.12
Loading...
Searching...
No Matches
TeensyParallel.ino
1
2// This is an prototype example for the ObjectFLED library for massive pins on
3// teensy40/41.
4
5#if !defined(__IMXRT1062__) // Teensy 4.0/4.1 only.
6void setup() {}
7void loop() {}
8#else
9
10#define FASTLED_USES_OBJECTFLED
11
12#include "FastLED.h"
13#include "fl/warn.h"
14
15using namespace fl;
16
17#define PIN_FIRST 3
18#define PIN_SECOND 1
19#define IS_RGBW false
20
21#define NUM_LEDS1 (22 * 22)
22#define NUM_LEDS2 1
23CRGB leds1[NUM_LEDS1];
24CRGB leds2[NUM_LEDS2];
25
26void wait_for_serial() {
27 uint32_t end_timeout = millis() + 3000;
28 while (!Serial && end_timeout > millis()) {}
29}
30
31void print_startup_info() {
32 Serial.println("Start");
33 Serial.print("*********************************************\n");
34 Serial.print("* TeensyParallel.ino *\n");
35 Serial.print("*********************************************\n");
36 Serial.printf(
37 "CPU speed: %d MHz Temp: %.1f C %.1f F Serial baud: %.1f MHz\n",
38 F_CPU_ACTUAL / 1000000, tempmonGetTemp(),
39 tempmonGetTemp() * 9.0 / 5.0 + 32, 800000 * 1.6 / 1000000.0);
40}
41
42void dump_last_crash() {
43 if (CrashReport) {
44 Serial.println("CrashReport:");
45 Serial.println(CrashReport);
46 }
47}
48
49void setup() {
50 Serial.begin(115200);
51 wait_for_serial();
52 dump_last_crash();
53 CLEDController& c1 = FastLED.addLeds<WS2812, PIN_FIRST, GRB>(leds1, NUM_LEDS1);
54 CLEDController& c2 = FastLED.addLeds<WS2812, PIN_SECOND, GRB>(leds2, NUM_LEDS2);
55 if (IS_RGBW) {
56 c1.setRgbw();
57 c2.setRgbw();
58 }
60}
61
62void fill(CRGB color) {
63 for (int i = 0; i < NUM_LEDS1; i++) {
64 leds1[i] = color;
65 }
66 for (int i = 0; i < NUM_LEDS2; i++) {
67 leds2[i] = color;
68 }
69}
70
71void blink(CRGB color, int times, int delay_ms = 250) {
72 for (int i = 0; i < times; ++i) {
73 fill(color);
74 FastLED.show();
75 delay(delay_ms);
76 fill(CRGB::Black);
77 FastLED.show();
78 delay(delay_ms);
79 }
80}
81
82void loop() {
83 blink(CRGB::Red, 1);
84 blink(CRGB::Green, 2);
85 blink(CRGB::Blue, 3);
86 delay(500);
87}
88
89#endif // __IMXRT1062__
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:719
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
Base definition for an LED controller.
WS2812 controller class.
Definition FastLED.h:190
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:17
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
@ Green
Definition crgb.h:544
@ Blue
Definition crgb.h:498
@ Red
Definition crgb.h:608
@ Black
Definition crgb.h:496