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
10
namespace
fl
{
11
12
void
FxLayer::setFx
(
fl::shared_ptr<Fx>
newFx) {
13
if
(newFx !=
fx
) {
14
release
();
15
fx
= newFx;
16
}
17
}
18
19
void
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
35
void
FxLayer::pause
(fl::u32 now) {
36
if
(
fx
&&
running
) {
37
fx
->pause(now);
38
running
=
false
;
39
}
40
}
41
42
void
FxLayer::release
() {
43
pause
(0);
44
fx
.reset();
45
}
46
47
fl::shared_ptr<Fx>
FxLayer::getFx
() {
48
return
fx
;
49
}
50
51
CRGB
*
FxLayer::getSurface
() {
52
return
frame
->rgb();
53
}
54
55
}
fl::Fx::DrawContext
_DrawContext DrawContext
Definition
fx.h:21
fl::FxLayer::draw
void draw(fl::u32 now)
Definition
fx_layer.cpp:19
fl::FxLayer::getFx
fl::shared_ptr< Fx > getFx()
Definition
fx_layer.cpp:47
fl::FxLayer::pause
void pause(fl::u32 now)
Definition
fx_layer.cpp:35
fl::FxLayer::getSurface
CRGB * getSurface()
Definition
fx_layer.cpp:51
fl::FxLayer::setFx
void setFx(fl::shared_ptr< Fx > newFx)
Definition
fx_layer.cpp:12
fl::FxLayer::fx
fl::shared_ptr< Fx > fx
Definition
fx_layer.h:33
fl::FxLayer::frame
fl::shared_ptr< Frame > frame
Definition
fx_layer.h:32
fl::FxLayer::release
void release()
Definition
fx_layer.cpp:42
fl::FxLayer::running
bool running
Definition
fx_layer.h:34
fl::shared_ptr
Definition
shared_ptr.h:106
fx_layer.h
memfill.h
fl::memfill
void * memfill(void *ptr, int value, fl::size num)
Definition
memfill.h:11
fl::make_shared
shared_ptr< T > make_shared(Args &&... args)
Definition
shared_ptr.h:348
fl
IMPORTANT!
Definition
crgb.h:20
string.h
CRGB
Representation of an RGB pixel (Red, Green, Blue)
Definition
crgb.h:86
fx
detail
fx_layer.cpp
Generated on Fri Aug 22 2025 20:59:33 for FastLED by
1.13.2