FastLED 3.9.7
Loading...
Searching...
No Matches
fx.h
1#pragma once
2
3#include <stdint.h>
4
5#include "crgb.h"
6#include "fl/namespace.h"
7#include "fl/ptr.h"
8#include "detail/draw_context.h"
9#include "detail/transition.h"
10#include "fl/str.h"
11#include "fl/unused.h"
12
13namespace fl {
14
15FASTLED_SMART_PTR(Fx);
16
17// Abstract base class for effects on a strip/grid of LEDs.
18class Fx : public fl::Referent {
19 public:
20 // Alias DrawContext for use within Fx
22
23 Fx(uint16_t numLeds) : mNumLeds(numLeds) {}
24
28 virtual void draw(DrawContext context) = 0; // This is the only function that needs to be implemented
29 // everything else is optional.
30
31 // If true then this fx has a fixed frame rate and the fps parameter will be
32 // set to the frame rate.
33 virtual bool hasFixedFrameRate(float *fps) const {
34 FASTLED_UNUSED(fps);
35 return false;
36 }
37
38 // Get the name of the current fx.
39 virtual fl::Str fxName() const = 0;
40
41 // Called when the fx is paused, usually when a transition has finished.
42 virtual void pause(uint32_t now) { FASTLED_UNUSED(now); }
43 virtual void resume(uint32_t now) { FASTLED_UNUSED(now); } // Called when the fx is resumed after a pause,
44 // usually when a transition has started.
45
46 uint16_t getNumLeds() const { return mNumLeds; }
47
48 protected:
49 virtual ~Fx() {} // Protected destructor
50 uint16_t mNumLeds;
51};
52
53} // namespace fl
Definition fx.h:18
virtual void draw(DrawContext context)=0
Definition str.h:336
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16