Merge branch 'master' of https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA
This commit is contained in:
commit
c72dbb1360
14 changed files with 233 additions and 169 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 ( (ms_current - ms_previous) > ms_animation_max_duration )
|
|
||||||
{
|
|
||||||
// patterns.moveRandom(1);
|
|
||||||
|
|
||||||
|
if ( (millis() - ms_previous) > ms_animation_max_duration )
|
||||||
|
{
|
||||||
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: %ld\n"), fps);
|
||||||
|
fps_timer = millis();
|
||||||
|
fps = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,22 +33,40 @@
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
// forward declaration
|
||||||
|
uint16_t XY16( uint16_t x, uint16_t y);
|
||||||
|
|
||||||
/* 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;
|
return XY16(x, y);
|
||||||
if( y >= MATRIX_HEIGHT || y < 0) return 0;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The one 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()
|
return (y * MATRIX_WIDTH) + x + 1; // everything offset by one to capute out of bounds stuff - never displayed by ShowFrame()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +97,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;
|
||||||
|
@ -87,15 +105,37 @@ uint32_t noise_z;
|
||||||
uint32_t noise_scale_x;
|
uint32_t noise_scale_x;
|
||||||
uint32_t noise_scale_y;
|
uint32_t noise_scale_y;
|
||||||
|
|
||||||
uint8_t noise[MATRIX_WIDTH][MATRIX_HEIGHT];
|
//uint8_t noise[MATRIX_WIDTH][MATRIX_HEIGHT];
|
||||||
|
uint8_t **noise = nullptr; // we will allocate mem later
|
||||||
uint8_t noisesmoothing;
|
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 such a big size for 256+ matrixes
|
||||||
|
leds = (CRGB *)malloc(NUM_LEDS * sizeof(CRGB));
|
||||||
|
|
||||||
|
// allocate mem for noise effect
|
||||||
|
// (there should be some guards for malloc errors eventually)
|
||||||
|
noise = (uint8_t **)malloc(MATRIX_WIDTH * sizeof(uint8_t *));
|
||||||
|
for (int i = 0; i < MATRIX_WIDTH; ++i) {
|
||||||
|
noise[i] = (uint8_t *)malloc(MATRIX_HEIGHT * sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearFrame();
|
||||||
|
matrix.clearScreen();
|
||||||
|
}
|
||||||
|
~Effects(){
|
||||||
|
free(leds);
|
||||||
|
for (int i = 0; i < MATRIX_WIDTH; ++i) {
|
||||||
|
free(noise[i]);
|
||||||
|
}
|
||||||
|
free(noise);
|
||||||
|
}
|
||||||
|
|
||||||
/* 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 +147,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() {
|
||||||
|
@ -132,20 +171,13 @@ public:
|
||||||
// leds = (CRGB*) backgroundLayer.backBuffer();
|
// leds = (CRGB*) backgroundLayer.backBuffer();
|
||||||
// LEDS.countFPS();
|
// LEDS.countFPS();
|
||||||
|
|
||||||
|
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++)
|
//Serial.printf("Flushing x, y coord %d, %d\n", x, y);
|
||||||
{
|
uint16_t _pixel = XY16(x,y);
|
||||||
|
matrix.drawPixelRGB888( x, y, leds[_pixel].r, leds[_pixel].g, leds[_pixel].b);
|
||||||
CRGB tmp_led = leds[XY(x,y)];
|
} // end loop to copy fast led to the dma matrix
|
||||||
|
}
|
||||||
//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);
|
|
||||||
matrix.drawPixelRGB888( x, y, tmp_led.r, tmp_led.g, tmp_led.b);
|
|
||||||
|
|
||||||
} // 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 +191,7 @@ public:
|
||||||
|
|
||||||
void ClearFrame()
|
void ClearFrame()
|
||||||
{
|
{
|
||||||
memset(leds, 0x00, sizeof(leds)); // flush
|
memset(leds, 0x00, NUM_LEDS * sizeof(CRGB)); // flush
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,9 +409,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,18 +421,18 @@ 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)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy one diagonal triangle into the other one within a 16x16
|
// copy one diagonal triangle into the other one within a 16x16
|
||||||
void Caleidoscope3() {
|
void Caleidoscope3() {
|
||||||
for (int x = 0; x <= MATRIX_CENTRE_X; x++) {
|
for (int x = 0; x <= MATRIX_CENTRE_X && x < MATRIX_HEIGHT; x++) {
|
||||||
for (int y = 0; y <= x; y++) {
|
for (int y = 0; y <= x && y<MATRIX_HEIGHT; y++) {
|
||||||
leds[XY(x, y)] = leds[XY(y, x)];
|
leds[XY16(x, y)] = leds[XY16(y, x)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +441,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)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,39 +449,39 @@ public:
|
||||||
// copy one diagonal triangle into the other one within a 8x8
|
// copy one diagonal triangle into the other one within a 8x8
|
||||||
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<=MATRIX_HEIGHT; 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 +490,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 +526,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 +573,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 +586,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 +599,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 +612,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 +625,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 +640,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 +666,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 +676,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 +685,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 +694,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 +720,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 +764,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 +793,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 +835,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ public:
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
// dim all pixels on the display slightly
|
// dim all pixels on the display slightly
|
||||||
// to 250/255 (98%) of their current brightness
|
// to 250/255 (98%) of their current brightness
|
||||||
effects.DimAll(250); effects.ShowFrame();
|
blur2d(effects.leds, MATRIX_WIDTH > 255 ? 255 : MATRIX_WIDTH, MATRIX_HEIGHT > 255 ? 255 : MATRIX_HEIGHT, 250);
|
||||||
|
// effects.DimAll(250); effects.ShowFrame();
|
||||||
|
|
||||||
|
|
||||||
// the Effects class has some sample oscillators
|
// the Effects class has some sample oscillators
|
||||||
// that move from 0 to 255 at different speeds
|
// that move from 0 to 255 at different speeds
|
||||||
|
@ -51,7 +53,8 @@ public:
|
||||||
// draw a pixel at x,y using a color from the current palette
|
// draw a pixel at x,y using a color from the current palette
|
||||||
effects.Pixel(x, y, hue);
|
effects.Pixel(x, y, hue);
|
||||||
|
|
||||||
return 15;
|
effects.ShowFrame();
|
||||||
|
return 30;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
#ifndef PatternPendulumWave_H
|
#ifndef PatternPendulumWave_H
|
||||||
#define PatternPendulumWave_H
|
#define PatternPendulumWave_H
|
||||||
|
|
||||||
|
#define WAVE_BPM 25
|
||||||
|
#define AMP_BPM 2
|
||||||
|
#define SKEW_BPM 4
|
||||||
|
#define WAVE_TIMEMINSKEW MATRIX_WIDTH/8
|
||||||
|
#define WAVE_TIMEMAXSKEW MATRIX_WIDTH/2
|
||||||
|
|
||||||
class PatternPendulumWave : public Drawable {
|
class PatternPendulumWave : public Drawable {
|
||||||
public:
|
public:
|
||||||
PatternPendulumWave() {
|
PatternPendulumWave() {
|
||||||
|
@ -41,15 +47,19 @@ class PatternPendulumWave : public Drawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int drawFrame() {
|
unsigned int drawFrame() {
|
||||||
effects.DimAll(170); effects.ShowFrame();
|
effects.ClearFrame();
|
||||||
|
|
||||||
for (int x = 0; x < MATRIX_WIDTH; x++)
|
for (int x = 0; x < MATRIX_WIDTH; ++x)
|
||||||
{
|
{
|
||||||
uint8_t y = beatsin8(x + MATRIX_WIDTH, 0, MATRIX_HEIGHT);
|
uint16_t amp = beatsin16(AMP_BPM, MATRIX_HEIGHT/8, MATRIX_HEIGHT-1);
|
||||||
|
uint16_t offset = (MATRIX_HEIGHT - beatsin16(AMP_BPM, 0, MATRIX_HEIGHT))/2;
|
||||||
|
|
||||||
|
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.drawBackgroundFastLEDPixelCRGB(x, y, effects.ColorFromCurrentPalette(x * 7));
|
||||||
}
|
}
|
||||||
|
effects.ShowFrame();
|
||||||
return 15;
|
return 20;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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();
|
blur2d(effects.leds, MATRIX_WIDTH > 255 ? 255 : MATRIX_WIDTH, MATRIX_HEIGHT > 255 ? 255 : MATRIX_HEIGHT, 192);
|
||||||
|
|
||||||
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() {
|
||||||
|
@ -43,27 +44,28 @@ class PatternSwirl : public Drawable {
|
||||||
// Note that we never actually clear the matrix, we just constantly
|
// Note that we never actually clear the matrix, we just constantly
|
||||||
// blur it repeatedly. Since the blurring is 'lossy', there's
|
// blur it repeatedly. Since the blurring is 'lossy', there's
|
||||||
// an automatic trend toward black -- by design.
|
// an automatic trend toward black -- by design.
|
||||||
uint8_t blurAmount = beatsin8(2, 10, 255);
|
uint8_t blurAmount = beatsin8(2, 10, 255)
|
||||||
|
|
||||||
#if FASTLED_VERSION >= 3001000
|
#if FASTLED_VERSION >= 3001000
|
||||||
blur2d(effects.leds, MATRIX_WIDTH, MATRIX_HEIGHT, blurAmount);
|
blur2d(effects.leds, MATRIX_WIDTH > 255 ? 255 : MATRIX_WIDTH, MATRIX_HEIGHT > 255 ? 255 : MATRIX_HEIGHT, blurAmount);
|
||||||
#else
|
#else
|
||||||
effects.DimAll(blurAmount);
|
effects.DimAll(blurAmount);
|
||||||
#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(256/MATRIX_HEIGHT, borderWidth, MATRIX_WIDTH - borderWidth);
|
||||||
uint8_t j = beatsin8(41, borderWidth, MATRIX_WIDTH - borderWidth);
|
uint8_t j = beatsin8(2048/MATRIX_WIDTH, borderWidth, MATRIX_HEIGHT - 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_HEIGHT - 1) - j;
|
||||||
|
|
||||||
// The color of each point shifts over time, each at a different speed.
|
// The color of each point shifts over time, each at a different speed.
|
||||||
uint16_t ms = millis();
|
uint16_t ms = millis();
|
||||||
effects.leds[XY(i, j)] += effects.ColorFromCurrentPalette(ms / 11);
|
effects.leds[XY(i, j)] += effects.ColorFromCurrentPalette(ms / 11);
|
||||||
effects.leds[XY(j, i)] += effects.ColorFromCurrentPalette(ms / 13);
|
//effects.leds[XY(j, i)] += effects.ColorFromCurrentPalette(ms / 13); // this doesn't work for non-square matrixes
|
||||||
effects.leds[XY(ni, nj)] += effects.ColorFromCurrentPalette(ms / 17);
|
effects.leds[XY(ni, nj)] += effects.ColorFromCurrentPalette(ms / 17);
|
||||||
effects.leds[XY(nj, ni)] += effects.ColorFromCurrentPalette(ms / 29);
|
//effects.leds[XY(nj, ni)] += effects.ColorFromCurrentPalette(ms / 29); // this doesn't work for non-square matrixes
|
||||||
effects.leds[XY(i, nj)] += effects.ColorFromCurrentPalette(ms / 37);
|
effects.leds[XY(i, nj)] += effects.ColorFromCurrentPalette(ms / 37);
|
||||||
effects.leds[XY(ni, j)] += effects.ColorFromCurrentPalette(ms / 41);
|
effects.leds[XY(ni, j)] += effects.ColorFromCurrentPalette(ms / 41);
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
#include "PatternInfinity.h"
|
#include "PatternInfinity.h"
|
||||||
#include "PatternPlasma.h"
|
#include "PatternPlasma.h"
|
||||||
#include "PatternSnake.h"
|
#include "PatternSnake.h"
|
||||||
//#include "PatternInvaders.h" // Doesn't seem to work, omitting.
|
#include "PatternInvaders.h"
|
||||||
//#include "PatternCube.h" // Doesn't seem to work, omitting.
|
//#include "PatternCube.h" // Doesn't seem to work, omitting.
|
||||||
//#include "PatternFire.h" // Doesn't seem to work, omitting.
|
//#include "PatternFire.h" // Doesn't seem to work, omitting.
|
||||||
#include "PatternLife.h"
|
#include "PatternLife.h"
|
||||||
|
@ -93,7 +93,7 @@ class Patterns : public Playlist {
|
||||||
PatternFlock flock;
|
PatternFlock flock;
|
||||||
PatternInfinity infinity;
|
PatternInfinity infinity;
|
||||||
PatternPlasma plasma;
|
PatternPlasma plasma;
|
||||||
// PatternInvadersSmall invadersSmall;
|
PatternInvadersSmall invadersSmall;
|
||||||
// PatternInvadersMedium invadersMedium;
|
// PatternInvadersMedium invadersMedium;
|
||||||
// PatternInvadersLarge invadersLarge;
|
// PatternInvadersLarge invadersLarge;
|
||||||
PatternSnake snake;
|
PatternSnake snake;
|
||||||
|
@ -132,13 +132,14 @@ 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
|
||||||
// &spin, // 16 ok but repeditivev
|
// &spin, // 16 ok but repeditivev
|
||||||
&simplexNoise, // 17 - cool!
|
&simplexNoise, // 17 - cool!
|
||||||
&wave, // 18 ok
|
// &wave, // 18 ok (can't work with 256+ matrix due to uint8_t vars)
|
||||||
// &rainbowFlag, //20 // fail
|
// &rainbowFlag, //20 // fail
|
||||||
&attract, // 21 ok
|
&attract, // 21 ok
|
||||||
&swirl, // 22
|
&swirl, // 22
|
||||||
|
@ -146,7 +147,7 @@ class Patterns : public Playlist {
|
||||||
&flock, // works
|
&flock, // works
|
||||||
&infinity, // works
|
&infinity, // works
|
||||||
&plasma, // works
|
&plasma, // works
|
||||||
// &invadersSmall, // works ish
|
&invadersSmall, // works ish
|
||||||
// &invadersMedium, // fail
|
// &invadersMedium, // fail
|
||||||
// &invadersLarge, // fail
|
// &invadersLarge, // fail
|
||||||
&snake, // ok
|
&snake, // 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