FastLED 3.9.15
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
10namespace fl {
11
13 if (newFx != fx) {
14 release();
15 fx = newFx;
16 }
17}
18
19void FxLayer::draw(fl::u32 now, float speed, const AudioBatch *audio) {
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::memset((u8*)frame->rgb().data(), 0, frame->size() * sizeof(CRGB));
28 fx->resume(now);
29 mLastNow = now;
30 running = true;
31 }
32 u16 frame_time = static_cast<u16>(now - mLastNow);
33 mLastNow = now;
34 Fx::DrawContext context(now, frame->rgb(), frame_time, speed, audio);
35 fx->draw(context);
36}
37
38void FxLayer::pause(fl::u32 now) {
39 if (fx && running) {
40 fx->pause(now);
41 running = false;
42 }
43}
44
46 pause(0);
47 fx.reset();
48}
49
53
55 return frame->rgb();
56}
57
58}
uint16_t speed
Definition Noise.ino:66
::fl::DrawContext DrawContext
Definition fx.h:21
fl::shared_ptr< Fx > getFx()
void pause(fl::u32 now)
void setFx(fl::shared_ptr< Fx > newFx)
fl::shared_ptr< Fx > fx
Definition fx_layer.h:30
fl::shared_ptr< Frame > frame
Definition fx_layer.h:29
void draw(fl::u32 now, float speed=1.0f, const AudioBatch *audio=nullptr)
fl::u32 mLastNow
Definition fx_layer.h:31
fl::span< CRGB > getSurface()
bool running
Definition fx_layer.h:32
unsigned char u8
Definition stdint.h:131
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
Base definition for an LED controller.
Definition crgb.hpp:179
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38