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"
7#include "detail/transition.h"
8#include "fl/namespace.h"
9#include "fl/ptr.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
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::Str fxName() const = 0;
41
42 // Called when the fx is paused, usually when a transition has finished.
43 virtual void pause(uint32_t now) { FASTLED_UNUSED(now); }
44 virtual void resume(uint32_t now) {
45 FASTLED_UNUSED(now);
46 } // Called when the fx is resumed after a pause,
47 // usually when a transition has started.
48
49 uint16_t getNumLeds() const { return mNumLeds; }
50
51 protected:
52 virtual ~Fx() {} // Protected destructor
53 uint16_t mNumLeds;
54};
55
56} // namespace fl
uint16_t mNumLeds
Definition fx.h:53
virtual fl::Str fxName() const =0
virtual void pause(uint32_t now)
Definition fx.h:43
virtual ~Fx()
Definition fx.h:52
virtual void resume(uint32_t now)
Definition fx.h:44
_DrawContext DrawContext
Definition fx.h:21
Fx(uint16_t numLeds)
Definition fx.h:23
virtual bool hasFixedFrameRate(float *fps) const
Definition fx.h:34
virtual void draw(DrawContext context)=0
uint16_t getNumLeds() const
Definition fx.h:49
Definition fx.h:18
Definition str.h:388
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
#define FASTLED_SMART_PTR(type)
Definition ptr.h:31
#define FASTLED_UNUSED(x)
Definition unused.h:3