7#ifndef COMPILE_VIDEO_STREAM
10#define COMPILE_VIDEO_STREAM 0
12#define COMPILE_VIDEO_STREAM 1
16#if COMPILE_VIDEO_STREAM
20#include "fl/bytestreammemory.h"
21#include "fx/fx_engine.h"
30#define LED_TYPE WS2811
31#define COLOR_ORDER GRB
33#define MATRIX_WIDTH 22
34#define MATRIX_HEIGHT 22
35#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
39const int BYTES_PER_FRAME = 3 * NUM_LEDS;
40const int NUM_FRAMES = 2;
41const uint32_t BUFFER_SIZE = BYTES_PER_FRAME * NUM_FRAMES;
43ByteStreamMemoryPtr memoryStream;
46XYMap xymap(MATRIX_WIDTH, MATRIX_HEIGHT);
47Video video(NUM_LEDS, 2.0f);
49void write_one_frame(ByteStreamMemoryPtr memoryStream) {
51 uint32_t total_bytes_written = 0;
52 bool toggle = (millis() / 500) % 2 == 0;
53 FASTLED_DBG(
"Writing frame data, toggle = " << toggle);
54 for (uint32_t i = 0; i < NUM_LEDS; ++i) {
56 size_t bytes_written = memoryStream->writeCRGB(&color, 1);
57 if (bytes_written != 1) {
58 FASTLED_DBG(
"Failed to write frame data, wrote " << bytes_written <<
" bytes");
61 total_bytes_written += bytes_written;
73 memoryStream = ByteStreamMemoryPtr::New(BUFFER_SIZE*
sizeof(
CRGB));
75 video.beginStream(memoryStream);
77 fxEngine.addFx(video);
82 write_one_frame(memoryStream);
86 fxEngine.draw(millis(), leds);
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Manages and renders multiple visual effects (Fx) for LED strips.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Implements a simple red square effect for 2D LED grids.
Representation of an RGB pixel (Red, Green, Blue)