FastLED 3.10.8
Loading...
Searching...
No Matches
fx.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/stdint.h"
4
5#include "crgb.h" // IWYU pragma: keep
7#include "fl/fx/detail/transition.h" // IWYU pragma: keep
8#include "fl/stl/shared_ptr.h" // For FASTLED_SHARED_PTR macros
9#include "fl/stl/string.h" // IWYU pragma: keep
11#include "fl/stl/noexcept.h"
12
13namespace fl {
14
16
17// Abstract base class for effects on a strip/grid of LEDs.
18class Fx {
19 public:
20 // Alias so Fx::DrawContext keeps working in existing code.
22
23 Fx(u16 numLeds) FL_NO_EXCEPT : mNumLeds(numLeds) {}
24
28 virtual void
29 draw(DrawContext context) FL_NO_EXCEPT = 0; // This is the only function that needs to be
30 // implemented everything else is optional.
31
32 // If true then this fx has a fixed frame rate and the fps parameter will be
33 // set to the frame rate.
34 virtual bool hasFixedFrameRate(float *fps) const FL_NO_EXCEPT {
35 FASTLED_UNUSED(fps);
36 return false;
37 }
38
39 // Get the name of the current fx.
40 virtual fl::string fxName() const FL_NO_EXCEPT = 0;
41
42 // Called when the fx is paused, usually when a transition has finished.
43 virtual void pause(fl::u32 now) FL_NO_EXCEPT { FASTLED_UNUSED(now); }
44 virtual void resume(fl::u32 now) FL_NO_EXCEPT {
45 FASTLED_UNUSED(now);
46 } // Called when the fx is resumed after a pause,
47 // usually when a transition has started.
48
49 u16 getNumLeds() const FL_NO_EXCEPT { return mNumLeds; }
50
51 protected:
52 virtual ~Fx() FL_NO_EXCEPT {} // Protected destructor
54};
55
56} // namespace fl
virtual ~Fx() FL_NO_EXCEPT
Definition fx.h:52
virtual fl::string fxName() const FL_NO_EXCEPT=0
u16 mNumLeds
Definition fx.h:53
virtual bool hasFixedFrameRate(float *fps) const FL_NO_EXCEPT
Definition fx.h:34
virtual void pause(fl::u32 now) FL_NO_EXCEPT
Definition fx.h:43
Fx(u16 numLeds) FL_NO_EXCEPT
Definition fx.h:23
virtual void resume(fl::u32 now) FL_NO_EXCEPT
Definition fx.h:44
::fl::DrawContext DrawContext
Definition fx.h:21
virtual void draw(DrawContext context) FL_NO_EXCEPT=0
u16 getNumLeds() const FL_NO_EXCEPT
Definition fx.h:49
Definition fx.h:18
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
#define FASTLED_UNUSED(x)
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:577