FastLED 3.9.7
Loading...
Searching...
No Matches
frame.h
1#pragma once
2
3#include <string.h>
4
5#include "fl/namespace.h"
6#include "crgb.h"
7#include "fl/ptr.h"
8
9#include "fl/allocator.h"
10
11namespace fl {
12
13FASTLED_SMART_PTR(Frame);
14
15// Frames are used to hold led data. This includes an optional alpha channel. This object
16// is used by the fx and video engines. Most of the memory used for Fx and Video will be located
17// in instances of this class. See Frame::SetAllocator() for custom memory allocation.
18class Frame : public fl::Referent {
19public:
20 // Frames take up a lot of memory. On some devices like ESP32 there is
21 // PSRAM available. You should see allocator.h -> SetLargeBlockAllocator(...)
22 // on setting a custom allocator for these large blocks.
23 explicit Frame(int pixels_per_frame);
24 ~Frame() override;
25 CRGB* rgb() { return mRgb.get(); }
26 const CRGB* rgb() const { return mRgb.get(); }
27 size_t size() const { return mPixelsCount; }
28 void copy(const Frame& other);
29 void interpolate(const Frame& frame1, const Frame& frame2, uint8_t amountOfFrame2);
30 static void interpolate(const Frame& frame1, const Frame& frame2, uint8_t amountofFrame2, CRGB* pixels);
31 void draw(CRGB* leds) const;
32private:
33 const size_t mPixelsCount;
35};
36
37
38inline void Frame::copy(const Frame& other) {
39 memcpy(mRgb.get(), other.mRgb.get(), other.mPixelsCount * sizeof(CRGB));
40}
41
42} // namespace fl
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
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54