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
10#include "fl/allocator.h"
11#include "fl/draw_mode.h"
12
13namespace fl {
14
16
17// Frames are used to hold led data. This includes an optional alpha channel.
18// This object is used by the fx and video engines. Most of the memory used for
19// Fx and Video will be located in instances of this class. See
20// Frame::SetAllocator() for custom memory allocation.
21class Frame : public fl::Referent {
22 public:
23 // Frames take up a lot of memory. On some devices like ESP32 there is
24 // PSRAM available. You should see allocator.h ->
25 // SetLargeBlockAllocator(...) on setting a custom allocator for these large
26 // blocks.
27 explicit Frame(int pixels_per_frame);
28 ~Frame() override;
29 CRGB *rgb() { return mRgb.get(); }
30 const CRGB *rgb() const { return mRgb.get(); }
31 size_t size() const { return mPixelsCount; }
32 void copy(const Frame &other);
33 void interpolate(const Frame &frame1, const Frame &frame2,
34 uint8_t amountOfFrame2);
35 static void interpolate(const Frame &frame1, const Frame &frame2,
36 uint8_t amountofFrame2, CRGB *pixels);
37 void draw(CRGB *leds, DrawMode draw_mode = DRAW_MODE_OVERWRITE) const;
38 void drawXY(CRGB *leds, const XYMap &xyMap,
39 DrawMode draw_mode = DRAW_MODE_OVERWRITE) const;
40 void clear();
41
42 private:
43 const size_t mPixelsCount;
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(WIDTH, HEIGHT, false)
void draw(CRGB *leds, DrawMode draw_mode=DRAW_MODE_OVERWRITE) const
Definition frame.cpp:29
size_t size() const
Definition frame.h:31
fl::scoped_array< CRGB > mRgb
Definition frame.h:44
const CRGB * rgb() const
Definition frame.h:30
void interpolate(const Frame &frame1, const Frame &frame2, uint8_t amountOfFrame2)
Definition frame.cpp:101
~Frame() override
Definition frame.cpp:23
const size_t mPixelsCount
Definition frame.h:43
void copy(const Frame &other)
Definition frame.h:47
Frame(int pixels_per_frame)
Definition frame.cpp:17
void clear()
Definition frame.cpp:79
void drawXY(CRGB *leds, const XYMap &xyMap, DrawMode draw_mode=DRAW_MODE_OVERWRITE) const
Definition frame.cpp:46
CRGB * rgb()
Definition frame.h:29
T * get() const
Definition scoped_ptr.h:125
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_OVERWRITE
Definition draw_mode.h:5
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