6#include "fx/detail/data_stream.h"
8#include "fx/video/frame_interpolator.h"
11FASTLED_NAMESPACE_BEGIN
29 void begin(uint32_t now, FxGridRef fx,uint16_t nFrameHistory,
float fps = -1) {
34 mDelegate->getXYMap().setRectangularGrid();
35 mFps = fps < 0 ? 30 : fps;
36 mDelegate->hasFixedFrameRate(&mFps);
37 mFrameInterpolator = FrameInterpolatorRef::New(nFrameHistory, mFps);
38 mFrameInterpolator->reset(now);
41 void lazyInit()
override {
44 mDelegate->lazyInit();
48 void draw(DrawContext context)
override {
53 uint32_t precise_timestamp;
54 if (mFrameInterpolator->needsFrame(context.now, &precise_timestamp)) {
56 bool wasFullBeforePop = mFrameInterpolator->full();
57 if (wasFullBeforePop) {
58 if (!mFrameInterpolator->popOldest(&frame)) {
61 if (mFrameInterpolator->full()) {
65 frame = FrameRef::New(mDelegate->getNumLeds(), mDelegate->hasAlphaChannel());
72 DrawContext delegateContext = context;
73 delegateContext.leds = frame->rgb();
74 delegateContext.alpha_channel = frame->alpha();
75 delegateContext.now = precise_timestamp;
76 mDelegate->draw(delegateContext);
78 mFrameInterpolator->pushNewest(frame, precise_timestamp);
79 mFrameInterpolator->incrementFrameCounter();
82 mFrameInterpolator->draw(context.now, context.leds, context.alpha_channel);
85 const char *fxName(
int)
const override {
return "video_fx"; }
89 bool mInitialized =
false;
90 FrameInterpolatorRef mFrameInterpolator;
central include file for FastLED, defines the CFastLED class/object
void draw(DrawContext context) override