This sketch is fully compatible with the FastLED web compiler.
This sketch is fully compatible with the FastLED web compiler. To use it do the following:
#ifndef COMPILE_VIDEO_STREAM
#if defined(__AVR__)
#define COMPILE_VIDEO_STREAM 0
#else
#define COMPILE_VIDEO_STREAM 1
#endif
#endif
#if COMPILE_VIDEO_STREAM
#define LED_PIN 2
#define BRIGHTNESS 96
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define MATRIX_WIDTH 22
#define MATRIX_HEIGHT 22
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
const int BYTES_PER_FRAME = 3 *
NUM_LEDS;
const int NUM_FRAMES = 2;
const uint32_t BUFFER_SIZE = BYTES_PER_FRAME * NUM_FRAMES;
ByteStreamMemoryPtr memoryStream;
void write_one_frame(ByteStreamMemoryPtr memoryStream) {
uint32_t total_bytes_written = 0;
bool toggle = (millis() / 500) % 2 == 0;
for (uint32_t i = 0; i <
NUM_LEDS; ++i) {
size_t bytes_written = memoryStream->writeCRGB(&color, 1);
if (bytes_written != 1) {
FASTLED_DBG(
"Failed to write frame data, wrote " << bytes_written <<
" bytes");
break;
}
total_bytes_written += bytes_written;
}
if (total_bytes_written) {
FASTLED_DBG(
"Frame written, total bytes: " << total_bytes_written);
}
}
delay(1000);
video.beginStream(memoryStream);
}
write_one_frame(memoryStream);
}
delay(20);
}
#else
#endif
XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
Manages and renders multiple visual effects (Fx) for LED strips.
fl::unique_ptr< FxEngine > fxEngine
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
shared_ptr< T > make_shared(Args &&... args)
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Representation of an RGB pixel (Red, Green, Blue)