aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authormrcodetastic <12006953+mrcodetastic@users.noreply.github.com>2024-07-28 23:40:30 +0100
committermrcodetastic <12006953+mrcodetastic@users.noreply.github.com>2024-07-28 23:40:30 +0100
commit3960bbed887fc6211ced5abcf8ef00ec4cbd0346 (patch)
tree8c9c2a51247a44f5b63f6cf04168a3e3944087ba /examples
parentf2634319ab7ebfe22fc6d2ebabcdd27879f3667e (diff)
updates
Diffstat (limited to 'examples')
-rw-r--r--examples/AuroraDemo/Attractor.h2
-rw-r--r--examples/AuroraDemo/AuroraDemo.ino4
-rw-r--r--examples/AuroraDemo/Effects.h372
-rw-r--r--examples/AuroraDemo/PatternAttract.h2
-rw-r--r--examples/AuroraDemo/PatternElectricMandala.h30
-rw-r--r--examples/AuroraDemo/PatternFire.h8
-rw-r--r--examples/AuroraDemo/PatternFlock.h8
-rw-r--r--examples/AuroraDemo/PatternFlowField.h2
-rw-r--r--examples/AuroraDemo/PatternIncrementalDrift.h6
-rw-r--r--examples/AuroraDemo/PatternIncrementalDrift2.h6
-rw-r--r--examples/AuroraDemo/PatternInfinity.h2
-rw-r--r--examples/AuroraDemo/PatternInvaders.h12
-rw-r--r--examples/AuroraDemo/PatternLife.h2
-rw-r--r--examples/AuroraDemo/PatternMaze.h6
-rw-r--r--examples/AuroraDemo/PatternMunch.h2
-rw-r--r--examples/AuroraDemo/PatternNoiseSmearing.h22
-rw-r--r--examples/AuroraDemo/PatternPendulumWave.h2
-rw-r--r--examples/AuroraDemo/PatternPlasma.h2
-rw-r--r--examples/AuroraDemo/PatternRadar.h8
-rw-r--r--examples/AuroraDemo/PatternSimplexNoise.h25
-rw-r--r--examples/AuroraDemo/PatternSnake.h2
-rw-r--r--examples/AuroraDemo/PatternSpark.h8
-rw-r--r--examples/AuroraDemo/PatternSpiro.h24
-rw-r--r--examples/AuroraDemo/PatternSwirl.h12
-rw-r--r--examples/AuroraDemo/PatternWave.h16
25 files changed, 271 insertions, 314 deletions
diff --git a/examples/AuroraDemo/Attractor.h b/examples/AuroraDemo/Attractor.h
index 668ba53..670a0f3 100644
--- a/examples/AuroraDemo/Attractor.h
+++ b/examples/AuroraDemo/Attractor.h
@@ -33,7 +33,7 @@ public:
PVector location; // Location
Attractor() {
- location = PVector(MATRIX_CENTRE_X, MATRIX_CENTRE_Y);
+ location = PVector(VPANEL_W/2, VPANEL_H/2);
mass = 10;
G = .5;
}
diff --git a/examples/AuroraDemo/AuroraDemo.ino b/examples/AuroraDemo/AuroraDemo.ino
index 7cf1a93..808a740 100644
--- a/examples/AuroraDemo/AuroraDemo.ino
+++ b/examples/AuroraDemo/AuroraDemo.ino
@@ -61,7 +61,7 @@ VirtualMatrixPanel *virtualDisp = nullptr;
// Aurora related
#include "Effects.h"
-Effects effects;
+Effects effects(VPANEL_W, VPANEL_H);
#include "Drawable.h"
#include "Playlist.h"
@@ -73,7 +73,7 @@ Patterns patterns;
/* -------------------------- Some variables -------------------------- */
unsigned long ms_current = 0;
unsigned long ms_previous = 0;
-unsigned long ms_animation_max_duration = 20000; // 10 seconds
+unsigned long ms_animation_max_duration = 10000; // 10 seconds
unsigned long next_frame = 0;
void listPatterns();
diff --git a/examples/AuroraDemo/Effects.h b/examples/AuroraDemo/Effects.h
index 3d4affb..54ae47d 100644
--- a/examples/AuroraDemo/Effects.h
+++ b/examples/AuroraDemo/Effects.h
@@ -7,6 +7,8 @@
* Portions of this code are adapted from "NoiseSmearing" by Stefan Petrick: https://gist.github.com/StefanPetrick/9ee2f677dbff64e3ba7a
* Copyright (c) 2014 Stefan Petrick
* http://www.stefan-petrick.de/wordpress_beta
+ *
+ * Modified by Codetastic 2024
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -29,106 +31,74 @@
#ifndef Effects_H
#define Effects_H
-/* ---------------------------- GLOBAL CONSTANTS ----------------------------- */
-const int MATRIX_CENTER_X = VPANEL_W / 2;
-const int MATRIX_CENTER_Y = VPANEL_H / 2;
-// US vs GB, huh? :)
-//const byte MATRIX_CENTRE_X = MATRIX_CENTER_X - 1;
-//const byte MATRIX_CENTRE_Y = MATRIX_CENTER_Y - 1;
-#define MATRIX_CENTRE_X MATRIX_CENTER_X
-#define MATRIX_CENTRE_Y MATRIX_CENTER_Y
+ /**
+ * The one for 256+ matrices
+ * otherwise this:
+ * for (uint8_t i = 0; i < VPANEL_W; i++) {}
+ * turns into an infinite loop
+ */
+ uint16_t XY16( uint16_t x, uint16_t y)
+ {
+ if( x >= VPANEL_W) return 0;
+ if( y >= VPANEL_H) return 0;
-const uint16_t NUM_LEDS = (VPANEL_W * VPANEL_H) + 1; // one led spare to capture out of bounds
-
-// forward declaration
-uint16_t XY16( uint16_t x, uint16_t y);
+ return (y * VPANEL_W) + x;
+ }
-/* Convert x,y co-ordinate to flat array index.
- * x and y positions start from 0, so must not be >= 'real' panel width or height
- * (i.e. 64 pixels or 32 pixels.). Max value: VPANEL_W-1 etc.
- * Ugh... uint8_t - really??? this weak method can't cope with 256+ pixel matrices :(
- */
-uint16_t XY( uint8_t x, uint8_t y)
-{
- return XY16(x, y);
-}
-/**
- * The one for 256+ matrices
- * otherwise this:
- * for (uint8_t i = 0; i < VPANEL_W; i++) {}
- * turns into an infinite loop
- */
-uint16_t XY16( uint16_t x, uint16_t y)
-{
- if( x >= VPANEL_W) return 0;
- if( y >= VPANEL_H) return 0;
+ /* Convert x,y co-ordinate to flat array index.
+ * x and y positions start from 0, so must not be >= 'real' panel width or height
+ * (i.e. 64 pixels or 32 pixels.). Max value: VPANEL_W-1 etc.
+ * Ugh... uint8_t - really??? this weak method can't cope with 256+ pixel matrices :(
+ */
+ uint16_t XY( uint16_t x, uint16_t y)
+ {
+ return XY16(x, y);
+ }
- return (y * VPANEL_W) + x + 1; // everything offset by one to compute out of bounds stuff - never displayed by ShowFrame()
-}
-uint8_t beatcos8(accum88 beats_per_minute, uint8_t lowest = 0, uint8_t highest = 255, uint32_t timebase = 0, uint8_t phase_offset = 0)
-{
- uint8_t beat = beat8(beats_per_minute, timebase);
- uint8_t beatcos = cos8(beat + phase_offset);
- uint8_t rangewidth = highest - lowest;
- uint8_t scaledbeat = scale8(beatcos, rangewidth);
- uint8_t result = lowest + scaledbeat;
- return result;
-}
-uint8_t mapsin8(uint8_t theta, uint8_t lowest = 0, uint8_t highest = 255) {
- uint8_t beatsin = sin8(theta);
- uint8_t rangewidth = highest - lowest;
- uint8_t scaledbeat = scale8(beatsin, rangewidth);
- uint8_t result = lowest + scaledbeat;
- return result;
-}
+class Effects {
-uint8_t mapcos8(uint8_t theta, uint8_t lowest = 0, uint8_t highest = 255) {
- uint8_t beatcos = cos8(theta);
- uint8_t rangewidth = highest - lowest;
- uint8_t scaledbeat = scale8(beatcos, rangewidth);
- uint8_t result = lowest + scaledbeat;
- return result;
-}
+public:
-// Array of temperature readings at each simulation cell
-//byte heat[NUM_LEDS]; // none of the currently enabled effects uses this
+ uint32_t noise_x;
+ uint32_t noise_y;
+ uint32_t noise_z;
+ uint32_t noise_scale_x;
+ uint32_t noise_scale_y;
-uint32_t noise_x;
-uint32_t noise_y;
-uint32_t noise_z;
-uint32_t noise_scale_x;
-uint32_t noise_scale_y;
+ uint8_t **noise = nullptr; // we will allocate mem later
+ uint8_t noisesmoothing;
-//uint8_t noise[VPANEL_W][VPANEL_H];
-uint8_t **noise = nullptr; // we will allocate mem later
-uint8_t noisesmoothing;
-class Effects {
-public:
CRGB *leds;
+ int width;
+ int height;
+ int num_leds = 0;
+
+ Effects(int w, int h) : width(w), height(h) {
- Effects(){
// we do dynamic allocation for leds buffer, otherwise esp32 toolchain can't link static arrays of such a big size for 256+ matrices
- leds = (CRGB *)malloc(NUM_LEDS * sizeof(CRGB));
+ leds = (CRGB *)malloc((width * height + 1) * sizeof(CRGB));
+ num_leds = width * height;
// allocate mem for noise effect
// (there should be some guards for malloc errors eventually)
- noise = (uint8_t **)malloc(VPANEL_W * sizeof(uint8_t *));
- for (int i = 0; i < VPANEL_W; ++i) {
- noise[i] = (uint8_t *)malloc(VPANEL_H * sizeof(uint8_t));
+ noise = (uint8_t **)malloc(width * sizeof(uint8_t *));
+ for (int i = 0; i < width; ++i) {
+ noise[i] = (uint8_t *)malloc(height * sizeof(uint8_t));
}
ClearFrame();
}
+
~Effects(){
free(leds);
- for (int i = 0; i < VPANEL_W; ++i) {
+ for (int i = 0; i < width; ++i) {
free(noise[i]);
}
free(noise);
@@ -141,91 +111,69 @@ public:
* As such, any time these effects want to write a pixel color, we first have to update
* the leds or leds2 array, and THEN write it to the RGB panel. This enables us to 'look up' the array to see what a pixel color was previously, each drawFrame().
*/
- void drawBackgroundFastLEDPixelCRGB(int16_t x, int16_t y, CRGB color)
+ void setPixel(int16_t x, int16_t y, CRGB color)
{
- leds[XY(x, y)] = color;
- //matrix.drawPixelRGB888(x, y, color.r, color.g, color.b);
+ leds[XY16(x, y)] = color;
}
// write one pixel with the specified color from the current palette to coordinates
- void Pixel(int x, int y, uint8_t colorIndex) {
- leds[XY(x, y)] = ColorFromCurrentPalette(colorIndex);
- //matrix.drawPixelRGB888(x, y, temp.r, temp.g, temp.b); // now draw it?
+ void setPixelFromPaletteIndex(int x, int y, uint8_t colorIndex) {
+ leds[XY16(x, y)] = ColorFromCurrentPalette(colorIndex);
}
- void PrepareFrame() {
- // leds = (CRGB*) backgroundLayer.backBuffer();
- }
+ void PrepareFrame() { }
- void ShowFrame() {
- //#if (FASTLED_VERSION >= 3001000)
- // nblendPaletteTowardPalette(currentPalette, targetPalette, 24);
- //#else
+ void ShowFrame() { // send to display
currentPalette = targetPalette;
- //#endif
-
- // backgroundLayer.swapBuffers();
- // leds = (CRGB*) backgroundLayer.backBuffer();
- // LEDS.countFPS();
-
- for (int y=0; y<VPANEL_H; ++y){
- for (int x=0; x<VPANEL_W; ++x){
- //Serial.printf("Flushing x, y coord %d, %d\n", x, y);
- uint16_t _pixel = XY16(x,y);
- virtualDisp->drawPixelRGB888( x, y, leds[_pixel].r, leds[_pixel].g, leds[_pixel].b);
- } // end loop to copy fast led to the dma matrix
- }
+
+ for (int y=0; y<height; ++y){
+ for (int x=0; x<width; ++x){
+ uint16_t _pixel = XY16(x,y);
+ virtualDisp->drawPixelRGB888( x, y, leds[_pixel].r, leds[_pixel].g, leds[_pixel].b);
+ } // end loop to copy fast led to the dma matrix
+ }
}
// scale the brightness of the screenbuffer down
- void DimAll(byte value)
- {
- for (int i = 0; i < NUM_LEDS; i++)
- {
- leds[i].nscale8(value);
- }
+ void DimAll(byte value) {
+ for (int i = 0; i < num_leds; i++)
+ leds[i].nscale8(value);
}
- void ClearFrame()
- {
- memset(leds, 0x00, NUM_LEDS * sizeof(CRGB)); // flush
+ void ClearFrame() {
+ for (int i = 0; i < num_leds; i++)
+ leds[i]= CRGB(0,0,0);
+
}
-
-
-/*
- void CircleStream(uint8_t value) {
- DimAll(value); ShowFrame();
-
- for (uint8_t offset = 0; offset < MATRIX_CENTER_X; offset++) {
- boolean hasprev = false;
- uint16_t prevxy = 0;
-
- for (uint8_t theta = 0; theta < 255; theta++) {
- uint8_t x = mapcos8(theta, offset, (VPANEL_W - 1) - offset);
- uint8_t y = mapsin8(theta, offset, (VPANEL_H - 1) - offset);
-
- uint16_t xy = XY(x, y);
- if (hasprev) {
- leds[prevxy] += leds[xy];
- }
+ uint8_t beatcos8(accum88 beats_per_minute, uint8_t lowest = 0, uint8_t highest = 255, uint32_t timebase = 0, uint8_t phase_offset = 0)
+ {
+ uint8_t beat = beat8(beats_per_minute, timebase);
+ uint8_t beatcos = cos8(beat + phase_offset);
+ uint8_t rangewidth = highest - lowest;
+ uint8_t scaledbeat = scale8(beatcos, rangewidth);
+ uint8_t result = lowest + scaledbeat;
+ return result;
+ }
- prevxy = xy;
- hasprev = true;
- }
- }
+ uint8_t mapsin8(uint8_t theta, uint8_t lowest = 0, uint8_t highest = 255) {
+ uint8_t beatsin = sin8(theta);
+ uint8_t rangewidth = highest - lowest;
+ uint8_t scaledbeat = scale8(beatsin, rangewidth);
+ uint8_t result = lowest + scaledbeat;
+ return result;
+ }
- for (uint8_t x = 0; x < VPANEL_W; x++) {
- for (uint8_t y = 0; y < VPANEL_H; y++) {
- uint16_t xy = XY(x, y);
- leds[xy] = leds2[xy];
- leds[xy].nscale8(value);
- leds2[xy].nscale8(value);
- }
- }
+ uint8_t mapcos8(uint8_t theta, uint8_t lowest = 0, uint8_t highest = 255) {
+ uint8_t beatcos = cos8(theta);
+ uint8_t rangewidth = highest - lowest;
+ uint8_t scaledbeat = scale8(beatcos, rangewidth);
+ uint8_t result = lowest + scaledbeat;
+ return result;
}
-*/
+
+
// palettes
static const int paletteCount = 10;
@@ -394,7 +342,7 @@ public:
if (osci[4] % 2 == 0)
osci[5] = osci[5] + 1; // .5
for (int i = 0; i < 4; i++) {
- p[i] = map8(sin8(osci[i]), 0, VPANEL_W - 1); //why? to keep the result in the range of 0-VPANEL_W (matrix size)
+ p[i] = map8(sin8(osci[i]), 0, width - 1); //why? to keep the result in the range of 0-VPANEL_W (matrix size)
}
}
@@ -404,11 +352,11 @@ public:
// rotates the first 16x16 quadrant 3 times onto a 32x32 (+90 degrees rotation for each one)
void Caleidoscope1() {
- for (int x = 0; x < MATRIX_CENTER_X; x++) {
- for (int y = 0; y < MATRIX_CENTER_Y; y++) {
- leds[XY16(VPANEL_W - 1 - x, y)] = leds[XY16(x, y)];
- leds[XY16(VPANEL_W - 1 - x, VPANEL_H - 1 - y)] = leds[XY16(x, y)];
- leds[XY16(x, VPANEL_H - 1 - y)] = leds[XY16(x, y)];
+ for (int x = 0; x < width / 2; x++) {
+ for (int y = 0; y < height / 2; y++) {
+ leds[XY16(width - 1 - x, y)] = leds[XY16(x, y)];
+ leds[XY16(width - 1 - x, height - 1 - y)] = leds[XY16(x, y)];
+ leds[XY16(x, height - 1 - y)] = leds[XY16(x, y)];
}
}
}
@@ -416,19 +364,19 @@ public:
// mirror the first 16x16 quadrant 3 times onto a 32x32
void Caleidoscope2() {
- for (int x = 0; x < MATRIX_CENTER_X; x++) {
- for (int y = 0; y < MATRIX_CENTER_Y; y++) {
- leds[XY16(VPANEL_W - 1 - x, y)] = leds[XY16(y, x)];
- leds[XY16(x, VPANEL_H - 1 - y)] = leds[XY16(y, x)];
- leds[XY16(VPANEL_W - 1 - x, VPANEL_H - 1 - y)] = leds[XY16(x, y)];
+ for (int x = 0; x < width / 2; x++) {
+ for (int y = 0; y < height / 2; y++) {
+ leds[XY16(width - 1 - x, y)] = leds[XY16(y, x)];
+ leds[XY16(x, height - 1 - y)] = leds[XY16(y, x)];
+ leds[XY16(width - 1 - x, height - 1 - y)] = leds[XY16(x, y)];
}
}
}
// copy one diagonal triangle into the other one within a 16x16
void Caleidoscope3() {
- for (int x = 0; x <= MATRIX_CENTRE_X && x < VPANEL_H; x++) {
- for (int y = 0; y <= x && y<VPANEL_H; y++) {
+ for (int x = 0; x <= width / 2 - 1 && x < height; x++) {
+ for (int y = 0; y <= x && y<height; y++) {
leds[XY16(x, y)] = leds[XY16(y, x)];
}
}
@@ -436,48 +384,48 @@ public:
// copy one diagonal triangle into the other one within a 16x16 (90 degrees rotated compared to Caleidoscope3)
void Caleidoscope4() {
- for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
- for (int y = 0; y <= MATRIX_CENTRE_Y - x; y++) {
- leds[XY16(MATRIX_CENTRE_Y - y, MATRIX_CENTRE_X - x)] = leds[XY16(x, y)];
+ for (int x = 0; x <= width / 2 - 1; x++) {
+ for (int y = 0; y <= height / 2 - 1 - x; y++) {
+ leds[XY16(height / 2 - 1 - y, width / 2 - 1 - x)] = leds[XY16(x, y)];
}
}
}
// copy one diagonal triangle into the other one within a 8x8
void Caleidoscope5() {
- for (int x = 0; x < VPANEL_W / 4; x++) {
- for (int y = 0; y <= x && y<=VPANEL_H; y++) {
+ for (int x = 0; x < width / 4; x++) {
+ for (int y = 0; y <= x && y<=height; y++) {
leds[XY16(x, y)] = leds[XY16(y, x)];
}
}
- for (int x = VPANEL_W / 4; x < VPANEL_W / 2; x++) {
- for (int y = VPANEL_H / 4; y >= 0; y--) {
+ for (int x = width / 4; x < width / 2; x++) {
+ for (int y = height / 4; y >= 0; y--) {
leds[XY16(x, y)] = leds[XY16(y, x)];
}
}
}
void Caleidoscope6() {
- for (int x = 1; x < MATRIX_CENTER_X; x++) {
+ for (int x = 1; x < width / 2; x++) {
leds[XY16(7 - x, 7)] = leds[XY16(x, 0)];
} //a
- for (int x = 2; x < MATRIX_CENTER_X; x++) {
+ for (int x = 2; x < width / 2; x++) {
leds[XY16(7 - x, 6)] = leds[XY16(x, 1)];
} //b
- for (int x = 3; x < MATRIX_CENTER_X; x++) {
+ for (int x = 3; x < width / 2; x++) {
leds[XY16(7 - x, 5)] = leds[XY16(x, 2)];
} //c
- for (int x = 4; x < MATRIX_CENTER_X; x++) {
+ for (int x = 4; x < width / 2; x++) {
leds[XY16(7 - x, 4)] = leds[XY16(x, 3)];
} //d
- for (int x = 5; x < MATRIX_CENTER_X; x++) {
+ for (int x = 5; x < width / 2; x++) {
leds[XY16(7 - x, 3)] = leds[XY16(x, 4)];
} //e
- for (int x = 6; x < MATRIX_CENTER_X; x++) {
+ for (int x = 6; x < width / 2; x++) {
leds[XY16(7 - x, 2)] = leds[XY16(x, 5)];
} //f
- for (int x = 7; x < MATRIX_CENTER_X; x++) {
+ for (int x = 7; x < width / 2; x++) {
leds[XY16(7 - x, 1)] = leds[XY16(x, 6)];
} //g
}
@@ -566,7 +514,7 @@ public:
}
// give it a linear tail to the right
- void StreamRight(byte scale, int fromX = 0, int toX = VPANEL_W, int fromY = 0, int toY = VPANEL_H)
+ void StreamRight(byte scale, int fromX = 0, int toX = 0, int fromY = 0, int toY = 0)
{
for (int x = fromX + 1; x < toX; x++) {
for (int y = fromY; y < toY; y++) {
@@ -579,7 +527,7 @@ public:
}
// give it a linear tail to the left
- void StreamLeft(byte scale, int fromX = VPANEL_W, int toX = 0, int fromY = 0, int toY = VPANEL_H)
+ void StreamLeft(byte scale, int fromX = 0, int toX = 0, int fromY = 0, int toY = 0)
{
for (int x = toX; x < fromX; x++) {
for (int y = fromY; y < toY; y++) {
@@ -594,66 +542,66 @@ public:
// give it a linear tail downwards
void StreamDown(byte scale)
{
- for (int x = 0; x < VPANEL_W; x++) {
- for (int y = 1; y < VPANEL_H; y++) {
+ for (int x = 0; x < width; x++) {
+ for (int y = 1; y < height; y++) {
leds[XY16(x, y)] += leds[XY16(x, y - 1)];
leds[XY16(x, y)].nscale8(scale);
}
}
- for (int x = 0; x < VPANEL_W; x++)
+ for (int x = 0; x < width; x++)
leds[XY16(x, 0)].nscale8(scale);
}
// give it a linear tail upwards
void StreamUp(byte scale)
{
- for (int x = 0; x < VPANEL_W; x++) {
- for (int y = VPANEL_H - 2; y >= 0; y--) {
+ for (int x = 0; x < width; x++) {
+ for (int y = height - 2; y >= 0; y--) {
leds[XY16(x, y)] += leds[XY16(x, y + 1)];
leds[XY16(x, y)].nscale8(scale);
}
}
- for (int x = 0; x < VPANEL_W; x++)
- leds[XY16(x, VPANEL_H - 1)].nscale8(scale);
+ for (int x = 0; x < width; x++)
+ leds[XY16(x, height - 1)].nscale8(scale);
}
// give it a linear tail up and to the left
void StreamUpAndLeft(byte scale)
{
- for (int x = 0; x < VPANEL_W - 1; x++) {
- for (int y = VPANEL_H - 2; y >= 0; y--) {
+ for (int x = 0; x < width - 1; x++) {
+ for (int y = height - 2; y >= 0; y--) {
leds[XY16(x, y)] += leds[XY16(x + 1, y + 1)];
leds[XY16(x, y)].nscale8(scale);
}
}
- for (int x = 0; x < VPANEL_W; x++)
- leds[XY16(x, VPANEL_H - 1)].nscale8(scale);
- for (int y = 0; y < VPANEL_H; y++)
- leds[XY16(VPANEL_W - 1, y)].nscale8(scale);
+ for (int x = 0; x < width; x++)
+ leds[XY16(x, height - 1)].nscale8(scale);
+ for (int y = 0; y < height; y++)
+ leds[XY16(width - 1, y)].nscale8(scale);
}
// give it a linear tail up and to the right
void StreamUpAndRight(byte scale)
{
- for (int x = 0; x < VPANEL_W - 1; x++) {
- for (int y = VPANEL_H - 2; y >= 0; y--) {
+ for (int x = 0; x < width - 1; x++) {
+ for (int y = height - 2; y >= 0; y--) {
leds[XY16(x + 1, y)] += leds[XY16(x, y + 1)];
leds[XY16(x, y)].nscale8(scale);
}
}
// fade the bottom row
- for (int x = 0; x < VPANEL_W; x++)
- leds[XY16(x, VPANEL_H - 1)].nscale8(scale);
+ for (int x = 0; x < width; x++)
+ leds[XY16(x, height - 1)].nscale8(scale);
// fade the right column
- for (int y = 0; y < VPANEL_H; y++)
- leds[XY16(VPANEL_W - 1, y)].nscale8(scale);
+ for (int y = 0; y < height; y++)
+ leds[XY16(width - 1, y)].nscale8(scale);
}
// just move everything one line down
void MoveDown() {
- for (int y = VPANEL_H - 1; y > 0; y--) {
- for (int x = 0; x < VPANEL_W; x++) {
+ for (int y = height - 1; y > 0; y--) {
+ for (int x = 0; x < width; x++) {
leds[XY16(x, y)] = leds[XY16(x, y - 1)];
}
}
@@ -662,7 +610,7 @@ public:
// just move everything one line down
void VerticalMoveFrom(int start, int end) {
for (int y = end; y > start; y--) {
- for (int x = 0; x < VPANEL_W; x++) {
+ for (int x = 0; x < width; x++) {
leds[XY16(x, y)] = leds[XY16(x, y - 1)];
}
}
@@ -680,18 +628,18 @@ public:
// rotate + copy triangle (MATRIX_CENTER_X*MATRIX_CENTER_X)
void RotateTriangle() {
- for (int x = 1; x < MATRIX_CENTER_X; x++) {
+ for (int x = 1; x < width / 2; x++) {
for (int y = 0; y < x; y++) {
- leds[XY16(x, 7 - y)] = leds[XY16(7 - x, y)];
+ leds[XY16(x, height / 2 - 1 - y)] = leds[XY16(width / 2 - 1 - x, y)];
}
}
}
// mirror + copy triangle (MATRIX_CENTER_X*MATRIX_CENTER_X)
void MirrorTriangle() {
- for (int x = 1; x < MATRIX_CENTER_X; x++) {
+ for (int x = 1; x < width / 2; x++) {
for (int y = 0; y < x; y++) {
- leds[XY16(7 - y, x)] = leds[XY16(7 - x, y)];
+ leds[XY16(height / 2 - 1 - y, x)] = leds[XY16(width / 2 - 1 - x, y)];
}
}
}
@@ -699,9 +647,9 @@ public:
// draw static rainbow triangle pattern (MATRIX_CENTER_XxWIDTH / 2)
// (just for debugging)
void RainbowTriangle() {
- for (int i = 0; i < MATRIX_CENTER_X; i++) {
+ for (int i = 0; i < width / 2; i++) {
for (int j = 0; j <= i; j++) {
- Pixel(7 - i, j, i * j * 4);
+ setPixelFromPaletteIndex(height / 2 - 1 - i, j, i * j * 4);
}
}
}
@@ -734,8 +682,8 @@ public:
// write one pixel with the specified color from the current palette to coordinates
/*
void Pixel(int x, int y, uint8_t colorIndex) {
- leds[XY(x, y)] = ColorFromCurrentPalette(colorIndex);
- matrix.drawBackgroundPixelRGB888(x,y, leds[XY(x, y)]); // now draw it?
+ leds[XY16(x, y)] = ColorFromCurrentPalette(colorIndex);
+ matrix.drawBackgroundPixelRGB888(x,y, leds[XY16(x, y)]); // now draw it?
}
*/
@@ -761,11 +709,11 @@ public:
}
void FillNoise() {
- for (uint16_t i = 0; i < VPANEL_W; i++) {
- uint32_t ioffset = noise_scale_x * (i - MATRIX_CENTRE_Y);
+ for (uint16_t i = 0; i < width; i++) {
+ uint32_t ioffset = noise_scale_x * (i - width / 2);
- for (uint16_t j = 0; j < VPANEL_H; j++) {
- uint32_t joffset = noise_scale_y * (j - MATRIX_CENTRE_Y);
+ for (uint16_t j = 0; j < height; j++) {
+ uint32_t joffset = noise_scale_y * (j - height / 2);
byte data = inoise16(noise_x + ioffset, noise_y + joffset, noise_z) >> 8;
@@ -784,7 +732,7 @@ public:
CRGB tmp = 0;
- for (int y = 0; y < VPANEL_H; y++)
+ for (int y = 0; y < height; y++)
{
// Shift Left: https://codedost.com/c/arraypointers-in-c/c-program-shift-elements-array-left-direction/
@@ -794,24 +742,24 @@ public:
for (int m = 0; m < delta; m++)
{
// Do this delta time for each row... computationally expensive potentially.
- for(int x = 0; x < VPANEL_W; x++)
+ for(int x = 0; x < width; x++)
{
leds[XY16(x, y)] = leds [XY16(x+1, y)];
}
- leds[XY16(VPANEL_W-1, y)] = tmp;
+ leds[XY16(width-1, y)] = tmp;
}
/*
// Shift
for (int x = 0; x < VPANEL_W - delta; x++) {
- leds2[XY(x, y)] = leds[XY(x + delta, y)];
+ leds2[XY16(x, y)] = leds[XY16(x + delta, y)];
}
// Wrap around
for (int x = VPANEL_W - delta; x < VPANEL_W; x++) {
- leds2[XY(x, y)] = leds[XY(x + delta - VPANEL_W, y)];
+ leds2[XY16(x, y)] = leds[XY16(x + delta - VPANEL_W, y)];
}
*/
} // end row loop
@@ -820,7 +768,7 @@ public:
// write back to leds
for (uint8_t y = 0; y < VPANEL_H; y++) {
for (uint8_t x = 0; x < VPANEL_W; x++) {
- leds[XY(x, y)] = leds2[XY(x, y)];
+ leds[XY16(x, y)] = leds2[XY16(x, y)];
}
}
*/
@@ -830,18 +778,18 @@ public:
{
CRGB tmp = 0;
- for (int x = 0; x < VPANEL_W; x++)
+ for (int x = 0; x < width; x++)
{
tmp = leds[XY16(x, 0)];
for (int m = 0; m < delta; m++) // moves
{
// Do this delta time for each row... computationally expensive potentially.
- for(int y = 0; y < VPANEL_H; y++)
+ for(int y = 0; y < height; y++)
{
leds[XY16(x, y)] = leds [XY16(x, y+1)];
}
- leds[XY16(x, VPANEL_H-1)] = tmp;
+ leds[XY16(x, height-1)] = tmp;
}
} // end column loop
} /// MoveY
diff --git a/examples/AuroraDemo/PatternAttract.h b/examples/AuroraDemo/PatternAttract.h
index dcb6491..b448563 100644
--- a/examples/AuroraDemo/PatternAttract.h
+++ b/examples/AuroraDemo/PatternAttract.h
@@ -61,7 +61,7 @@ public:
boid.applyForce(force);
boid.update();
- effects.drawBackgroundFastLEDPixelCRGB(boid.location.x, boid.location.y, effects.ColorFromCurrentPalette(boid.colorIndex));
+ effects.setPixel(boid.location.x, boid.location.y, effects.ColorFromCurrentPalette(boid.colorIndex));
boids[i] = boid;
}
diff --git a/examples/AuroraDemo/PatternElectricMandala.h b/examples/AuroraDemo/PatternElectricMandala.h
index 1977a83..9ae9ace 100644
--- a/examples/AuroraDemo/PatternElectricMandala.h
+++ b/examples/AuroraDemo/PatternElectricMandala.h
@@ -39,6 +39,9 @@ class PatternElectricMandala : public Drawable {
int16_t dsx;
int16_t dsy;
+
+ unsigned int last_parameter_change_ms = 0;
+
public:
PatternElectricMandala() {
name = (char *)"ElectricMandala";
@@ -46,18 +49,18 @@ class PatternElectricMandala : public Drawable {
void start() {
// set to reasonable values to avoid a black out
- noisesmoothing = 200;
+ effects.noisesmoothing = 200;
// just any free input pin
//random16_add_entropy(analogRead(18));
// fill coordinates with random values
// set zoom levels
- noise_x = random16();
- noise_y = random16();
- noise_z = random16();
- noise_scale_x = 6000;
- noise_scale_y = 6000;
+ effects.noise_x = random16();
+ effects.noise_y = random16();
+ effects.noise_z = random16();
+ effects.noise_scale_x = 6000;
+ effects.noise_scale_y = 6000;
// for the random movement
dx = random8();
@@ -70,19 +73,20 @@ class PatternElectricMandala : public Drawable {
unsigned int drawFrame() {
#if FASTLED_VERSION >= 3001000
// a new parameter set every 15 seconds
- EVERY_N_SECONDS(15) {
+ if(millis() - last_parameter_change_ms > 15000) {
+ last_parameter_change_ms = millis();
//SetupRandomPalette3();
dy = random16(500) - 250; // random16(2000) - 1000 is pretty fast but works fine, too
dx = random16(500) - 250;
dz = random16(500) - 250;
- noise_scale_x = random16(10000) + 2000;
- noise_scale_y = random16(10000) + 2000;
+ effects.noise_scale_x = random16(10000) + 2000;
+ effects.noise_scale_y = random16(10000) + 2000;
}
#endif
- noise_y += dy;
- noise_x += dx;
- noise_z += dz;
+ effects.noise_y += dy;
+ effects.noise_x += dx;
+ effects.noise_z += dz;
effects.FillNoise();
ShowNoiseLayer(0, 1, 0);
@@ -100,7 +104,7 @@ class PatternElectricMandala : public Drawable {
for (uint16_t i = 0; i < VPANEL_W; i++) {
for (uint16_t j = 0; j < VPANEL_H; j++) {
- uint8_t color = noise[i][j];
+ uint8_t color = effects.noise[i][j];
uint8_t bri = color;
diff --git a/examples/AuroraDemo/PatternFire.h b/examples/AuroraDemo/PatternFire.h
index 731aff9..0f46e2a 100644
--- a/examples/AuroraDemo/PatternFire.h
+++ b/examples/AuroraDemo/PatternFire.h
@@ -61,26 +61,26 @@ class PatternFire : public Drawable {
for (int x = 0; x < VPANEL_W; x++) {
// Step 1. Cool down every cell a little
for (int y = 0; y < VPANEL_H; y++) {
- int xy = XY(x, y);
+ int xy = XY16(x, y);
heat[xy] = qsub8(heat[xy], random8(0, ((cooling * 10) / VPANEL_H) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for (int y = 0; y < VPANEL_H; y++) {
- heat[XY(x, y)] = (heat[XY(x, y + 1)] + heat[XY(x, y + 2)] + heat[XY(x, y + 2)]) / 3;
+ heat[XY16(x, y)] = (heat[XY16(x, y + 1)] + heat[XY16(x, y + 2)] + heat[XY16(x, y + 2)]) / 3;
}
// Step 2. Randomly ignite new 'sparks' of heat
if (random8() < sparking) {
// int x = (p[0] + p[1] + p[2]) / 3;
- int xy = XY(x, VPANEL_H - 1);
+ int xy = XY16(x, VPANEL_H - 1);
heat[xy] = qadd8(heat[xy], random8(160, 255));
}
// Step 4. Map from heat cells to LED colors
for (int y = 0; y < VPANEL_H; y++) {
- int xy = XY(x, y);
+ int xy = XY16(x, y);
byte colorIndex = heat[xy];
// Recommend that you use values 0-240 rather than
diff --git a/examples/AuroraDemo/PatternFlock.h b/examples/AuroraDemo/PatternFlock.h
index 03c3fd7..8d3adc8 100644
--- a/examples/AuroraDemo/PatternFlock.h
+++ b/examples/AuroraDemo/PatternFlock.h
@@ -95,8 +95,8 @@ class PatternFlock : public Drawable {
PVector location = boid->location;
// PVector velocity = boid->velocity;
// backgroundLayer.drawLine(location.x, location.y, location.x - velocity.x, location.y - velocity.y, color);
- // effects.leds[XY(location.x, location.y)] += color;
- effects.drawBackgroundFastLEDPixelCRGB(location.x, location.y, color);
+ // effects.leds[XY16(location.x, location.y)] += color;
+ effects.setPixel(location.x, location.y, color);
if (applyWind) {
boid->applyForce(wind);
@@ -111,8 +111,8 @@ class PatternFlock : public Drawable {
PVector location = predator.location;
// PVector velocity = predator.velocity;
// backgroundLayer.drawLine(location.x, location.y, location.x - velocity.x, location.y - velocity.y, color);
- // effects.leds[XY(location.x, location.y)] += color;
- effects.drawBackgroundFastLEDPixelCRGB(location.x, location.y, color);
+ // effects.leds[XY16(location.x, location.y)] += color;
+ effects.setPixel(location.x, location.y, color);
}
if (millis() - last_update_hue_ms > 200) {
diff --git a/examples/AuroraDemo/PatternFlowField.h b/examples/AuroraDemo/PatternFlowField.h
index 8e41c3d..d0cb7a1 100644
--- a/examples/AuroraDemo/PatternFlowField.h
+++ b/examples/AuroraDemo/PatternFlowField.h
@@ -67,7 +67,7 @@ class PatternFlowField : public Drawable {
boid->velocity.y = -((float)cos8(angle) * 0.0078125 - 1.0);
boid->update();
- effects.drawBackgroundFastLEDPixelCRGB(boid->location.x, boid->location.y, effects.ColorFromCurrentPalette(angle + hue)); // color
+ effects.setPixel(boid->location.x, boid->location.y, effects.ColorFromCurrentPalette(angle + hue)); // color
if (boid->location.x < 0 || boid->location.x >= VPANEL_W ||
boid->location.y < 0 || boid->location.y >= VPANEL_H) {
diff --git a/examples/AuroraDemo/PatternIncrementalDrift.h b/examples/AuroraDemo/PatternIncrementalDrift.h
index 573c765..d2bb2ba 100644
--- a/examples/AuroraDemo/PatternIncrementalDrift.h
+++ b/examples/AuroraDemo/PatternIncrementalDrift.h
@@ -38,10 +38,10 @@ class PatternIncrementalDrift : public Drawable {
{
CRGB color = effects.ColorFromCurrentPalette((i - 2) * (240 / (VPANEL_W / 2)));
- uint8_t x = beatcos8((17 - i) * 2, MATRIX_CENTER_X - i, MATRIX_CENTER_X + i);
- uint8_t y = beatsin8((17 - i) * 2, MATRIX_CENTER_Y - i, MATRIX_CENTER_Y + i);
+ uint8_t x = effects.beatcos8((17 - i) * 2, VPANEL_W/2 - i, VPANEL_W/2 + i);
+ uint8_t y = beatsin8((17 - i) * 2, VPANEL_H/2 - i, VPANEL_H/2 + i);
- effects.drawBackgroundFastLEDPixelCRGB(x, y, color);
+ effects.setPixel(x, y, color);
}
return 0;
diff --git a/examples/AuroraDemo/PatternIncrementalDrift2.h b/examples/AuroraDemo/PatternIncrementalDrift2.h
index 03312f6..e30ac39 100644
--- a/examples/AuroraDemo/PatternIncrementalDrift2.h
+++ b/examples/AuroraDemo/PatternIncrementalDrift2.h
@@ -43,18 +43,18 @@ class PatternIncrementalDrift2 : public Drawable {
uint8_t y = 0;
if (i < 16) {
- x = beatcos8((i + 1) * 2, i, VPANEL_W - i);
+ x = effects.beatcos8((i + 1) * 2, i, VPANEL_W - i);
y = beatsin8((i + 1) * 2, i, VPANEL_H - i);
color = effects.ColorFromCurrentPalette(i * 14);
}
else
{
x = beatsin8((32 - i) * 2, VPANEL_W - i, i + 1);
- y = beatcos8((32 - i) * 2, VPANEL_H - i, i + 1);
+ y = effects.beatcos8((32 - i) * 2, VPANEL_H - i, i + 1);
color = effects.ColorFromCurrentPalette((31 - i) * 14);
}
- effects.drawBackgroundFastLEDPixelCRGB(x, y, color);
+ effects.setPixel(x, y, color);
}
return 0;
diff --git a/examples/AuroraDemo/PatternInfinity.h b/examples/AuroraDemo/PatternInfinity.h
index c99f329..e8f4091 100644
--- a/examples/AuroraDemo/PatternInfinity.h
+++ b/examples/AuroraDemo/PatternInfinity.h
@@ -51,7 +51,7 @@ public:
byte hue = sin8(effects.osci[5]);
// draw a pixel at x,y using a color from the current palette
- effects.Pixel(x, y, hue);
+ effects.setPixelFromPaletteIndex(x, y, hue);
effects.ShowFrame();
return 30;
diff --git a/examples/AuroraDemo/PatternInvaders.h b/examples/AuroraDemo/PatternInvaders.h
index cb76c34..5dea111 100644
--- a/examples/AuroraDemo/PatternInvaders.h
+++ b/examples/AuroraDemo/PatternInvaders.h
@@ -48,10 +48,10 @@ class PatternInvadersSmall : public Drawable {
if (random(0, 2) == 1) color = color1;
- effects.drawBackgroundFastLEDPixelCRGB(x + i, y + j, color);
+ effects.setPixel(x + i, y + j, color);
if (i < 2)
- effects.drawBackgroundFastLEDPixelCRGB(x + (4 - i), y + j, color);
+ effects.setPixel(x + (4 - i), y + j, color);
}
}
@@ -92,10 +92,10 @@ class PatternInvadersMedium : public Drawable {
if (random(0, 2) == 1) color = color1;
- effects.drawBackgroundFastLEDPixelCRGB(x + (i * 2), y + (j * 2), color);
+ effects.setPixel(x + (i * 2), y + (j * 2), color);
if (i < 2)
- effects.drawBackgroundFastLEDPixelCRGB(x + (8 - i * 2), y + (j * 2), color);
+ effects.setPixel(x + (8 - i * 2), y + (j * 2), color);
}
}
@@ -138,10 +138,10 @@ class PatternInvadersLarge : public Drawable {
color = color1;
}
- effects.drawBackgroundFastLEDPixelCRGB(1 + x * 6, 1 + y * 6, color);
+ effects.setPixel(1 + x * 6, 1 + y * 6, color);
if (x < 2)
- effects.drawBackgroundFastLEDPixelCRGB(1 + (4 - x) * 6, 1 + y * 6, color);
+ effects.setPixel(1 + (4 - x) * 6, 1 + y * 6, color);
}
}
diff --git a/examples/AuroraDemo/PatternLife.h b/examples/AuroraDemo/PatternLife.h
index 8074e40..fa33524 100644
--- a/examples/AuroraDemo/PatternLife.h
+++ b/examples/AuroraDemo/PatternLife.h
@@ -85,7 +85,7 @@ public:
// Display current generation
for (int i = 0; i < VPANEL_W; i++) {
for (int j = 0; j < VPANEL_H; j++) {
- effects.leds[XY(i, j)] = effects.ColorFromCurrentPalette(world[i][j].hue * 4, world[i][j].brightness);
+ effects.leds[XY16(i, j)] = effects.ColorFromCurrentPalette(world[i][j].hue * 4, world[i][j].brightness);
}
}
diff --git a/examples/AuroraDemo/PatternMaze.h b/examples/AuroraDemo/PatternMaze.h
index b4e26a9..b709db2 100644
--- a/examples/AuroraDemo/PatternMaze.h
+++ b/examples/AuroraDemo/PatternMaze.h
@@ -175,7 +175,7 @@ private:
Point imagePoint = createPoint(point.x * 2, point.y * 2);
- //effects.drawBackgroundFastLEDPixelCRGB(imagePoint.x, imagePoint.y, CRGB(CRGB::Gray));
+ //effects.setPixel(imagePoint.x, imagePoint.y, CRGB(CRGB::Gray));
shuffleDirections();
@@ -191,7 +191,7 @@ private:
Point newImagePoint = imagePoint.Move(direction);
- effects.drawBackgroundFastLEDPixelCRGB(newImagePoint.x, newImagePoint.y, color);
+ effects.setPixel(newImagePoint.x, newImagePoint.y, color);
cellCount++;
cells[cellCount - 1] = newPoint;
@@ -204,7 +204,7 @@ private:
if (index > -1) {
Point finishedPoint = cells[index];
imagePoint = createPoint(finishedPoint.x * 2, finishedPoint.y * 2);
- effects.drawBackgroundFastLEDPixelCRGB(imagePoint.x, imagePoint.y, color);
+ effects.setPixel(imagePoint.x, imagePoint.y, color);
removeCell(index);
}
diff --git a/examples/AuroraDemo/PatternMunch.h b/examples/AuroraDemo/PatternMunch.h
index 092dca1..370f690 100644
--- a/examples/AuroraDemo/PatternMunch.h
+++ b/examples/AuroraDemo/PatternMunch.h
@@ -45,7 +45,7 @@ public:
effects.leds[XY16(x, y)] = (x ^ y ^ flip) < count ? effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) : CRGB::Black;
// The below is more pleasant
- // effects.leds[XY(x, y)] = effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) ;
+ // effects.leds[XY16(x, y)] = effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) ;
}
}
diff --git a/examples/AuroraDemo/PatternNoiseSmearing.h b/examples/AuroraDemo/PatternNoiseSmearing.h
index 2d6723a..2555361 100644
--- a/examples/AuroraDemo/PatternNoiseSmearing.h
+++ b/examples/AuroraDemo/PatternNoiseSmearing.h
@@ -54,8 +54,8 @@ public:
byte x2 = 8 + sin8(counter * 2) / 16;
byte y2 = 8 + cos8((counter * 2) / 3) / 16;
- effects.leds[XY(x1, x2)] = effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
- effects.leds[XY(x2, y2)] = effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 128);
+ effects.leds[XY16(x1, x2)] = effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
+ effects.leds[XY16(x2, y2)] = effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 128);
// Noise
noise_x += 1000;
@@ -87,13 +87,13 @@ public:
byte xx = 4 + sin8(millis() / 9) / 10;
byte yy = 4 + cos8(millis() / 10) / 10;
- effects.leds[XY(xx, yy)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
+ effects.leds[XY16(xx, yy)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
xx = 8 + sin8(millis() / 10) / 16;
yy = 8 + cos8(millis() / 7) / 16;
- effects.leds[XY(xx, yy)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 80);
+ effects.leds[XY16(xx, yy)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 80);
- effects.leds[XY(15, 15)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 160);
+ effects.leds[XY16(15, 15)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue + 160);
noise_x += 1000;
noise_y += 1000;
@@ -125,7 +125,7 @@ public:
effects.DimAll(235); effects.ShowFrame();
for (uint8_t i = 3; i < 32; i = i + 4) {
- effects.leds[XY(i, 15)] += effects.ColorFromCurrentPalette(i * 8);
+ effects.leds[XY16(i, 15)] += effects.ColorFromCurrentPalette(i * 8);
}
// Noise
@@ -159,7 +159,7 @@ public:
//CLS();
effects.DimAll(235); effects.ShowFrame();
- effects.leds[XY(15, 15)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
+ effects.leds[XY16(15, 15)] += effects.ColorFromCurrentPalette(patternNoiseSmearingHue);
// Noise
@@ -194,7 +194,7 @@ public:
for (uint8_t i = 3; i < 32; i = i + 4) {
- effects.leds[XY(i, 31)] += effects.ColorFromCurrentPalette(i * 8);
+ effects.leds[XY16(i, 31)] += effects.ColorFromCurrentPalette(i * 8);
}
// Noise
@@ -228,7 +228,7 @@ public:
for (uint8_t y = 1; y < 32; y = y + 6) {
for (uint8_t x = 1; x < 32; x = x + 6) {
- effects.leds[XY(x, y)] += effects.ColorFromCurrentPalette((x * y) / 4);
+ effects.leds[XY16(x, y)] += effects.ColorFromCurrentPalette((x * y) / 4);
}
}
@@ -263,7 +263,7 @@ public:
// draw a rainbow color palette
for (uint8_t y = 0; y < VPANEL_H; y++) {
for (uint8_t x = 0; x < VPANEL_W; x++) {
- effects.leds[XY(x, y)] += effects.ColorFromCurrentPalette(x * 8, y * 8 + 7);
+ effects.leds[XY16(x, y)] += effects.ColorFromCurrentPalette(x * 8, y * 8 + 7);
}
}
@@ -310,7 +310,7 @@ public:
for (uint8_t c = 0; c < 6; c++) {
for (uint8_t j = 0; j < 5; j++) {
for (uint8_t x = 0; x < VPANEL_W; x++) {
- effects.leds[XY(x, y)] += rainbow[c];
+ effects.leds[XY16(x, y)] += rainbow[c];
}
y++;
diff --git a/examples/AuroraDemo/PatternPendulumWave.h b/examples/AuroraDemo/PatternPendulumWave.h
index 985e15a..01327cd 100644
--- a/examples/AuroraDemo/PatternPendulumWave.h
+++ b/examples/AuroraDemo/PatternPendulumWave.h
@@ -56,7 +56,7 @@ class PatternPendulumWave : public Drawable {
uint8_t y = beatsin16(WAVE_BPM, 0, amp, x*beatsin16(SKEW_BPM, WAVE_TIMEMINSKEW, WAVE_TIMEMAXSKEW)) + offset;
- effects.drawBackgroundFastLEDPixelCRGB(x, y, effects.ColorFromCurrentPalette(x * 7));
+ effects.setPixel(x, y, effects.ColorFromCurrentPalette(x * 7));
}
effects.ShowFrame();
return 20;
diff --git a/examples/AuroraDemo/PatternPlasma.h b/examples/AuroraDemo/PatternPlasma.h
index dcecc97..6c8bc4d 100644
--- a/examples/AuroraDemo/PatternPlasma.h
+++ b/examples/AuroraDemo/PatternPlasma.h
@@ -45,7 +45,7 @@ public:
v += cos16(y * (128 - wibble) * 6 + time);
v += sin16(y * x * cos8(-time) / 8);
- effects.Pixel(x, y, (v >> 8) + 127);
+ effects.setPixelFromPaletteIndex(x, y, (v >> 8) + 127);
}
}
diff --git a/examples/AuroraDemo/PatternRadar.h b/examples/AuroraDemo/PatternRadar.h
index fca1579..b0433b7 100644
--- a/examples/AuroraDemo/PatternRadar.h
+++ b/examples/AuroraDemo/PatternRadar.h
@@ -36,12 +36,12 @@ class PatternRadar : public Drawable {
unsigned int drawFrame() {
effects.DimAll(254); effects.ShowFrame();
- for (int offset = 0; offset < MATRIX_CENTER_X; offset++) {
+ for (int offset = 0; offset < VPANEL_W/2; offset++) {
byte hue = 255 - (offset * 16 + hueoffset);
CRGB color = effects.ColorFromCurrentPalette(hue);
- uint8_t x = mapcos8(theta, offset, (VPANEL_W - 1) - offset);
- uint8_t y = mapsin8(theta, offset, (VPANEL_H - 1) - offset);
- uint16_t xy = XY(x, y);
+ uint8_t x = effects.mapcos8(theta, offset, (VPANEL_W - 1) - offset);
+ uint8_t y = effects.mapsin8(theta, offset, (VPANEL_H - 1) - offset);
+ uint16_t xy = XY16(x, y);
effects.leds[xy] = color;
if (millis() - last_update_hue_ms > 25) {
diff --git a/examples/AuroraDemo/PatternSimplexNoise.h b/examples/AuroraDemo/PatternSimplexNoise.h
index 3810ec0..4a031e7 100644
--- a/examples/AuroraDemo/PatternSimplexNoise.h
+++ b/examples/AuroraDemo/PatternSimplexNoise.h
@@ -27,6 +27,10 @@
#define PatternSimplexNoise_H
class PatternSimplexNoise : public Drawable {
+
+ private:
+
+ unsigned int last_update_ms = 0;
public:
PatternSimplexNoise() {
name = (char *)"Noise";
@@ -34,18 +38,19 @@ class PatternSimplexNoise : public Drawable {
void start() {
// Initialize our coordinates to some random values
- noise_x = random16();
- noise_y = random16();
- noise_z = random16();
+ effects.noise_x = random16();
+ effects.noise_y = random16();
+ effects.noise_z = random16();
}
unsigned int drawFrame() {
#if FASTLED_VERSION >= 3001000
// a new parameter set every 15 seconds
- EVERY_N_SECONDS(15) {
- noise_x = random16();
- noise_y = random16();
- noise_z = random16();
+ if(millis() - last_update_ms > 15000) {
+ last_update_ms = millis();
+ effects.noise_x = random16();
+ effects.noise_y = random16();
+ effects.noise_z = random16();
}
#endif
@@ -55,8 +60,8 @@ class PatternSimplexNoise : public Drawable {
ShowNoiseLayer(0, 1, 0);
// noise_x += speed;
- noise_y += speed;
- noise_z += speed;
+ effects.noise_y += speed;
+ effects.noise_z += speed;
effects.ShowFrame();
@@ -67,7 +72,7 @@ class PatternSimplexNoise : public Drawable {
void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) {
for (uint16_t i = 0; i < VPANEL_W; i++) {
for (uint16_t j = 0; j < VPANEL_H; j++) {
- uint8_t pixel = noise[i][j];
+ uint8_t pixel = effects.noise[i][j];
// assign a color depending on the actual palette
effects.leds[XY16(i, j)] = effects.ColorFromCurrentPalette(colorrepeat * (pixel + colorshift), pixel);
diff --git a/examples/AuroraDemo/PatternSnake.h b/examples/AuroraDemo/PatternSnake.h
index 00895ab..ae151ec 100644
--- a/examples/AuroraDemo/PatternSnake.h
+++ b/examples/AuroraDemo/PatternSnake.h
@@ -96,7 +96,7 @@ private:
void draw(CRGB colors[SNAKE_LENGTH]) {
for (byte i = 0; i < SNAKE_LENGTH; i++) {
- effects.leds[XY(pixels[i].x, pixels[i].y)] = colors[i] %= (255 - i * (255 / SNAKE_LENGTH));
+ effects.leds[XY16(pixels[i].x, pixels[i].y)] = colors[i] %= (255 - i * (255 / SNAKE_LENGTH));
}
}
};
diff --git a/examples/AuroraDemo/PatternSpark.h b/examples/AuroraDemo/PatternSpark.h
index 059d97c..3517365 100644
--- a/examples/AuroraDemo/PatternSpark.h
+++ b/examples/AuroraDemo/PatternSpark.h
@@ -57,26 +57,26 @@ class PatternSpark : public Drawable {
for (uint8_t x = 0; x < VPANEL_W; x++) {
// Step 1. Cool down every cell a little
for (int y = 0; y < VPANEL_H; y++) {
- int xy = XY(x, y);
+ int xy = XY16(x, y);
heat[xy] = qsub8(heat[xy], random8(0, ((cooling * 10) / VPANEL_H) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for (int y = 0; y < VPANEL_H; y++) {
- heat[XY(x, y)] = (heat[XY(x, y + 1)] + heat[XY(x, y + 2)] + heat[XY(x, y + 2)]) / 3;
+ heat[XY16(x, y)] = (heat[XY16(x, y + 1)] + heat[XY16(x, y + 2)] + heat[XY16(x, y + 2)]) / 3;
}
// Step 2. Randomly ignite new 'sparks' of heat
if (random8() < sparking) {
uint8_t xt = random8(MATRIX_CENTRE_X - 2, MATRIX_CENTER_X + 3);
- int xy = XY(xt, VPANEL_H - 1);
+ int xy = XY16(xt, VPANEL_H - 1);
heat[xy] = qadd8(heat[xy], random8(160, 255));
}
// Step 4. Map from heat cells to LED colors
for (int y = 0; y < VPANEL_H; y++) {
- int xy = XY(x, y);
+ int xy = XY16(x, y);
byte colorIndex = heat[xy];
// Recommend that you use values 0-240 rather than
diff --git a/examples/AuroraDemo/PatternSpiro.h b/examples/AuroraDemo/PatternSpiro.h
index 8e4f750..8a544f7 100644
--- a/examples/AuroraDemo/PatternSpiro.h
+++ b/examples/AuroraDemo/PatternSpiro.h
@@ -30,12 +30,12 @@ class PatternSpiro : public Drawable {
uint8_t radiusx = VPANEL_W / 4;
uint8_t radiusy = VPANEL_H / 4;
- uint8_t minx = MATRIX_CENTER_X - radiusx;
- uint8_t maxx = MATRIX_CENTER_X + radiusx + 1;
- uint8_t miny = MATRIX_CENTER_Y - radiusy;
- uint8_t maxy = MATRIX_CENTER_Y + radiusy + 1;
+ uint8_t minx = VPANEL_W/2 - radiusx;
+ uint8_t maxx = VPANEL_W/2 + radiusx + 1;
+ uint8_t miny = VPANEL_H/2 - radiusy;
+ uint8_t maxy = VPANEL_H/2 + radiusy + 1;
- uint8_t spirocount = 1;
+ uint8_t spirocount = 16;
uint8_t spirooffset = 256 / spirocount;
boolean spiroincrement = true;
@@ -60,17 +60,17 @@ class PatternSpiro : public Drawable {
boolean change = false;
for (int i = 0; i < spirocount; i++) {
- uint8_t x = mapsin8(theta1 + i * spirooffset, minx, maxx);
- uint8_t y = mapcos8(theta1 + i * spirooffset, miny, maxy);
+ uint8_t x = effects.mapsin8(theta1 + i * spirooffset, minx, maxx);
+ uint8_t y = effects.mapcos8(theta1 + i * spirooffset, miny, maxy);
- uint8_t x2 = mapsin8(theta2 + i * spirooffset, x - radiusx, x + radiusx);
- uint8_t y2 = mapcos8(theta2 + i * spirooffset, y - radiusy, y + radiusy);
+ uint8_t x2 = effects.mapsin8(theta2 + i * spirooffset, x - radiusx, x + radiusx);
+ uint8_t y2 = effects.mapcos8(theta2 + i * spirooffset, y - radiusy, y + radiusy);
CRGB color = effects.ColorFromCurrentPalette(hueoffset + i * spirooffset, 128);
- effects.leds[XY(x2, y2)] += color;
+ effects.leds[XY16(x2, y2)] += color;
- if((x2 == MATRIX_CENTER_X && y2 == MATRIX_CENTER_Y) ||
- (x2 == MATRIX_CENTRE_X && y2 == MATRIX_CENTRE_Y)) change = true;
+ if((x2 == VPANEL_W/2 && y2 == VPANEL_H/2) ||
+ (x2 == VPANEL_W/2 && y2 == VPANEL_H/2)) change = true;
}
theta2 += 1;
diff --git a/examples/AuroraDemo/PatternSwirl.h b/examples/AuroraDemo/PatternSwirl.h
index 49f3273..807408a 100644
--- a/examples/AuroraDemo/PatternSwirl.h
+++ b/examples/AuroraDemo/PatternSwirl.h
@@ -62,12 +62,12 @@ class PatternSwirl : public Drawable {
// The color of each point shifts over time, each at a different speed.
uint16_t ms = millis();
- effects.leds[XY(i, j)] += effects.ColorFromCurrentPalette(ms / 11);
- //effects.leds[XY(j, i)] += effects.ColorFromCurrentPalette(ms / 13); // this doesn't work for non-square matrices
- effects.leds[XY(ni, nj)] += effects.ColorFromCurrentPalette(ms / 17);
- //effects.leds[XY(nj, ni)] += effects.ColorFromCurrentPalette(ms / 29); // this doesn't work for non-square matrices
- effects.leds[XY(i, nj)] += effects.ColorFromCurrentPalette(ms / 37);
- effects.leds[XY(ni, j)] += effects.ColorFromCurrentPalette(ms / 41);
+ effects.leds[XY16(i, j)] += effects.ColorFromCurrentPalette(ms / 11);
+ //effects.leds[XY16(j, i)] += effects.ColorFromCurrentPalette(ms / 13); // this doesn't work for non-square matrices
+ effects.leds[XY16(ni, nj)] += effects.ColorFromCurrentPalette(ms / 17);
+ //effects.leds[XY16(nj, ni)] += effects.ColorFromCurrentPalette(ms / 29); // this doesn't work for non-square matrices
+ effects.leds[XY16(i, nj)] += effects.ColorFromCurrentPalette(ms / 37);
+ effects.leds[XY16(ni, j)] += effects.ColorFromCurrentPalette(ms / 41);
effects.ShowFrame();
diff --git a/examples/AuroraDemo/PatternWave.h b/examples/AuroraDemo/PatternWave.h
index 90e7448..4dcc103 100644
--- a/examples/AuroraDemo/PatternWave.h
+++ b/examples/AuroraDemo/PatternWave.h
@@ -60,36 +60,36 @@ public:
case 0:
for (int x = 0; x < VPANEL_W; x++) {
n = quadwave8(x * 2 + theta) / scale;
- effects.drawBackgroundFastLEDPixelCRGB(x, n, effects.ColorFromCurrentPalette(x + hue));
+ effects.setPixel(x, n, effects.ColorFromCurrentPalette(x + hue));
if (waveCount == 2)
- effects.drawBackgroundFastLEDPixelCRGB(x, maxY - n, effects.ColorFromCurrentPalette(x + hue));
+ effects.setPixel(x, maxY - n, effects.ColorFromCurrentPalette(x + hue));
}
break;
case 1:
for (int y = 0; y < VPANEL_H; y++) {
n = quadwave8(y * 2 + theta) / scale;
- effects.drawBackgroundFastLEDPixelCRGB(n, y, effects.ColorFromCurrentPalette(y + hue));
+ effects.setPixel(n, y, effects.ColorFromCurrentPalette(y + hue));
if (waveCount == 2)
- effects.drawBackgroundFastLEDPixelCRGB(maxX - n, y, effects.ColorFromCurrentPalette(y + hue));
+ effects.setPixel(maxX - n, y, effects.ColorFromCurrentPalette(y + hue));
}
break;
case 2:
for (int x = 0; x < VPANEL_W; x++) {
n = quadwave8(x * 2 - theta) / scale;
- effects.drawBackgroundFastLEDPixelCRGB(x, n, effects.ColorFromCurrentPalette(x + hue));
+ effects.setPixel(x, n, effects.ColorFromCurrentPalette(x + hue));
if (waveCount == 2)
- effects.drawBackgroundFastLEDPixelCRGB(x, maxY - n, effects.ColorFromCurrentPalette(x + hue));
+ effects.setPixel(x, maxY - n, effects.ColorFromCurrentPalette(x + hue));
}
break;
case 3:
for (int y = 0; y < VPANEL_H; y++) {
n = quadwave8(y * 2 - theta) / scale;
- effects.drawBackgroundFastLEDPixelCRGB(n, y, effects.ColorFromCurrentPalette(y + hue));
+ effects.setPixel(n, y, effects.ColorFromCurrentPalette(y + hue));
if (waveCount == 2)
- effects.drawBackgroundFastLEDPixelCRGB(maxX - n, y, effects.ColorFromCurrentPalette(y + hue));
+ effects.setPixel(maxX - n, y, effects.ColorFromCurrentPalette(y + hue));
}
break;
}