FastLED 3.9.15
Loading...
Searching...
No Matches
frame.h
Go to the documentation of this file.
1#pragma once
2
3#include <string.h>
4
5#include "crgb.h"
6#include "fl/namespace.h"
7#include "fl/ptr.h"
8#include "fl/xymap.h"
9#include "fl/vector.h"
10
11#include "fl/allocator.h"
12#include "fl/draw_mode.h"
13
14namespace fl {
15
17
18// Frames are used to hold led data. This includes an optional alpha channel.
19// This object is used by the fx and video engines. Most of the memory used for
20// Fx and Video will be located in instances of this class. See
21// Frame::SetAllocator() for custom memory allocation.
22class Frame : public fl::Referent {
23 public:
24 // Frames take up a lot of memory. On some devices like ESP32 there is
25 // PSRAM available. You should see allocator.h ->
26 // SetPSRamAllocator(...) on setting a custom allocator for these large
27 // blocks.
28 explicit Frame(int pixels_per_frame);
29 ~Frame() override;
30 CRGB *rgb() { return mRgb.data(); }
31 const CRGB *rgb() const { return mRgb.data(); }
32 size_t size() const { return mPixelsCount; }
33 void copy(const Frame &other);
34 void interpolate(const Frame &frame1, const Frame &frame2,
35 uint8_t amountOfFrame2);
36 static void interpolate(const Frame &frame1, const Frame &frame2,
37 uint8_t amountofFrame2, CRGB *pixels);
38 void draw(CRGB *leds, DrawMode draw_mode = DRAW_MODE_OVERWRITE) const;
39 void drawXY(CRGB *leds, const XYMap &xyMap,
40 DrawMode draw_mode = DRAW_MODE_OVERWRITE) const;
41 void clear();
42
43 private:
44 const size_t mPixelsCount;
46};
47
48inline void Frame::copy(const Frame &other) {
49 memcpy(mRgb.data(), other.mRgb.data(), other.mPixelsCount * sizeof(CRGB));
50}
51
52} // namespace fl
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
void draw(CRGB *leds, DrawMode draw_mode=DRAW_MODE_OVERWRITE) const
Definition frame.cpp:26
size_t size() const
Definition frame.h:32
fl::vector< CRGB, fl::allocator_psram< CRGB > > mRgb
Definition frame.h:45
const CRGB * rgb() const
Definition frame.h:31
void interpolate(const Frame &frame1, const Frame &frame2, uint8_t amountOfFrame2)
Definition frame.cpp:98
~Frame() override
Definition frame.cpp:22
const size_t mPixelsCount
Definition frame.h:44
void copy(const Frame &other)
Definition frame.h:48
Frame(int pixels_per_frame)
Definition frame.cpp:17
void clear()
Definition frame.cpp:76
void drawXY(CRGB *leds, const XYMap &xyMap, DrawMode draw_mode=DRAW_MODE_OVERWRITE) const
Definition frame.cpp:43
CRGB * rgb()
Definition frame.h:30
Defines the red, green, and blue (RGB) pixel struct.
XYMap xyMap
Definition gfx.cpp:8
Implements the FastLED namespace macros.
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_OVERWRITE
Definition draw_mode.h:5
HeapVector< T, Allocator > vector
Definition vector.h:1074
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
#define FASTLED_SMART_PTR(type)
Definition ptr.h:31
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55