FastLED 3.10.6
Loading...
Searching...
No Matches
FxLedmapper32x32.ino
Go to the documentation of this file.
1// @filter: (memory is large)
2
17
18#include "FastLED.h"
19#include "Arduino.h"
20
21#include "fl/fx/video.h"
22#include "fl/math/screenmap.h"
24#include "fl/ui/ui.h"
25
26#ifndef LED_PIN
27#define LED_PIN 2
28#endif
29
30#ifndef CHIP_SELECT_PIN
31#define CHIP_SELECT_PIN 5
32#endif
33
34#define LED_TYPE WS2812B
35#define COLOR_ORDER GRB
36
37#define MATRIX_WIDTH 32
38#define MATRIX_HEIGHT 32
39#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
40
41#define VIDEO_FPS 30
42#define VIDEO_FRAME_HISTORY 2
43#define DEFAULT_BRIGHTNESS 96
44
46
50
51fl::UITitle title("Ledmapper 32x32 Video");
53 "Streams data/video1.rgb as a 32x32 mapped raw RGB asset. "
54 "Change VIDEO_FPS if the export was authored at a different frame rate.");
55fl::UISlider brightness("Brightness", DEFAULT_BRIGHTNESS, 0, 255, 1);
56fl::UISlider playbackSpeed("Playback Speed", 1.0f, -2.0f, 2.0f, 0.01f);
57
58bool gError = false;
59
60void setup() {
61 Serial.begin(115200);
62 Serial.println("FxLedmapper32x32 setup");
63
64 if (!filesystem.beginSd(CHIP_SELECT_PIN)) {
65 Serial.println("Failed to initialize file system.");
66 gError = true;
67 return;
68 }
69
70 if (!filesystem.readScreenMap("data/screenmap.json", "strip1", &screenMap)) {
71 Serial.println("Failed to read data/screenmap.json");
72 gError = true;
73 return;
74 }
75
77 .setCorrection(TypicalLEDStrip)
78 .setScreenMap(screenMap);
79 FastLED.setBrightness(DEFAULT_BRIGHTNESS);
80
81 video = filesystem.openVideo("data/video1.rgb", NUM_LEDS, VIDEO_FPS,
83 if (!video) {
84 FL_WARN("Failed to open data/video1.rgb");
85 gError = true;
86 return;
87 }
88
90 FastLED.show();
91 Serial.println("FxLedmapper32x32 ready");
92}
93
94void loop() {
95 if (gError) {
97 FL_WARN("FxLedmapper32x32 halted due to setup error.");
98 }
99 return;
100 }
101
102 FastLED.setBrightness(static_cast<uint8_t>(brightness.value()));
103 video.setTimeScale(playbackSpeed.value());
104 video.draw(fl::millis(), leds);
105 FastLED.show();
106}
CRGB leds[1]
#define COLOR_ORDER
#define NUM_LEDS
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
#define LED_PIN
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::Video video(NUM_LEDS, 2.0f)
fl::UISlider brightness("Brightness", DEFAULT_BRIGHTNESS, 0, 255, 1)
fl::UITitle title("Ledmapper 32x32 Video")
void setup()
fl::UIDescription description("Streams data/video1.rgb as a 32x32 mapped raw RGB asset. " "Change VIDEO_FPS if the export was authored at a different frame rate.")
fl::FileSystem filesystem
#define VIDEO_FRAME_HISTORY
fl::UISlider playbackSpeed("Playback Speed", 1.0f, -2.0f, 2.0f, 0.01f)
bool gError
#define VIDEO_FPS
#define CHIP_SELECT_PIN
#define DEFAULT_BRIGHTNESS
void loop()
#define LED_TYPE
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NO_EXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
fl::ScreenMap screenMap
Definition Corkscrew.h:101
Compatibility forwarder.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Definition lib8tion.h:1009
#define FL_WARN(...)
Definition log.h:440
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
unsigned char uint8_t
Definition stdint.h:208
@ 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
Aggregator header for the fl/ui/ family of per-element UI types.