FastLED 3.9.7
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 "FastLED.h"
13#include "bilinear_expansion.h"
14#include "fl/ptr.h"
15#include "fx/fx2d.h"
16#include "lib8tion/random8.h"
17#include "noise.h"
18#include "fl/xymap.h"
19
20// Optimized for 2^n grid sizes in terms of both memory and performance.
21// If you are somehow running this on AVR then you probably want this if
22// you can make your grid size a power of 2.
23#define FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 0 // 0 for always power of 2.
24// Uses more memory than FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 but can handle
25// arbitrary grid sizes.
26#define FASTLED_SCALE_UP_HIGH_PRECISION 1 // 1 for always choose high precision.
27// Uses the most executable memory because both low and high precision versions
28// are compiled in. If the grid size is a power of 2 then the faster version is
29// used. Note that the floating point version has to be directly specified
30// because in testing it offered no benefits over the integer versions.
31#define FASTLED_SCALE_UP_DECIDE_AT_RUNTIME 2 // 2 for runtime decision.
32
33#define FASTLED_SCALE_UP_FORCE_FLOATING_POINT 3 // Warning, this is slow.
34
35#ifndef FASTLED_SCALE_UP
36#define FASTLED_SCALE_UP FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
37#endif
38
39namespace fl {
40
41FASTLED_SMART_PTR(ScaleUp);
42
43// Uses bilearn filtering to double the size of the grid.
44class ScaleUp : public Fx2d {
45 public:
46 ScaleUp(XYMap xymap, Fx2dPtr fx);
47 void draw(DrawContext context) override;
48
49 void expand(const CRGB *input, CRGB *output, uint16_t width,
50 uint16_t height, XYMap mXyMap);
51
52 fl::Str fxName() const override { return "scale_up"; }
53
54 private:
55 // No expansion needed. Also useful for debugging.
56 void noExpand(const CRGB *input, CRGB *output, uint16_t width,
57 uint16_t height);
58 Fx2dPtr mDelegate;
60};
61
62} // namespace fl
central include file for FastLED, defines the CFastLED class/object
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
void draw(DrawContext context) override
Definition scale_up.cpp:43
Definition str.h:336
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