FastLED 3.9.15
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 "fl/upscale.h"
13#include "fl/ptr.h"
14#include "fl/vector.h"
15#include "fl/xymap.h"
16#include "fx/fx2d.h"
17#include "lib8tion/random8.h"
18#include "noise.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
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
XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
XYMap mXyMap
Definition fx2d.h:31
Fx2d(const XYMap &xyMap)
Definition fx2d.h:20
_DrawContext DrawContext
Definition fx.h:21
void expand(const CRGB *input, CRGB *output, uint16_t width, uint16_t height, XYMap mXyMap)
Definition scale_up.cpp:64
ScaleUp(XYMap xymap, Fx2dPtr fx)
Definition scale_up.cpp:37
void draw(DrawContext context) override
Definition scale_up.cpp:44
fl::vector< CRGB, fl::allocator_psram< CRGB > > mSurface
Definition scale_up.h:59
Fx2dPtr mDelegate
Definition scale_up.h:58
fl::Str fxName() const override
Definition scale_up.h:52
void noExpand(const CRGB *input, CRGB *output, uint16_t width, uint16_t height)
Definition scale_up.cpp:79
Definition str.h:389
HeapVector< T, Allocator > vector
Definition vector.h:1074
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Functions to generate and fill arrays with noise.
#define FASTLED_SMART_PTR(type)
Definition ptr.h:31
Fast, efficient random number generators specifically designed for high-performance LED programming.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55