9#include "fl/allocator.h"
15Frame::Frame(
int pixels_count)
16 : mPixelsCount(pixels_count), mRgb() {
17 mRgb.reset(
reinterpret_cast<CRGB *
>(LargeBlockAllocate(pixels_count *
sizeof(
CRGB))));
18 memset(mRgb.get(), 0, pixels_count *
sizeof(
CRGB));
23 LargeBlockDeallocate(mRgb.release());
27void Frame::draw(
CRGB* leds)
const {
29 memcpy(leds, mRgb.get(), mPixelsCount *
sizeof(
CRGB));
34void Frame::interpolate(
const Frame& frame1,
const Frame& frame2, uint8_t amountofFrame2,
CRGB* pixels) {
35 if (frame1.size() != frame2.size()) {
39 const CRGB* rgbFirst = frame1.rgb();
40 const CRGB* rgbSecond = frame2.rgb();
42 if (!rgbFirst || !rgbSecond) {
47 for (
size_t i = 0; i < frame2.size(); ++i) {
48 pixels[i] = CRGB::blend(rgbFirst[i], rgbSecond[i], amountofFrame2);
53void Frame::interpolate(
const Frame& frame1,
const Frame& frame2, uint8_t amountOfFrame2) {
54 if (frame1.size() != frame2.size() || frame1.size() != mPixelsCount) {
55 FASTLED_DBG(
"Frames must have the same size");
58 interpolate(frame1, frame2, amountOfFrame2, mRgb.get());
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Representation of an RGB pixel (Red, Green, Blue)