FastLED 3.9.15
Loading...
Searching...
No Matches
fx_layer.cpp
Go to the documentation of this file.
1
2
3#include <string.h>
4
5#include "fx_layer.h"
6
7
8#include "fl/memfill.h"
9
10namespace fl {
11
13 if (newFx != fx) {
14 release();
15 fx = newFx;
16 }
17}
18
19void FxLayer::draw(fl::u32 now) {
20 // assert(fx);
21 if (!frame) {
22 frame = fl::make_shared<Frame>(fx->getNumLeds());
23 }
24
25 if (!running) {
26 // Clear the frame
27 fl::memfill((uint8_t*)frame->rgb(), 0, frame->size() * sizeof(CRGB));
28 fx->resume(now);
29 running = true;
30 }
31 Fx::DrawContext context = {now, frame->rgb()};
32 fx->draw(context);
33}
34
35void FxLayer::pause(fl::u32 now) {
36 if (fx && running) {
37 fx->pause(now);
38 running = false;
39 }
40}
41
43 pause(0);
44 fx.reset();
45}
46
50
52 return frame->rgb();
53}
54
55}
_DrawContext DrawContext
Definition fx.h:21
void draw(fl::u32 now)
Definition fx_layer.cpp:19
fl::shared_ptr< Fx > getFx()
Definition fx_layer.cpp:47
void pause(fl::u32 now)
Definition fx_layer.cpp:35
CRGB * getSurface()
Definition fx_layer.cpp:51
void setFx(fl::shared_ptr< Fx > newFx)
Definition fx_layer.cpp:12
fl::shared_ptr< Fx > fx
Definition fx_layer.h:33
fl::shared_ptr< Frame > frame
Definition fx_layer.h:32
void release()
Definition fx_layer.cpp:42
bool running
Definition fx_layer.h:34
void * memfill(void *ptr, int value, fl::size num)
Definition memfill.h:11
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348
IMPORTANT!
Definition crgb.h:20
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86