FastLED 3.10.8
Loading...
Searching...
No Matches
fx_layer.cpp.hpp
Go to the documentation of this file.
1
2
4
5#include "crgb.h"
6#include "fl/fx/frame.h"
7#include "fl/fx/fx.h"
8#include "fl/stl/cstring.h"
9#include "fl/stl/noexcept.h"
10
11namespace fl {
12
14 if (newFx != fx) {
15 release();
16 fx = newFx;
17 }
18}
19
20void FxLayer::draw(fl::u32 now, float speed, const AudioBatch *audio) FL_NO_EXCEPT {
21 // assert(fx);
22 if (!frame) {
23 frame = fl::make_shared<Frame>(fx->getNumLeds());
24 }
25
26 if (!running) {
27 // Clear the frame
28 fl::memset((u8*)frame->rgb().data(), 0, frame->size() * sizeof(CRGB));
29 fx->resume(now);
30 mLastNow = now;
31 running = true;
32 }
33 u16 frame_time = static_cast<u16>(now - mLastNow);
34 mLastNow = now;
35 Fx::DrawContext context(now, frame->rgb(), frame_time, speed, audio);
36 fx->draw(context);
37}
38
39void FxLayer::pause(fl::u32 now) FL_NO_EXCEPT {
40 if (fx && running) {
41 fx->pause(now);
42 running = false;
43 }
44}
45
47 pause(0);
48 fx.reset();
49}
50
54
58
59}
uint16_t speed
Definition Noise.ino:72
::fl::DrawContext DrawContext
Definition fx.h:21
fl::shared_ptr< Fx > getFx() FL_NO_EXCEPT
void draw(fl::u32 now, float speed=1.0f, const AudioBatch *audio=nullptr) FL_NO_EXCEPT
fl::span< CRGB > getSurface() FL_NO_EXCEPT
void setFx(fl::shared_ptr< Fx > newFx) FL_NO_EXCEPT
void pause(fl::u32 now) FL_NO_EXCEPT
fl::shared_ptr< Fx > fx
Definition fx_layer.h:31
fl::shared_ptr< Frame > frame
Definition fx_layer.h:30
fl::u32 mLastNow
Definition fx_layer.h:32
void release() FL_NO_EXCEPT
bool running
Definition fx_layer.h:33
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
FASTLED_FORCE_INLINE void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
Definition cstring.h:148
Base definition for an LED controller.
Definition crgb.hpp:179
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38