FastLED 3.9.15
Loading...
Searching...
No Matches
fx.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "crgb.h"
6#include "fl/namespace.h"
7#include "fl/ptr.h"
9#include "detail/transition.h"
10#include "fl/str.h"
11#include "fl/unused.h"
12
13namespace fl {
14
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
uint16_t mNumLeds
Definition fx.h:50
virtual fl::Str fxName() const =0
virtual void pause(uint32_t now)
Definition fx.h:42
virtual ~Fx()
Definition fx.h:49
virtual void resume(uint32_t now)
Definition fx.h:43
_DrawContext DrawContext
Definition fx.h:21
Fx(uint16_t numLeds)
Definition fx.h:23
virtual bool hasFixedFrameRate(float *fps) const
Definition fx.h:33
virtual void draw(DrawContext context)=0
uint16_t getNumLeds() const
Definition fx.h:46
Definition fx.h:18
Definition str.h:368
Defines the red, green, and blue (RGB) pixel struct.
#define FASTLED_SMART_PTR(type)
Definition ptr.h:17
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
#define FASTLED_UNUSED(x)
Definition unused.h:3