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