diff --git a/examples/AuroraDemo/AuroraDemo.ino b/examples/AuroraDemo/AuroraDemo.ino index f1bde22..d3f7978 100644 --- a/examples/AuroraDemo/AuroraDemo.ino +++ b/examples/AuroraDemo/AuroraDemo.ino @@ -36,10 +36,10 @@ Effects effects; Patterns patterns; /* -------------------------- Some variables -------------------------- */ -unsigned long ms_current = 0; -unsigned long ms_previous = 0; -unsigned long ms_animation_max_duration = 10000; // 10 seconds -unsigned long next_frame = 0; +unsigned long fps = 0, fps_timer; // fps (this is NOT a matix refresh rate!) +unsigned int default_fps = 30, pattern_fps = 30; // default fps limit (this is not a matix refresh conuter!) +unsigned long ms_animation_max_duration = 20000; // 20 seconds +unsigned long last_frame=0, ms_previous=0; void setup() { @@ -58,40 +58,51 @@ void setup() listPatterns(); - patterns.setPattern(0); // // simple noise - patterns.start(); + //patterns.setPattern(0); // // simple noise + patterns.moveRandom(1); // start from a random pattern Serial.print("Starting with pattern: "); Serial.println(patterns.getCurrentPatternName()); - + patterns.start(); + ms_previous = millis(); + fps_timer = millis(); } void loop() { // 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.move(1); + patterns.moveRandom(1); + //patterns.move(1); patterns.start(); Serial.print("Changing pattern to: "); Serial.println(patterns.getCurrentPatternName()); - ms_previous = ms_current; + ms_previous = millis(); // Select a random palette as well //effects.RandomPalette(); } - if ( next_frame < ms_current) - next_frame = patterns.drawFrame() + ms_current; + if ( 1000 / pattern_fps + last_frame < millis()){ + 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; + } } diff --git a/examples/AuroraDemo/Effects.h b/examples/AuroraDemo/Effects.h index 8169069..312e05c 100644 --- a/examples/AuroraDemo/Effects.h +++ b/examples/AuroraDemo/Effects.h @@ -33,24 +33,43 @@ const int MATRIX_CENTER_X = MATRIX_WIDTH / 2; const int MATRIX_CENTER_Y = MATRIX_HEIGHT / 2; -const byte MATRIX_CENTRE_X = MATRIX_CENTER_X - 1; -const byte MATRIX_CENTRE_Y = MATRIX_CENTER_Y - 1; +// 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 + 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. * 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. + * Ugh... uint8_t - really??? this weak method can't cope with 256+ pixel matrixes :( */ uint16_t XY( uint8_t x, uint8_t y) { - if( x >= MATRIX_WIDTH || x < 0) return 0; - if( y >= MATRIX_HEIGHT || y < 0) return 0; + 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() } - + +/** + * 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) { @@ -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 -byte heat[NUM_LEDS]; +//byte heat[NUM_LEDS]; // none of the currently enabled effects uses this uint32_t noise_x; uint32_t noise_y; @@ -92,11 +111,19 @@ uint8_t noisesmoothing; class Effects { public: - //CRGB *leds; - CRGB leds[NUM_LEDS]; + CRGB *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). - + 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. * We don't store what the color a particular pixel might be, other than when it's turned * into raw electrical signal output gobbly-gook (i.e. the DMA matrix buffer), but this * is not reversible. @@ -107,14 +134,13 @@ public: void drawBackgroundFastLEDPixelCRGB(int16_t x, int16_t y, CRGB 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 void Pixel(int x, int y, uint8_t colorIndex) { - CRGB temp = ColorFromCurrentPalette(colorIndex); - leds[XY(x, y)] = temp; - matrix.drawPixelRGB888(x, y, temp.r, temp.g, temp.b); // now draw it? + leds[XY(x, y)] = ColorFromCurrentPalette(colorIndex); + //matrix.drawPixelRGB888(x, y, temp.r, temp.g, temp.b); // now draw it? } void PrepareFrame() { @@ -134,18 +160,12 @@ public: for (int y=0;y= 0; y--) { - leds[XY(x, y)] = leds[XY(y, x)]; + leds[XY16(x, y)] = leds[XY16(y, x)]; } } } void Caleidoscope6() { 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 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 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 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 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 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 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 } @@ -458,20 +479,20 @@ public: 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 i = x - d; i <= x + d; i++) { - leds[XY(i, y - d)] += leds[XY(i + 1, y - d)]; // lowest row to the right - leds[XY(i, y - d)].nscale8(dimm); + leds[XY16(i, y - d)] += leds[XY16(i + 1, y - d)]; // lowest row to the right + leds[XY16(i, y - d)].nscale8(dimm); } for (int i = y - d; i <= y + d; i++) { - leds[XY(x + d, i)] += leds[XY(x + d, i + 1)]; // right colum up - leds[XY(x + d, i)].nscale8(dimm); + leds[XY16(x + d, i)] += leds[XY16(x + d, i + 1)]; // right colum up + leds[XY16(x + d, i)].nscale8(dimm); } 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[XY(i, y + d)].nscale8(dimm); + leds[XY16(i, y + d)] += leds[XY16(i - 1, y + d)]; // upper row to the left + leds[XY16(i, y + d)].nscale8(dimm); } for (int i = y + d; i >= y - d; i--) { - leds[XY(x - d, i)] += leds[XY(x - d, i - 1)]; // left colum down - leds[XY(x - d, i)].nscale8(dimm); + leds[XY16(x - d, i)] += leds[XY16(x - d, i - 1)]; // left colum down + leds[XY16(x - d, i)].nscale8(dimm); } } } @@ -494,24 +515,24 @@ public: while (a >= b) { // move them out one pixel on the radius - leds[XY(a + centerX, b + centerY)] = leds[XY(nextA + centerX, nextB + centerY)]; - leds[XY(b + centerX, a + centerY)] = leds[XY(nextB + centerX, nextA + centerY)]; - leds[XY(-a + centerX, b + centerY)] = leds[XY(-nextA + centerX, nextB + centerY)]; - leds[XY(-b + centerX, a + centerY)] = leds[XY(-nextB + centerX, nextA + centerY)]; - leds[XY(-a + centerX, -b + centerY)] = leds[XY(-nextA + centerX, -nextB + centerY)]; - leds[XY(-b + centerX, -a + centerY)] = leds[XY(-nextB + centerX, -nextA + centerY)]; - leds[XY(a + centerX, -b + centerY)] = leds[XY(nextA + centerX, -nextB + centerY)]; - leds[XY(b + centerX, -a + centerY)] = leds[XY(nextB + centerX, -nextA + centerY)]; + leds[XY16(a + centerX, b + centerY)] = leds[XY16(nextA + centerX, nextB + centerY)]; + leds[XY16(b + centerX, a + centerY)] = leds[XY16(nextB + centerX, nextA + centerY)]; + leds[XY16(-a + centerX, b + centerY)] = leds[XY16(-nextA + centerX, nextB + centerY)]; + leds[XY16(-b + centerX, a + centerY)] = leds[XY16(-nextB + centerX, nextA + centerY)]; + leds[XY16(-a + centerX, -b + centerY)] = leds[XY16(-nextA + centerX, -nextB + centerY)]; + leds[XY16(-b + centerX, -a + centerY)] = leds[XY16(-nextB + centerX, -nextA + centerY)]; + leds[XY16(a + centerX, -b + centerY)] = leds[XY16(nextA + centerX, -nextB + centerY)]; + leds[XY16(b + centerX, -a + centerY)] = leds[XY16(nextB + centerX, -nextA + centerY)]; // dim them - leds[XY(a + centerX, b + centerY)].nscale8(dimm); - leds[XY(b + centerX, a + centerY)].nscale8(dimm); - leds[XY(-a + centerX, b + centerY)].nscale8(dimm); - leds[XY(-b + centerX, a + centerY)].nscale8(dimm); - leds[XY(-a + centerX, -b + centerY)].nscale8(dimm); - leds[XY(-b + centerX, -a + centerY)].nscale8(dimm); - leds[XY(a + centerX, -b + centerY)].nscale8(dimm); - leds[XY(b + centerX, -a + centerY)].nscale8(dimm); + leds[XY16(a + centerX, b + centerY)].nscale8(dimm); + leds[XY16(b + centerX, a + centerY)].nscale8(dimm); + leds[XY16(-a + centerX, b + centerY)].nscale8(dimm); + leds[XY16(-b + centerX, a + centerY)].nscale8(dimm); + leds[XY16(-a + centerX, -b + centerY)].nscale8(dimm); + leds[XY16(-b + centerX, -a + centerY)].nscale8(dimm); + leds[XY16(a + centerX, -b + centerY)].nscale8(dimm); + leds[XY16(b + centerX, -a + centerY)].nscale8(dimm); b++; if (radiusError < 0) @@ -541,12 +562,12 @@ public: { for (int x = fromX + 1; x < toX; x++) { for (int y = fromY; y < toY; y++) { - leds[XY(x, y)] += leds[XY(x - 1, y)]; - leds[XY(x, y)].nscale8(scale); + leds[XY16(x, y)] += leds[XY16(x - 1, y)]; + leds[XY16(x, y)].nscale8(scale); } } 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 @@ -554,12 +575,12 @@ public: { for (int x = toX; x < fromX; x++) { for (int y = fromY; y < toY; y++) { - leds[XY(x, y)] += leds[XY(x + 1, y)]; - leds[XY(x, y)].nscale8(scale); + leds[XY16(x, y)] += leds[XY16(x + 1, y)]; + leds[XY16(x, y)].nscale8(scale); } } 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 @@ -567,12 +588,12 @@ public: { for (int x = 0; x < MATRIX_WIDTH; x++) { for (int y = 1; y < MATRIX_HEIGHT; y++) { - leds[XY(x, y)] += leds[XY(x, y - 1)]; - leds[XY(x, y)].nscale8(scale); + leds[XY16(x, y)] += leds[XY16(x, y - 1)]; + leds[XY16(x, y)].nscale8(scale); } } 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 @@ -580,12 +601,12 @@ public: { for (int x = 0; x < MATRIX_WIDTH; x++) { for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) { - leds[XY(x, y)] += leds[XY(x, y + 1)]; - leds[XY(x, y)].nscale8(scale); + leds[XY16(x, y)] += leds[XY16(x, y + 1)]; + leds[XY16(x, y)].nscale8(scale); } } 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 @@ -593,14 +614,14 @@ public: { for (int x = 0; x < MATRIX_WIDTH - 1; x++) { for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) { - leds[XY(x, y)] += leds[XY(x + 1, y + 1)]; - leds[XY(x, y)].nscale8(scale); + leds[XY16(x, y)] += leds[XY16(x + 1, y + 1)]; + leds[XY16(x, y)].nscale8(scale); } } 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++) - 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 @@ -608,24 +629,24 @@ public: { for (int x = 0; x < MATRIX_WIDTH - 1; x++) { for (int y = MATRIX_HEIGHT - 2; y >= 0; y--) { - leds[XY(x + 1, y)] += leds[XY(x, y + 1)]; - leds[XY(x, y)].nscale8(scale); + 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 < MATRIX_WIDTH; x++) - leds[XY(x, MATRIX_HEIGHT - 1)].nscale8(scale); + leds[XY16(x, MATRIX_HEIGHT - 1)].nscale8(scale); // fade the right column 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 void MoveDown() { for (int y = MATRIX_HEIGHT - 1; y > 0; y--) { 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) { for (int y = end; y > start; y--) { 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) { for (int y = y0; y < y1 + 1; y++) { 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() { for (int x = 1; x < MATRIX_CENTER_X; x++) { 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() { for (int x = 1; x < MATRIX_CENTER_X; x++) { 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 err = dx + dy, e2; for (;;) { - leds[XY(x0, y0)] += color; + leds[XY16(x0, y0)] += color; if (x0 == x1 && y0 == y1) break; e2 = 2 * err; if (e2 > dy) { @@ -732,10 +753,10 @@ public: } 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); - 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); 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/ // 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++) { // Do this delta time for each row... computationally expensive potentially. 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; 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 { // Do this delta time for each row... computationally expensive potentially. 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 } /// MoveY diff --git a/examples/AuroraDemo/PatternAttract.h b/examples/AuroraDemo/PatternAttract.h index 7df342c..dcb6491 100644 --- a/examples/AuroraDemo/PatternAttract.h +++ b/examples/AuroraDemo/PatternAttract.h @@ -52,7 +52,7 @@ public: unsigned int drawFrame() { // dim all pixels on the display uint8_t dim = beatsin8(2, 170, 250); - effects.DimAll(dim); effects.ShowFrame(); + effects.DimAll(dim); for (int i = 0; i < count; i++) { Boid boid = boids[i]; @@ -66,7 +66,8 @@ public: boids[i] = boid; } - return 15; + effects.ShowFrame(); + return 0; } }; diff --git a/examples/AuroraDemo/PatternElectricMandala.h b/examples/AuroraDemo/PatternElectricMandala.h index 2ba0a62..880de25 100644 --- a/examples/AuroraDemo/PatternElectricMandala.h +++ b/examples/AuroraDemo/PatternElectricMandala.h @@ -92,13 +92,13 @@ class PatternElectricMandala : public Drawable { effects.ShowFrame(); - return 0; + return 30; } // show just one layer void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) { - for (uint8_t i = 0; i < MATRIX_WIDTH; i++) { - for (uint8_t j = 0; j < MATRIX_HEIGHT; j++) { + for (uint16_t i = 0; i < MATRIX_WIDTH; i++) { + for (uint16_t j = 0; j < MATRIX_HEIGHT; j++) { uint8_t color = noise[i][j]; @@ -107,7 +107,7 @@ class PatternElectricMandala : public Drawable { // assign a color depending on the actual palette CRGB pixel = ColorFromPalette(effects.currentPalette, colorrepeat * (color + colorshift), bri); - effects.leds[XY(i, j)] = pixel; + effects.leds[XY16(i, j)] = pixel; } } } diff --git a/examples/AuroraDemo/PatternMaze.h b/examples/AuroraDemo/PatternMaze.h index eaa1089..c469922 100644 --- a/examples/AuroraDemo/PatternMaze.h +++ b/examples/AuroraDemo/PatternMaze.h @@ -246,7 +246,7 @@ public: if (algorithm >= algorithmCount) algorithm = 0; - return 1000; + return 0; } effects.ShowFrame(); @@ -255,7 +255,7 @@ public: } void start() { - matrix.fillScreen(0); + effects.ClearFrame(); cellCount = 0; hue = 0; } diff --git a/examples/AuroraDemo/PatternMunch.h b/examples/AuroraDemo/PatternMunch.h index b581b53..f580828 100644 --- a/examples/AuroraDemo/PatternMunch.h +++ b/examples/AuroraDemo/PatternMunch.h @@ -40,9 +40,9 @@ public: unsigned int drawFrame() { - for (byte x = 0; x < MATRIX_WIDTH; x++) { - for (byte y = 0; y < MATRIX_HEIGHT; y++) { - effects.leds[XY(x, y)] = (x ^ y ^ flip) < count ? effects.ColorFromCurrentPalette(((x ^ y) << 2) + generation) : CRGB::Black; + for (uint16_t x = 0; x < MATRIX_WIDTH; x++) { + for (uint16_t y = 0; y < MATRIX_HEIGHT; y++) { + 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) ; @@ -66,7 +66,6 @@ public: // show it ffs! effects.ShowFrame(); - return 60; } }; diff --git a/examples/AuroraDemo/PatternPendulumWave.h b/examples/AuroraDemo/PatternPendulumWave.h index acd83e9..b0ae99c 100644 --- a/examples/AuroraDemo/PatternPendulumWave.h +++ b/examples/AuroraDemo/PatternPendulumWave.h @@ -49,7 +49,7 @@ class PatternPendulumWave : public Drawable { effects.drawBackgroundFastLEDPixelCRGB(x, y, effects.ColorFromCurrentPalette(x * 7)); } - return 15; + return 10; } }; diff --git a/examples/AuroraDemo/PatternSimplexNoise.h b/examples/AuroraDemo/PatternSimplexNoise.h index 44c3ec5..0c47bff 100644 --- a/examples/AuroraDemo/PatternSimplexNoise.h +++ b/examples/AuroraDemo/PatternSimplexNoise.h @@ -60,17 +60,17 @@ class PatternSimplexNoise : public Drawable { effects.ShowFrame(); - return 0; + return 30; } // show just one layer void ShowNoiseLayer(byte layer, byte colorrepeat, byte colorshift) { - for (uint8_t i = 0; i < MATRIX_WIDTH; i++) { - for (uint8_t j = 0; j < MATRIX_HEIGHT; j++) { + for (uint16_t i = 0; i < MATRIX_WIDTH; i++) { + for (uint16_t j = 0; j < MATRIX_HEIGHT; j++) { uint8_t pixel = noise[i][j]; // 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); } } } diff --git a/examples/AuroraDemo/PatternSpiro.h b/examples/AuroraDemo/PatternSpiro.h index 488a729..ee0d03e 100644 --- a/examples/AuroraDemo/PatternSpiro.h +++ b/examples/AuroraDemo/PatternSpiro.h @@ -37,7 +37,7 @@ class PatternSpiro : public Drawable { uint8_t spirocount = 1; uint8_t spirooffset = 256 / spirocount; - boolean spiroincrement = false; + boolean spiroincrement = true; boolean handledChange = false; @@ -46,8 +46,12 @@ class PatternSpiro : public Drawable { name = (char *)"Spiro"; } + void start(){ + effects.ClearFrame(); + }; + unsigned int drawFrame() { - effects.DimAll(254); effects.ShowFrame(); + effects.DimAll(1); boolean change = false; @@ -100,6 +104,7 @@ class PatternSpiro : public Drawable { hueoffset += 1; } + effects.ShowFrame(); return 0; } }; diff --git a/examples/AuroraDemo/PatternSwirl.h b/examples/AuroraDemo/PatternSwirl.h index 8ae8eb1..d6df5ef 100644 --- a/examples/AuroraDemo/PatternSwirl.h +++ b/examples/AuroraDemo/PatternSwirl.h @@ -36,6 +36,7 @@ class PatternSwirl : public Drawable { } void start() { + effects.ClearFrame(); } unsigned int drawFrame() { @@ -52,8 +53,8 @@ class PatternSwirl : public Drawable { #endif // Use two out-of-sync sine waves - uint8_t i = beatsin8(27, borderWidth, MATRIX_HEIGHT - borderWidth); - uint8_t j = beatsin8(41, borderWidth, MATRIX_WIDTH - borderWidth); + uint8_t i = beatsin8(13, borderWidth, MATRIX_HEIGHT - borderWidth); + uint8_t j = beatsin8(27, borderWidth, MATRIX_WIDTH - borderWidth); // Also calculate some reflections uint8_t ni = (MATRIX_WIDTH - 1) - i; uint8_t nj = (MATRIX_WIDTH - 1) - j; diff --git a/examples/AuroraDemo/PatternTest.h b/examples/AuroraDemo/PatternTest.h index 490e1a2..6f0544f 100644 --- a/examples/AuroraDemo/PatternTest.h +++ b/examples/AuroraDemo/PatternTest.h @@ -13,7 +13,7 @@ class PatternTest : public Drawable { unsigned int drawFrame() { matrix.fillScreen(matrix.color565(128, 0, 0)); - + return 1000; } }; diff --git a/examples/AuroraDemo/Patterns.h b/examples/AuroraDemo/Patterns.h index 419b546..e141146 100644 --- a/examples/AuroraDemo/Patterns.h +++ b/examples/AuroraDemo/Patterns.h @@ -81,7 +81,7 @@ class Patterns : public Playlist { PatternSwirl swirl; PatternPendulumWave pendulumWave; PatternFlowField flowField; - PatternIncrementalDrift incrementalDrift; + // PatternIncrementalDrift incrementalDrift; // PatternIncrementalDrift2 incrementalDrift2; PatternMunch munch; PatternElectricMandala electricMandala; @@ -114,7 +114,7 @@ class Patterns : public Playlist { //const static int PATTERN_COUNT = 37; - const static int PATTERN_COUNT = 17; + const static int PATTERN_COUNT = 16; Drawable* shuffledItems[PATTERN_COUNT]; @@ -132,7 +132,8 @@ class Patterns : public Playlist { &life, // ok &flowField, &pendulumWave, //11 ok - &incrementalDrift, //12 ok + + // &incrementalDrift, //12 ok // &incrementalDrift2, // 13 fail &munch, // 14 ok &electricMandala, // 15 ok diff --git a/examples/FM6126Panel/FM6126Panel.ino b/examples/FM6126Panel/FM6126Panel.ino index 94fe6b4..e5d92bc 100644 --- a/examples/FM6126Panel/FM6126Panel.ino +++ b/examples/FM6126Panel/FM6126Panel.ino @@ -36,7 +36,7 @@ MatrixPanel_I2S_DMA dma_display; #define CH_B 19 #define CH_C 5 #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 LAT 4 #define OE 15 @@ -91,6 +91,6 @@ void loop(){ if (cycles >= 1024) { time_counter = 0; cycles = 0; - currentPalette = palettes[random(0,sizeof(palettes))]; + currentPalette = palettes[random(0,sizeof(palettes)/sizeof(palettes[0]))]; } } \ No newline at end of file