Aurora example adopted for 256+ matrixes
Signed-off-by: Emil Muratov <gpm@hotplug.ru>
This commit is contained in:
parent
adaf7c8081
commit
ba58902843
13 changed files with 184 additions and 145 deletions
|
@ -36,10 +36,10 @@ Effects effects;
|
||||||
Patterns patterns;
|
Patterns patterns;
|
||||||
|
|
||||||
/* -------------------------- Some variables -------------------------- */
|
/* -------------------------- Some variables -------------------------- */
|
||||||
unsigned long ms_current = 0;
|
unsigned long fps = 0, fps_timer; // fps (this is NOT a matix refresh rate!)
|
||||||
unsigned long ms_previous = 0;
|
unsigned int default_fps = 30, pattern_fps = 30; // default fps limit (this is not a matix refresh conuter!)
|
||||||
unsigned long ms_animation_max_duration = 10000; // 10 seconds
|
unsigned long ms_animation_max_duration = 20000; // 20 seconds
|
||||||
unsigned long next_frame = 0;
|
unsigned long last_frame=0, ms_previous=0;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -58,40 +58,51 @@ void setup()
|
||||||
listPatterns();
|
listPatterns();
|
||||||
|
|
||||||
|
|
||||||
patterns.setPattern(0); // // simple noise
|
//patterns.setPattern(0); // // simple noise
|
||||||
patterns.start();
|
patterns.moveRandom(1); // start from a random pattern
|
||||||
|
|
||||||
Serial.print("Starting with pattern: ");
|
Serial.print("Starting with pattern: ");
|
||||||
Serial.println(patterns.getCurrentPatternName());
|
Serial.println(patterns.getCurrentPatternName());
|
||||||
|
patterns.start();
|
||||||
|
ms_previous = millis();
|
||||||
|
fps_timer = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// menu.run(mainMenuItems, mainMenuItemCount);
|
// menu.run(mainMenuItems, mainMenuItemCount);
|
||||||
ms_current = millis();
|
|
||||||
|
|
||||||
|
if ( (millis() - ms_previous) > ms_animation_max_duration )
|
||||||
if ( (ms_current - ms_previous) > ms_animation_max_duration )
|
|
||||||
{
|
{
|
||||||
// patterns.moveRandom(1);
|
|
||||||
|
|
||||||
patterns.stop();
|
patterns.stop();
|
||||||
patterns.move(1);
|
patterns.moveRandom(1);
|
||||||
|
//patterns.move(1);
|
||||||
patterns.start();
|
patterns.start();
|
||||||
|
|
||||||
|
|
||||||
Serial.print("Changing pattern to: ");
|
Serial.print("Changing pattern to: ");
|
||||||
Serial.println(patterns.getCurrentPatternName());
|
Serial.println(patterns.getCurrentPatternName());
|
||||||
|
|
||||||
ms_previous = ms_current;
|
ms_previous = millis();
|
||||||
|
|
||||||
// Select a random palette as well
|
// Select a random palette as well
|
||||||
//effects.RandomPalette();
|
//effects.RandomPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( next_frame < ms_current)
|
if ( 1000 / pattern_fps + last_frame < millis()){
|
||||||
next_frame = patterns.drawFrame() + ms_current;
|
last_frame = millis();
|
||||||
|
pattern_fps = patterns.drawFrame();
|
||||||
|
if (!pattern_fps)
|
||||||
|
pattern_fps = default_fps;
|
||||||
|
|
||||||
|
++fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fps_timer + 1000 < millis()){
|
||||||
|
Serial.printf_P(PSTR("Effect fps: %d\n"), fps);
|
||||||
|
fps_timer = millis();
|
||||||
|
fps = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,24 +33,43 @@
|
||||||
|
|
||||||
const int MATRIX_CENTER_X = MATRIX_WIDTH / 2;
|
const int MATRIX_CENTER_X = MATRIX_WIDTH / 2;
|
||||||
const int MATRIX_CENTER_Y = MATRIX_HEIGHT / 2;
|
const int MATRIX_CENTER_Y = MATRIX_HEIGHT / 2;
|
||||||
const byte MATRIX_CENTRE_X = MATRIX_CENTER_X - 1;
|
// US vs GB, huh? :)
|
||||||
const byte MATRIX_CENTRE_Y = MATRIX_CENTER_Y - 1;
|
//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
|
||||||
|
|
||||||
|
|
||||||
const uint16_t NUM_LEDS = (MATRIX_WIDTH * MATRIX_HEIGHT) + 1; // one led spare to capture out of bounds
|
const uint16_t NUM_LEDS = (MATRIX_WIDTH * MATRIX_HEIGHT) + 1; // one led spare to capture out of bounds
|
||||||
|
|
||||||
/* Convert x,y co-ordinate to flat array index.
|
/* 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
|
* 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: MATRIX_WIDTH-1 etc.
|
* (i.e. 64 pixels or 32 pixels.). Max value: MATRIX_WIDTH-1 etc.
|
||||||
|
* Ugh... uint8_t - really??? this weak method can't cope with 256+ pixel matrixes :(
|
||||||
*/
|
*/
|
||||||
uint16_t XY( uint8_t x, uint8_t y)
|
uint16_t XY( uint8_t x, uint8_t y)
|
||||||
{
|
{
|
||||||
if( x >= MATRIX_WIDTH || x < 0) return 0;
|
if( x >= MATRIX_WIDTH) return 0;
|
||||||
if( y >= MATRIX_HEIGHT || y < 0) return 0;
|
if( y >= MATRIX_HEIGHT) return 0;
|
||||||
|
|
||||||
return (y * MATRIX_WIDTH) + x + 1; // everything offset by one to capute out of bounds stuff - never displayed by ShowFrame()
|
return (y * MATRIX_WIDTH) + x + 1; // everything offset by one to capute out of bounds stuff - never displayed by ShowFrame()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This one is for 256+ matrixes
|
||||||
|
* otherwise this:
|
||||||
|
* for (uint8_t i = 0; i < MATRIX_WIDTH; i++) {}
|
||||||
|
* turns into an infinite loop
|
||||||
|
*/
|
||||||
|
uint16_t XY16( uint16_t x, uint16_t y)
|
||||||
|
{
|
||||||
|
if( x >= MATRIX_WIDTH) return 0;
|
||||||
|
if( y >= MATRIX_HEIGHT) return 0;
|
||||||
|
|
||||||
|
return (y * MATRIX_WIDTH) + x + 1; // everything offset by one to capute 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 beatcos8(accum88 beats_per_minute, uint8_t lowest = 0, uint8_t highest = 255, uint32_t timebase = 0, uint8_t phase_offset = 0)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +98,7 @@ uint8_t mapcos8(uint8_t theta, uint8_t lowest = 0, uint8_t highest = 255) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array of temperature readings at each simulation cell
|
// Array of temperature readings at each simulation cell
|
||||||
byte heat[NUM_LEDS];
|
//byte heat[NUM_LEDS]; // none of the currently enabled effects uses this
|
||||||
|
|
||||||
uint32_t noise_x;
|
uint32_t noise_x;
|
||||||
uint32_t noise_y;
|
uint32_t noise_y;
|
||||||
|
@ -92,10 +111,18 @@ uint8_t noisesmoothing;
|
||||||
|
|
||||||
class Effects {
|
class Effects {
|
||||||
public:
|
public:
|
||||||
//CRGB *leds;
|
CRGB *leds;
|
||||||
CRGB leds[NUM_LEDS];
|
//CRGB leds[NUM_LEDS];
|
||||||
//CRGB leds2[NUM_LEDS]; // Faptastic: getting rid of this and any dependant effects or algos. to save memory 24*64*32 bytes of ram (50k).
|
//CRGB leds2[NUM_LEDS]; // Faptastic: getting rid of this and any dependant effects or algos. to save memory 24*64*32 bytes of ram (50k).
|
||||||
|
|
||||||
|
Effects(){
|
||||||
|
// we do dynamic allocation for leds buffer, otherwise esp32 toolchain can't link static arrays of this size for 256+ matrixes
|
||||||
|
leds = (CRGB *)malloc(NUM_LEDS * sizeof(CRGB));
|
||||||
|
ClearFrame();
|
||||||
|
}
|
||||||
|
~Effects(){
|
||||||
|
free(leds);
|
||||||
|
}
|
||||||
|
|
||||||
/* The only 'framebuffer' we have is what is contained in the leds and leds2 variables.
|
/* The only 'framebuffer' we have is what is contained in the leds and leds2 variables.
|
||||||
* We don't store what the color a particular pixel might be, other than when it's turned
|
* We don't store what the color a particular pixel might be, other than when it's turned
|
||||||
|
@ -107,14 +134,13 @@ public:
|
||||||
void drawBackgroundFastLEDPixelCRGB(int16_t x, int16_t y, CRGB color)
|
void drawBackgroundFastLEDPixelCRGB(int16_t x, int16_t y, CRGB color)
|
||||||
{
|
{
|
||||||
leds[XY(x, y)] = color;
|
leds[XY(x, y)] = color;
|
||||||
matrix.drawPixelRGB888(x, y, color.r, color.g, color.b);
|
//matrix.drawPixelRGB888(x, y, color.r, color.g, color.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write one pixel with the specified color from the current palette to coordinates
|
// write one pixel with the specified color from the current palette to coordinates
|
||||||
void Pixel(int x, int y, uint8_t colorIndex) {
|
void Pixel(int x, int y, uint8_t colorIndex) {
|
||||||
CRGB temp = ColorFromCurrentPalette(colorIndex);
|
leds[XY(x, y)] = ColorFromCurrentPalette(colorIndex);
|
||||||
leds[XY(x, y)] = temp;
|
//matrix.drawPixelRGB888(x, y, temp.r, temp.g, temp.b); // now draw it?
|
||||||
matrix.drawPixelRGB888(x, y, temp.r, temp.g, temp.b); // now draw it?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareFrame() {
|
void PrepareFrame() {
|
||||||
|
@ -136,16 +162,10 @@ public:
|
||||||
for (int y=0;y<MATRIX_HEIGHT; y++)
|
for (int y=0;y<MATRIX_HEIGHT; y++)
|
||||||
for (int x=0;x<MATRIX_WIDTH; x++)
|
for (int x=0;x<MATRIX_WIDTH; x++)
|
||||||
{
|
{
|
||||||
|
|
||||||
CRGB tmp_led = leds[XY(x,y)];
|
|
||||||
|
|
||||||
//Serial.printf("\r\nFlushing x, y coord %d, %d", x, y);
|
//Serial.printf("\r\nFlushing x, y coord %d, %d", x, y);
|
||||||
//display.drawPixelRGB888( x, 31-y, tmp_led.r, tmp_led.g, tmp_led.b);
|
//display.drawPixelRGB888( x, 31-y, tmp_led.r, tmp_led.g, tmp_led.b);
|
||||||
matrix.drawPixelRGB888( x, y, tmp_led.r, tmp_led.g, tmp_led.b);
|
matrix.drawPixelRGB888( x, y, leds[XY16(x,y)].r, leds[XY16(x,y)].g, leds[XY16(x,y)].b);
|
||||||
|
|
||||||
} // end loop to copy fast led to the dma matrix
|
} // end loop to copy fast led to the dma matrix
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale the brightness of the screenbuffer down
|
// scale the brightness of the screenbuffer down
|
||||||
|
@ -159,7 +179,8 @@ public:
|
||||||
|
|
||||||
void ClearFrame()
|
void ClearFrame()
|
||||||
{
|
{
|
||||||
memset(leds, 0x00, sizeof(leds)); // flush
|
memset(leds, 0x00, NUM_LEDS * sizeof(CRGB)); // flush
|
||||||
|
matrix.clearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,9 +398,9 @@ public:
|
||||||
void Caleidoscope1() {
|
void Caleidoscope1() {
|
||||||
for (int x = 0; x < MATRIX_CENTER_X; x++) {
|
for (int x = 0; x < MATRIX_CENTER_X; x++) {
|
||||||
for (int y = 0; y < MATRIX_CENTER_Y; y++) {
|
for (int y = 0; y < MATRIX_CENTER_Y; y++) {
|
||||||
leds[XY(MATRIX_WIDTH - 1 - x, y)] = leds[XY(x, y)];
|
leds[XY16(MATRIX_WIDTH - 1 - x, y)] = leds[XY16(x, y)];
|
||||||
leds[XY(MATRIX_WIDTH - 1 - x, MATRIX_HEIGHT - 1 - y)] = leds[XY(x, y)];
|
leds[XY16(MATRIX_WIDTH - 1 - x, MATRIX_HEIGHT - 1 - y)] = leds[XY16(x, y)];
|
||||||
leds[XY(x, MATRIX_HEIGHT - 1 - y)] = leds[XY(x, y)];
|
leds[XY16(x, MATRIX_HEIGHT - 1 - y)] = leds[XY16(x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,9 +410,9 @@ public:
|
||||||
void Caleidoscope2() {
|
void Caleidoscope2() {
|
||||||
for (int x = 0; x < MATRIX_CENTER_X; x++) {
|
for (int x = 0; x < MATRIX_CENTER_X; x++) {
|
||||||
for (int y = 0; y < MATRIX_CENTER_Y; y++) {
|
for (int y = 0; y < MATRIX_CENTER_Y; y++) {
|
||||||
leds[XY(MATRIX_WIDTH - 1 - x, y)] = leds[XY(y, x)];
|
leds[XY16(MATRIX_WIDTH - 1 - x, y)] = leds[XY16(y, x)];
|
||||||
leds[XY(x, MATRIX_HEIGHT - 1 - y)] = leds[XY(y, x)];
|
leds[XY16(x, MATRIX_HEIGHT - 1 - y)] = leds[XY16(y, x)];
|
||||||
leds[XY(MATRIX_WIDTH - 1 - x, MATRIX_HEIGHT - 1 - y)] = leds[XY(x, y)];
|
leds[XY16(MATRIX_WIDTH - 1 - x, MATRIX_HEIGHT - 1 - y)] = leds[XY16(x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +421,7 @@ public:
|
||||||
void Caleidoscope3() {
|
void Caleidoscope3() {
|
||||||
for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
|
for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
|
||||||
for (int y = 0; y <= x; y++) {
|
for (int y = 0; y <= x; y++) {
|
||||||
leds[XY(x, y)] = leds[XY(y, x)];
|
leds[XY16(x, y)] = leds[XY16(y, x)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +430,7 @@ public:
|
||||||
void Caleidoscope4() {
|
void Caleidoscope4() {
|
||||||
for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
|
for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
|
||||||
for (int y = 0; y <= MATRIX_CENTRE_Y - x; y++) {
|
for (int y = 0; y <= MATRIX_CENTRE_Y - x; y++) {
|
||||||
leds[XY(MATRIX_CENTRE_Y - y, MATRIX_CENTRE_X - x)] = leds[XY(x, y)];
|
leds[XY16(MATRIX_CENTRE_Y - y, MATRIX_CENTRE_X - x)] = leds[XY16(x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,38 +439,38 @@ public:
|
||||||
void Caleidoscope5() {
|
void Caleidoscope5() {
|
||||||
for (int x = 0; x < MATRIX_WIDTH / 4; x++) {
|
for (int x = 0; x < MATRIX_WIDTH / 4; x++) {
|
||||||
for (int y = 0; y <= x; y++) {
|
for (int y = 0; y <= x; y++) {
|
||||||
leds[XY(x, y)] = leds[XY(y, x)];
|
leds[XY16(x, y)] = leds[XY16(y, x)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = MATRIX_WIDTH / 4; x < MATRIX_WIDTH / 2; x++) {
|
for (int x = MATRIX_WIDTH / 4; x < MATRIX_WIDTH / 2; x++) {
|
||||||
for (int y = MATRIX_HEIGHT / 4; y >= 0; y--) {
|
for (int y = MATRIX_HEIGHT / 4; y >= 0; y--) {
|
||||||
leds[XY(x, y)] = leds[XY(y, x)];
|
leds[XY16(x, y)] = leds[XY16(y, x)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Caleidoscope6() {
|
void Caleidoscope6() {
|
||||||
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 7)] = leds[XY(x, 0)];
|
leds[XY16(7 - x, 7)] = leds[XY16(x, 0)];
|
||||||
} //a
|
} //a
|
||||||
for (int x = 2; x < MATRIX_CENTER_X; x++) {
|
for (int x = 2; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 6)] = leds[XY(x, 1)];
|
leds[XY16(7 - x, 6)] = leds[XY16(x, 1)];
|
||||||
} //b
|
} //b
|
||||||
for (int x = 3; x < MATRIX_CENTER_X; x++) {
|
for (int x = 3; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 5)] = leds[XY(x, 2)];
|
leds[XY16(7 - x, 5)] = leds[XY16(x, 2)];
|
||||||
} //c
|
} //c
|
||||||
for (int x = 4; x < MATRIX_CENTER_X; x++) {
|
for (int x = 4; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 4)] = leds[XY(x, 3)];
|
leds[XY16(7 - x, 4)] = leds[XY16(x, 3)];
|
||||||
} //d
|
} //d
|
||||||
for (int x = 5; x < MATRIX_CENTER_X; x++) {
|
for (int x = 5; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 3)] = leds[XY(x, 4)];
|
leds[XY16(7 - x, 3)] = leds[XY16(x, 4)];
|
||||||
} //e
|
} //e
|
||||||
for (int x = 6; x < MATRIX_CENTER_X; x++) {
|
for (int x = 6; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 2)] = leds[XY(x, 5)];
|
leds[XY16(7 - x, 2)] = leds[XY16(x, 5)];
|
||||||
} //f
|
} //f
|
||||||
for (int x = 7; x < MATRIX_CENTER_X; x++) {
|
for (int x = 7; x < MATRIX_CENTER_X; x++) {
|
||||||
leds[XY(7 - x, 1)] = leds[XY(x, 6)];
|
leds[XY16(7 - x, 1)] = leds[XY16(x, 6)];
|
||||||
} //g
|
} //g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,20 +479,20 @@ public:
|
||||||
void SpiralStream(int x, int y, int r, byte dimm) {
|
void SpiralStream(int x, int y, int r, byte dimm) {
|
||||||
for (int d = r; d >= 0; d--) { // from the outside to the inside
|
for (int d = r; d >= 0; d--) { // from the outside to the inside
|
||||||
for (int i = x - d; i <= x + d; i++) {
|
for (int i = x - d; i <= x + d; i++) {
|
||||||
leds[XY(i, y - d)] += leds[XY(i + 1, y - d)]; // lowest row to the right
|
leds[XY16(i, y - d)] += leds[XY16(i + 1, y - d)]; // lowest row to the right
|
||||||
leds[XY(i, y - d)].nscale8(dimm);
|
leds[XY16(i, y - d)].nscale8(dimm);
|
||||||
}
|
}
|
||||||
for (int i = y - d; i <= y + d; i++) {
|
for (int i = y - d; i <= y + d; i++) {
|
||||||
leds[XY(x + d, i)] += leds[XY(x + d, i + 1)]; // right colum up
|
leds[XY16(x + d, i)] += leds[XY16(x + d, i + 1)]; // right colum up
|
||||||
leds[XY(x + d, i)].nscale8(dimm);
|
leds[XY16(x + d, i)].nscale8(dimm);
|
||||||
}
|
}
|
||||||
for (int i = x + d; i >= x - d; i--) {
|
for (int i = x + d; i >= x - d; i--) {
|
||||||
leds[XY(i, y + d)] += leds[XY(i - 1, y + d)]; // upper row to the left
|
leds[XY16(i, y + d)] += leds[XY16(i - 1, y + d)]; // upper row to the left
|
||||||
leds[XY(i, y + d)].nscale8(dimm);
|
leds[XY16(i, y + d)].nscale8(dimm);
|
||||||
}
|
}
|
||||||
for (int i = y + d; i >= y - d; i--) {
|
for (int i = y + d; i >= y - d; i--) {
|
||||||
leds[XY(x - d, i)] += leds[XY(x - d, i - 1)]; // left colum down
|
leds[XY16(x - d, i)] += leds[XY16(x - d, i - 1)]; // left colum down
|
||||||
leds[XY(x - d, i)].nscale8(dimm);
|
leds[XY16(x - d, i)].nscale8(dimm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,24 +515,24 @@ public:
|
||||||
while (a >= b)
|
while (a >= b)
|
||||||
{
|
{
|
||||||
// move them out one pixel on the radius
|
// move them out one pixel on the radius
|
||||||
leds[XY(a + centerX, b + centerY)] = leds[XY(nextA + centerX, nextB + centerY)];
|
leds[XY16(a + centerX, b + centerY)] = leds[XY16(nextA + centerX, nextB + centerY)];
|
||||||
leds[XY(b + centerX, a + centerY)] = leds[XY(nextB + centerX, nextA + centerY)];
|
leds[XY16(b + centerX, a + centerY)] = leds[XY16(nextB + centerX, nextA + centerY)];
|
||||||
leds[XY(-a + centerX, b + centerY)] = leds[XY(-nextA + centerX, nextB + centerY)];
|
leds[XY16(-a + centerX, b + centerY)] = leds[XY16(-nextA + centerX, nextB + centerY)];
|
||||||
leds[XY(-b + centerX, a + centerY)] = leds[XY(-nextB + centerX, nextA + centerY)];
|
leds[XY16(-b + centerX, a + centerY)] = leds[XY16(-nextB + centerX, nextA + centerY)];
|
||||||
leds[XY(-a + centerX, -b + centerY)] = leds[XY(-nextA + centerX, -nextB + centerY)];
|
leds[XY16(-a + centerX, -b + centerY)] = leds[XY16(-nextA + centerX, -nextB + centerY)];
|
||||||
leds[XY(-b + centerX, -a + centerY)] = leds[XY(-nextB + centerX, -nextA + centerY)];
|
leds[XY16(-b + centerX, -a + centerY)] = leds[XY16(-nextB + centerX, -nextA + centerY)];
|
||||||
leds[XY(a + centerX, -b + centerY)] = leds[XY(nextA + centerX, -nextB + centerY)];
|
leds[XY16(a + centerX, -b + centerY)] = leds[XY16(nextA + centerX, -nextB + centerY)];
|
||||||
leds[XY(b + centerX, -a + centerY)] = leds[XY(nextB + centerX, -nextA + centerY)];
|
leds[XY16(b + centerX, -a + centerY)] = leds[XY16(nextB + centerX, -nextA + centerY)];
|
||||||
|
|
||||||
// dim them
|
// dim them
|
||||||
leds[XY(a + centerX, b + centerY)].nscale8(dimm);
|
leds[XY16(a + centerX, b + centerY)].nscale8(dimm);
|
||||||
leds[XY(b + centerX, a + centerY)].nscale8(dimm);
|
leds[XY16(b + centerX, a + centerY)].nscale8(dimm);
|
||||||
leds[XY(-a + centerX, b + centerY)].nscale8(dimm);
|
leds[XY16(-a + centerX, b + centerY)].nscale8(dimm);
|
||||||
leds[XY(-b + centerX, a + centerY)].nscale8(dimm);
|
leds[XY16(-b + centerX, a + centerY)].nscale8(dimm);
|
||||||
leds[XY(-a + centerX, -b + centerY)].nscale8(dimm);
|
leds[XY16(-a + centerX, -b + centerY)].nscale8(dimm);
|
||||||
leds[XY(-b + centerX, -a + centerY)].nscale8(dimm);
|
leds[XY16(-b + centerX, -a + centerY)].nscale8(dimm);
|
||||||
leds[XY(a + centerX, -b + centerY)].nscale8(dimm);
|
leds[XY16(a + centerX, -b + centerY)].nscale8(dimm);
|
||||||
leds[XY(b + centerX, -a + centerY)].nscale8(dimm);
|
leds[XY16(b + centerX, -a + centerY)].nscale8(dimm);
|
||||||
|
|
||||||
b++;
|
b++;
|
||||||
if (radiusError < 0)
|
if (radiusError < 0)
|
||||||
|
@ -541,12 +562,12 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = fromX + 1; x < toX; x++) {
|
for (int x = fromX + 1; x < toX; x++) {
|
||||||
for (int y = fromY; y < toY; y++) {
|
for (int y = fromY; y < toY; y++) {
|
||||||
leds[XY(x, y)] += leds[XY(x - 1, y)];
|
leds[XY16(x, y)] += leds[XY16(x - 1, y)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int y = fromY; y < toY; y++)
|
for (int y = fromY; y < toY; y++)
|
||||||
leds[XY(0, y)].nscale8(scale);
|
leds[XY16(0, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a linear tail to the left
|
// give it a linear tail to the left
|
||||||
|
@ -554,12 +575,12 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = toX; x < fromX; x++) {
|
for (int x = toX; x < fromX; x++) {
|
||||||
for (int y = fromY; y < toY; y++) {
|
for (int y = fromY; y < toY; y++) {
|
||||||
leds[XY(x, y)] += leds[XY(x + 1, y)];
|
leds[XY16(x, y)] += leds[XY16(x + 1, y)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int y = fromY; y < toY; y++)
|
for (int y = fromY; y < toY; y++)
|
||||||
leds[XY(0, y)].nscale8(scale);
|
leds[XY16(0, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a linear tail downwards
|
// give it a linear tail downwards
|
||||||
|
@ -567,12 +588,12 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
for (int y = 1; y < MATRIX_HEIGHT; y++) {
|
for (int y = 1; y < MATRIX_HEIGHT; y++) {
|
||||||
leds[XY(x, y)] += leds[XY(x, y - 1)];
|
leds[XY16(x, y)] += leds[XY16(x, y - 1)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
leds[XY(x, 0)].nscale8(scale);
|
leds[XY16(x, 0)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a linear tail upwards
|
// give it a linear tail upwards
|
||||||
|
@ -580,12 +601,12 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
||||||
leds[XY(x, y)] += leds[XY(x, y + 1)];
|
leds[XY16(x, y)] += leds[XY16(x, y + 1)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
leds[XY(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
leds[XY16(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a linear tail up and to the left
|
// give it a linear tail up and to the left
|
||||||
|
@ -593,14 +614,14 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MATRIX_WIDTH - 1; x++) {
|
for (int x = 0; x < MATRIX_WIDTH - 1; x++) {
|
||||||
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
||||||
leds[XY(x, y)] += leds[XY(x + 1, y + 1)];
|
leds[XY16(x, y)] += leds[XY16(x + 1, y + 1)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
leds[XY(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
leds[XY16(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
||||||
for (int y = 0; y < MATRIX_HEIGHT; y++)
|
for (int y = 0; y < MATRIX_HEIGHT; y++)
|
||||||
leds[XY(MATRIX_WIDTH - 1, y)].nscale8(scale);
|
leds[XY16(MATRIX_WIDTH - 1, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a linear tail up and to the right
|
// give it a linear tail up and to the right
|
||||||
|
@ -608,24 +629,24 @@ public:
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MATRIX_WIDTH - 1; x++) {
|
for (int x = 0; x < MATRIX_WIDTH - 1; x++) {
|
||||||
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) {
|
||||||
leds[XY(x + 1, y)] += leds[XY(x, y + 1)];
|
leds[XY16(x + 1, y)] += leds[XY16(x, y + 1)];
|
||||||
leds[XY(x, y)].nscale8(scale);
|
leds[XY16(x, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fade the bottom row
|
// fade the bottom row
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
leds[XY(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
leds[XY16(x, MATRIX_HEIGHT - 1)].nscale8(scale);
|
||||||
|
|
||||||
// fade the right column
|
// fade the right column
|
||||||
for (int y = 0; y < MATRIX_HEIGHT; y++)
|
for (int y = 0; y < MATRIX_HEIGHT; y++)
|
||||||
leds[XY(MATRIX_WIDTH - 1, y)].nscale8(scale);
|
leds[XY16(MATRIX_WIDTH - 1, y)].nscale8(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// just move everything one line down
|
// just move everything one line down
|
||||||
void MoveDown() {
|
void MoveDown() {
|
||||||
for (int y = MATRIX_HEIGHT - 1; y > 0; y--) {
|
for (int y = MATRIX_HEIGHT - 1; y > 0; y--) {
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
leds[XY(x, y)] = leds[XY(x, y - 1)];
|
leds[XY16(x, y)] = leds[XY16(x, y - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +655,7 @@ public:
|
||||||
void VerticalMoveFrom(int start, int end) {
|
void VerticalMoveFrom(int start, int end) {
|
||||||
for (int y = end; y > start; y--) {
|
for (int y = end; y > start; y--) {
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
for (int x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
leds[XY(x, y)] = leds[XY(x, y - 1)];
|
leds[XY16(x, y)] = leds[XY16(x, y - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,7 +665,7 @@ public:
|
||||||
void Copy(byte x0, byte y0, byte x1, byte y1, byte x2, byte y2) {
|
void Copy(byte x0, byte y0, byte x1, byte y1, byte x2, byte y2) {
|
||||||
for (int y = y0; y < y1 + 1; y++) {
|
for (int y = y0; y < y1 + 1; y++) {
|
||||||
for (int x = x0; x < x1 + 1; x++) {
|
for (int x = x0; x < x1 + 1; x++) {
|
||||||
leds[XY(x + x2 - x0, y + y2 - y0)] = leds[XY(x, y)];
|
leds[XY16(x + x2 - x0, y + y2 - y0)] = leds[XY16(x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -653,7 +674,7 @@ public:
|
||||||
void RotateTriangle() {
|
void RotateTriangle() {
|
||||||
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
||||||
for (int y = 0; y < x; y++) {
|
for (int y = 0; y < x; y++) {
|
||||||
leds[XY(x, 7 - y)] = leds[XY(7 - x, y)];
|
leds[XY16(x, 7 - y)] = leds[XY16(7 - x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,7 +683,7 @@ public:
|
||||||
void MirrorTriangle() {
|
void MirrorTriangle() {
|
||||||
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
for (int x = 1; x < MATRIX_CENTER_X; x++) {
|
||||||
for (int y = 0; y < x; y++) {
|
for (int y = 0; y < x; y++) {
|
||||||
leds[XY(7 - y, x)] = leds[XY(7 - x, y)];
|
leds[XY16(7 - y, x)] = leds[XY16(7 - x, y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,7 +709,7 @@ public:
|
||||||
int dy = -abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
|
int dy = -abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
|
||||||
int err = dx + dy, e2;
|
int err = dx + dy, e2;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
leds[XY(x0, y0)] += color;
|
leds[XY16(x0, y0)] += color;
|
||||||
if (x0 == x1 && y0 == y1) break;
|
if (x0 == x1 && y0 == y1) break;
|
||||||
e2 = 2 * err;
|
e2 = 2 * err;
|
||||||
if (e2 > dy) {
|
if (e2 > dy) {
|
||||||
|
@ -732,10 +753,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillNoise() {
|
void FillNoise() {
|
||||||
for (uint8_t i = 0; i < MATRIX_WIDTH; i++) {
|
for (uint16_t i = 0; i < MATRIX_WIDTH; i++) {
|
||||||
uint32_t ioffset = noise_scale_x * (i - MATRIX_CENTRE_Y);
|
uint32_t ioffset = noise_scale_x * (i - MATRIX_CENTRE_Y);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < MATRIX_HEIGHT; j++) {
|
for (uint16_t j = 0; j < MATRIX_HEIGHT; j++) {
|
||||||
uint32_t joffset = noise_scale_y * (j - MATRIX_CENTRE_Y);
|
uint32_t joffset = noise_scale_y * (j - MATRIX_CENTRE_Y);
|
||||||
|
|
||||||
byte data = inoise16(noise_x + ioffset, noise_y + joffset, noise_z) >> 8;
|
byte data = inoise16(noise_x + ioffset, noise_y + joffset, noise_z) >> 8;
|
||||||
|
@ -761,16 +782,16 @@ public:
|
||||||
// Shift Left: https://codedost.com/c/arraypointers-in-c/c-program-shift-elements-array-left-direction/
|
// Shift Left: https://codedost.com/c/arraypointers-in-c/c-program-shift-elements-array-left-direction/
|
||||||
// Computationally heavier but doesn't need an entire leds2 array
|
// Computationally heavier but doesn't need an entire leds2 array
|
||||||
|
|
||||||
tmp = leds[XY(0, y)];
|
tmp = leds[XY16(0, y)];
|
||||||
for (int m = 0; m < delta; m++)
|
for (int m = 0; m < delta; m++)
|
||||||
{
|
{
|
||||||
// Do this delta time for each row... computationally expensive potentially.
|
// Do this delta time for each row... computationally expensive potentially.
|
||||||
for(int x = 0; x < MATRIX_WIDTH; x++)
|
for(int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
{
|
{
|
||||||
leds[XY(x, y)] = leds [XY(x+1, y)];
|
leds[XY16(x, y)] = leds [XY16(x+1, y)];
|
||||||
}
|
}
|
||||||
|
|
||||||
leds[XY(MATRIX_WIDTH-1, y)] = tmp;
|
leds[XY16(MATRIX_WIDTH-1, y)] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -803,16 +824,16 @@ public:
|
||||||
CRGB tmp = 0;
|
CRGB tmp = 0;
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; x++)
|
||||||
{
|
{
|
||||||
tmp = leds[XY(x, 0)];
|
tmp = leds[XY16(x, 0)];
|
||||||
for (int m = 0; m < delta; m++) // moves
|
for (int m = 0; m < delta; m++) // moves
|
||||||
{
|
{
|
||||||
// Do this delta time for each row... computationally expensive potentially.
|
// Do this delta time for each row... computationally expensive potentially.
|
||||||
for(int y = 0; y < MATRIX_HEIGHT; y++)
|
for(int y = 0; y < MATRIX_HEIGHT; y++)
|
||||||
{
|
{
|
||||||
leds[XY(x, y)] = leds [XY(x, y+1)];
|
leds[XY16(x, y)] = leds [XY16(x, y+1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
leds[XY(x, MATRIX_HEIGHT-1)] = tmp;
|
leds[XY16(x, MATRIX_HEIGHT-1)] = tmp;
|
||||||
}
|
}
|
||||||
} // end column loop
|
} // end column loop
|
||||||
} /// MoveY
|
} /// MoveY
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
// dim all pixels on the display
|
// dim all pixels on the display
|
||||||
uint8_t dim = beatsin8(2, 170, 250);
|
uint8_t dim = beatsin8(2, 170, 250);
|
||||||
effects.DimAll(dim); effects.ShowFrame();
|
effects.DimAll(dim);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Boid boid = boids[i];
|
Boid boid = boids[i];
|
||||||
|
@ -66,7 +66,8 @@ public:
|
||||||
boids[i] = boid;
|
boids[i] = boid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 15;
|
effects.ShowFrame();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,13 @@ class PatternElectricMandala : public Drawable {
|
||||||
|
|
||||||
effects.ShowFrame();
|
effects.ShowFrame();
|
||||||
|
|
||||||
return 0;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show just one layer
|
// show just one layer
|
||||||
void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) {
|
void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) {
|
||||||
for (uint8_t i = 0; i < MATRIX_WIDTH; i++) {
|
for (uint16_t i = 0; i < MATRIX_WIDTH; i++) {
|
||||||
for (uint8_t j = 0; j < MATRIX_HEIGHT; j++) {
|
for (uint16_t j = 0; j < MATRIX_HEIGHT; j++) {
|
||||||
|
|
||||||
uint8_t color = noise[i][j];
|
uint8_t color = noise[i][j];
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class PatternElectricMandala : public Drawable {
|
||||||
// assign a color depending on the actual palette
|
// assign a color depending on the actual palette
|
||||||
CRGB pixel = ColorFromPalette(effects.currentPalette, colorrepeat * (color + colorshift), bri);
|
CRGB pixel = ColorFromPalette(effects.currentPalette, colorrepeat * (color + colorshift), bri);
|
||||||
|
|
||||||
effects.leds[XY(i, j)] = pixel;
|
effects.leds[XY16(i, j)] = pixel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ public:
|
||||||
if (algorithm >= algorithmCount)
|
if (algorithm >= algorithmCount)
|
||||||
algorithm = 0;
|
algorithm = 0;
|
||||||
|
|
||||||
return 1000;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
effects.ShowFrame();
|
effects.ShowFrame();
|
||||||
|
@ -255,7 +255,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
matrix.fillScreen(0);
|
effects.ClearFrame();
|
||||||
cellCount = 0;
|
cellCount = 0;
|
||||||
hue = 0;
|
hue = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ public:
|
||||||
|
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
|
|
||||||
for (byte x = 0; x < MATRIX_WIDTH; x++) {
|
for (uint16_t x = 0; x < MATRIX_WIDTH; x++) {
|
||||||
for (byte y = 0; y < MATRIX_HEIGHT; y++) {
|
for (uint16_t y = 0; y < MATRIX_HEIGHT; y++) {
|
||||||
effects.leds[XY(x, y)] = (x ^ y ^ flip) < count ? effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) : CRGB::Black;
|
effects.leds[XY16(x, y)] = (x ^ y ^ flip) < count ? effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) : CRGB::Black;
|
||||||
|
|
||||||
// The below is more pleasant
|
// The below is more pleasant
|
||||||
// effects.leds[XY(x, y)] = effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) ;
|
// effects.leds[XY(x, y)] = effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) ;
|
||||||
|
@ -66,7 +66,6 @@ public:
|
||||||
|
|
||||||
// show it ffs!
|
// show it ffs!
|
||||||
effects.ShowFrame();
|
effects.ShowFrame();
|
||||||
|
|
||||||
return 60;
|
return 60;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,7 @@ class PatternPendulumWave : public Drawable {
|
||||||
effects.drawBackgroundFastLEDPixelCRGB(x, y, effects.ColorFromCurrentPalette(x * 7));
|
effects.drawBackgroundFastLEDPixelCRGB(x, y, effects.ColorFromCurrentPalette(x * 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 15;
|
return 10;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,17 +60,17 @@ class PatternSimplexNoise : public Drawable {
|
||||||
|
|
||||||
effects.ShowFrame();
|
effects.ShowFrame();
|
||||||
|
|
||||||
return 0;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show just one layer
|
// show just one layer
|
||||||
void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) {
|
void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) {
|
||||||
for (uint8_t i = 0; i < MATRIX_WIDTH; i++) {
|
for (uint16_t i = 0; i < MATRIX_WIDTH; i++) {
|
||||||
for (uint8_t j = 0; j < MATRIX_HEIGHT; j++) {
|
for (uint16_t j = 0; j < MATRIX_HEIGHT; j++) {
|
||||||
uint8_t pixel = noise[i][j];
|
uint8_t pixel = noise[i][j];
|
||||||
|
|
||||||
// assign a color depending on the actual palette
|
// assign a color depending on the actual palette
|
||||||
effects.leds[XY(i, j)] = effects.ColorFromCurrentPalette(colorrepeat * (pixel + colorshift), pixel);
|
effects.leds[XY16(i, j)] = effects.ColorFromCurrentPalette(colorrepeat * (pixel + colorshift), pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class PatternSpiro : public Drawable {
|
||||||
|
|
||||||
uint8_t spirocount = 1;
|
uint8_t spirocount = 1;
|
||||||
uint8_t spirooffset = 256 / spirocount;
|
uint8_t spirooffset = 256 / spirocount;
|
||||||
boolean spiroincrement = false;
|
boolean spiroincrement = true;
|
||||||
|
|
||||||
boolean handledChange = false;
|
boolean handledChange = false;
|
||||||
|
|
||||||
|
@ -46,8 +46,12 @@ class PatternSpiro : public Drawable {
|
||||||
name = (char *)"Spiro";
|
name = (char *)"Spiro";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void start(){
|
||||||
|
effects.ClearFrame();
|
||||||
|
};
|
||||||
|
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
effects.DimAll(254); effects.ShowFrame();
|
effects.DimAll(1);
|
||||||
|
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
|
|
||||||
|
@ -100,6 +104,7 @@ class PatternSpiro : public Drawable {
|
||||||
hueoffset += 1;
|
hueoffset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
effects.ShowFrame();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,7 @@ class PatternSwirl : public Drawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
|
effects.ClearFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
|
@ -52,8 +53,8 @@ class PatternSwirl : public Drawable {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use two out-of-sync sine waves
|
// Use two out-of-sync sine waves
|
||||||
uint8_t i = beatsin8(27, borderWidth, MATRIX_HEIGHT - borderWidth);
|
uint8_t i = beatsin8(13, borderWidth, MATRIX_HEIGHT - borderWidth);
|
||||||
uint8_t j = beatsin8(41, borderWidth, MATRIX_WIDTH - borderWidth);
|
uint8_t j = beatsin8(27, borderWidth, MATRIX_WIDTH - borderWidth);
|
||||||
// Also calculate some reflections
|
// Also calculate some reflections
|
||||||
uint8_t ni = (MATRIX_WIDTH - 1) - i;
|
uint8_t ni = (MATRIX_WIDTH - 1) - i;
|
||||||
uint8_t nj = (MATRIX_WIDTH - 1) - j;
|
uint8_t nj = (MATRIX_WIDTH - 1) - j;
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PatternTest : public Drawable {
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
|
|
||||||
matrix.fillScreen(matrix.color565(128, 0, 0));
|
matrix.fillScreen(matrix.color565(128, 0, 0));
|
||||||
|
return 1000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Patterns : public Playlist {
|
||||||
PatternSwirl swirl;
|
PatternSwirl swirl;
|
||||||
PatternPendulumWave pendulumWave;
|
PatternPendulumWave pendulumWave;
|
||||||
PatternFlowField flowField;
|
PatternFlowField flowField;
|
||||||
PatternIncrementalDrift incrementalDrift;
|
// PatternIncrementalDrift incrementalDrift;
|
||||||
// PatternIncrementalDrift2 incrementalDrift2;
|
// PatternIncrementalDrift2 incrementalDrift2;
|
||||||
PatternMunch munch;
|
PatternMunch munch;
|
||||||
PatternElectricMandala electricMandala;
|
PatternElectricMandala electricMandala;
|
||||||
|
@ -114,7 +114,7 @@ class Patterns : public Playlist {
|
||||||
|
|
||||||
//const static int PATTERN_COUNT = 37;
|
//const static int PATTERN_COUNT = 37;
|
||||||
|
|
||||||
const static int PATTERN_COUNT = 17;
|
const static int PATTERN_COUNT = 16;
|
||||||
|
|
||||||
Drawable* shuffledItems[PATTERN_COUNT];
|
Drawable* shuffledItems[PATTERN_COUNT];
|
||||||
|
|
||||||
|
@ -132,7 +132,8 @@ class Patterns : public Playlist {
|
||||||
&life, // ok
|
&life, // ok
|
||||||
&flowField,
|
&flowField,
|
||||||
&pendulumWave, //11 ok
|
&pendulumWave, //11 ok
|
||||||
&incrementalDrift, //12 ok
|
|
||||||
|
// &incrementalDrift, //12 ok
|
||||||
// &incrementalDrift2, // 13 fail
|
// &incrementalDrift2, // 13 fail
|
||||||
&munch, // 14 ok
|
&munch, // 14 ok
|
||||||
&electricMandala, // 15 ok
|
&electricMandala, // 15 ok
|
||||||
|
|
|
@ -36,7 +36,7 @@ MatrixPanel_I2S_DMA dma_display;
|
||||||
#define CH_B 19
|
#define CH_B 19
|
||||||
#define CH_C 5
|
#define CH_C 5
|
||||||
#define CH_D 17
|
#define CH_D 17
|
||||||
#define CH_E 32 // assign to any available pin if using two panels or 64x64 panels with 1/32 scan
|
#define CH_E -1 // assign to any available pin if using two panels or 64x64 panels with 1/32 scan (i.e. 32 works fine)
|
||||||
#define CLK 16
|
#define CLK 16
|
||||||
#define LAT 4
|
#define LAT 4
|
||||||
#define OE 15
|
#define OE 15
|
||||||
|
@ -91,6 +91,6 @@ void loop(){
|
||||||
if (cycles >= 1024) {
|
if (cycles >= 1024) {
|
||||||
time_counter = 0;
|
time_counter = 0;
|
||||||
cycles = 0;
|
cycles = 0;
|
||||||
currentPalette = palettes[random(0,sizeof(palettes))];
|
currentPalette = palettes[random(0,sizeof(palettes)/sizeof(palettes[0]))];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue