FastLED 3.9.12
Loading...
Searching...
No Matches
scale_up.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <stdint.h>
11
12#include "bilinear_expansion.h"
13#include "fl/ptr.h"
14#include "fx/fx2d.h"
15#include "lib8tion/random8.h"
16#include "noise.h"
17#include "fl/xymap.h"
18
19// Optimized for 2^n grid sizes in terms of both memory and performance.
20// If you are somehow running this on AVR then you probably want this if
21// you can make your grid size a power of 2.
22#define FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 0 // 0 for always power of 2.
23// Uses more memory than FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 but can handle
24// arbitrary grid sizes.
25#define FASTLED_SCALE_UP_HIGH_PRECISION 1 // 1 for always choose high precision.
26// Uses the most executable memory because both low and high precision versions
27// are compiled in. If the grid size is a power of 2 then the faster version is
28// used. Note that the floating point version has to be directly specified
29// because in testing it offered no benefits over the integer versions.
30#define FASTLED_SCALE_UP_DECIDE_AT_RUNTIME 2 // 2 for runtime decision.
31
32#define FASTLED_SCALE_UP_FORCE_FLOATING_POINT 3 // Warning, this is slow.
33
34#ifndef FASTLED_SCALE_UP
35#define FASTLED_SCALE_UP FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
36#endif
37
38namespace fl {
39
40FASTLED_SMART_PTR(ScaleUp);
41
42// Uses bilearn filtering to double the size of the grid.
43class ScaleUp : public Fx2d {
44 public:
45 ScaleUp(XYMap xymap, Fx2dPtr fx);
46 void draw(DrawContext context) override;
47
48 void expand(const CRGB *input, CRGB *output, uint16_t width,
49 uint16_t height, XYMap mXyMap);
50
51 fl::Str fxName() const override { return "scale_up"; }
52
53 private:
54 // No expansion needed. Also useful for debugging.
55 void noExpand(const CRGB *input, CRGB *output, uint16_t width,
56 uint16_t height);
57 Fx2dPtr mDelegate;
59};
60
61} // namespace fl
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
void draw(DrawContext context) override
Definition scale_up.cpp:45
Definition str.h:368
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Functions to generate and fill arrays with noise.
Fast, efficient random number generators specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54