FastLED 3.9.15
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) : mNumLeds(numLeds) {}
24
28 virtual void
29 draw(DrawContext context) = 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 {
35 FASTLED_UNUSED(fps);
36 return false;
37 }
38
39 // Get the name of the current fx.
40 virtual fl::string fxName() const = 0;
41
42 // Called when the fx is paused, usually when a transition has finished.
43 virtual void pause(fl::u32 now) { FASTLED_UNUSED(now); }
44 virtual void resume(fl::u32 now) {
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 { return mNumLeds; }
50
51 protected:
52 virtual ~Fx() FL_NOEXCEPT {} // Protected destructor
54};
55
56} // namespace fl
Fx(u16 numLeds)
Definition fx.h:23
virtual ~Fx() FL_NOEXCEPT
Definition fx.h:52
u16 mNumLeds
Definition fx.h:53
virtual void pause(fl::u32 now)
Definition fx.h:43
::fl::DrawContext DrawContext
Definition fx.h:21
u16 getNumLeds() const
Definition fx.h:49
virtual fl::string fxName() const =0
virtual bool hasFixedFrameRate(float *fps) const
Definition fx.h:34
virtual void draw(DrawContext context)=0
virtual void resume(fl::u32 now)
Definition fx.h:44
Definition fx.h:18
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_UNUSED(x)
#define FL_NOEXCEPT
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535