5#define FASTLED_INTERNAL
20#define FASTLED_SCALE_UP_ALWAYS_POWER_OF_2 0
23#define FASTLED_SCALE_UP_HIGH_PRECISION 1
28#define FASTLED_SCALE_UP_DECIDE_AT_RUNTIME 2
30#define FASTLED_SCALE_UP_FORCE_FLOATING_POINT 3
32#ifndef FASTLED_SCALE_UP
33#define FASTLED_SCALE_UP FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
38ScaleUp::ScaleUp(XYMap xymap, Fx2dPtr fx) : Fx2d(xymap), mDelegate(fx) {
42 mDelegate->getXYMap().setRectangularGrid();
47 mSurface.reset(
new CRGB[mDelegate->getNumLeds()]);
50 delegateContext.leds = mSurface.get();
51 mDelegate->draw(delegateContext);
53 uint16_t in_w = mDelegate->getWidth();
54 uint16_t in_h = mDelegate->getHeight();
55 uint16_t out_w = getWidth();
56 uint16_t out_h = getHeight();
58 if (in_w == out_w && in_h == out_h) {
59 noExpand(mSurface.get(), context.leds, in_w, in_h);
61 expand(mSurface.get(), context.leds, in_w, in_h, mXyMap);
65void ScaleUp::expand(
const CRGB *input,
CRGB *output, uint16_t width,
66 uint16_t height,
XYMap mXyMap) {
67#if FASTLED_SCALE_UP == FASTLED_SCALE_UP_ALWAYS_POWER_OF_2
69#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_HIGH_PRECISION
71#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
72 bilinearExpand(input, output, width, height, mXyMap);
73#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_FORCE_FLOATING_POINT
74 bilinearExpandFloat(input, output, width, height, mXyMap);
76#error "Invalid FASTLED_SCALE_UP"
80void ScaleUp::noExpand(
const CRGB *input,
CRGB *output, uint16_t width,
82 uint16_t n = mXyMap.getTotal();
83 for (uint16_t w = 0; w < width; w++) {
84 for (uint16_t h = 0; h < height; h++) {
85 uint16_t idx = mXyMap.mapToIndex(w, h);
87 output[idx] = input[w * height + h];
central include file for FastLED, defines the CFastLED class/object
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
Implements a simple red square effect for 2D LED grids.
void bilinearExpandArbitrary(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
void bilinearExpandPowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth, uint8_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
Functions to generate and fill arrays with noise.
Fast, efficient random number generators specifically designed for high-performance LED programming.
Expands a grid using bilinear interpolation and scaling up.
Representation of an RGB pixel (Red, Green, Blue)