From df15a10b6c2a645c4ca5c4054f67608ccbbf5dd1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Mar 2024 18:23:50 +0000 Subject: [PATCH 1/2] Add FunkyPlank --- src/App/AppEffects.h | 74 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 8c389b77..049cd101 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -1048,6 +1048,79 @@ class FreqMatrix:public Effect { } }; +class FunkyPlank:public Effect { +public: + const char * name() { + return "Funky Plank 2D"; + } + + void setup(Leds &leds) { + leds.fill_solid(CRGB::Black); + } + + void loop(Leds &leds) { + + const uint16_t cols = leds.size.x; + const uint16_t rows = leds.size.y; + + unsigned8 num_bands = mdl->getValue("bands"); + int barWidth = (cols / num_bands); + int bandInc = 1; + if (barWidth == 0) { + // Matrix narrower than fft bands + barWidth = 1; + bandInc = (num_bands / cols); + } + + unsigned8 *aux0 = leds.sharedData.bind(aux0); + unsigned8 speed = mdl->getValue("speed"); + + unsigned8 secondHand = (speed < 255) ? (micros()/(256-speed)/500 % 16) : 0; + if((speed > 254) || (*aux0 != secondHand)) { // WLEDMM allow run run at full speed + *aux0 = secondHand; + + // display values of + int b = 0; + for (int band = 0; band < num_bands; band += bandInc, b++) { + int hue = wledAudioMod->fftResults[band % 16]; + int v = map(wledAudioMod->fftResults[band % 16], 0, 255, 10, 255); + for (int w = 0; w < barWidth; w++) { + int xpos = (barWidth * b) + w; + leds.setPixelColor(leds.XY(xpos, 0), CHSV(hue, 255, v)); + } + } + + // Update the display: + for (int i = (rows - 1); i > 0; i--) { + for (int j = (cols - 1); j >= 0; j--) { + unsigned16 p = leds.XY(j, i-1); + if((p == 0)||(p > (leds.nrOfLeds -1))) { + USER_PRINTF("%dx%d = %d\n", j, (i - 1), p); + } + else { + // USER_PRINTF("%dx%d = %d\n", j, (i - 1), p); + + // leds.setPixelColor(leds.XY(j, i), leds.getPixelColor(p)); // TODO fix + /* + #0 0x400d821f:0x3ffb2100 in std::vector >::size() const at /home/will/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_vector.h:806 + (inlined by) Leds::getPixelColor(unsigned short) at src/App/AppLeds.cpp:49 + */ + } + } + } + + } + + } + + void controls(JsonObject parentVar) { + ui->initSlider(parentVar, "speed", 255); + ui->initSlider(parentVar, "bands", NUM_GEQ_CHANNELS, 1, NUM_GEQ_CHANNELS); + } +}; + + + #endif // End Audio Effects class Effects { @@ -1080,6 +1153,7 @@ class Effects { effects.push_back(new GEQEffect); effects.push_back(new AudioRings); effects.push_back(new FreqMatrix); + effects.push_back(new FunkyPlank); #endif } From 70461cfcfc59b2a2067304aac04072302f88265b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Mar 2024 22:30:48 +0000 Subject: [PATCH 2/2] Remove comment for leds.getPixelColor --- src/App/AppEffects.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 049cd101..2272d893 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -1093,19 +1093,7 @@ class FunkyPlank:public Effect { // Update the display: for (int i = (rows - 1); i > 0; i--) { for (int j = (cols - 1); j >= 0; j--) { - unsigned16 p = leds.XY(j, i-1); - if((p == 0)||(p > (leds.nrOfLeds -1))) { - USER_PRINTF("%dx%d = %d\n", j, (i - 1), p); - } - else { - // USER_PRINTF("%dx%d = %d\n", j, (i - 1), p); - - // leds.setPixelColor(leds.XY(j, i), leds.getPixelColor(p)); // TODO fix - /* - #0 0x400d821f:0x3ffb2100 in std::vector >::size() const at /home/will/.platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_vector.h:806 - (inlined by) Leds::getPixelColor(unsigned short) at src/App/AppLeds.cpp:49 - */ - } + leds.setPixelColor(leds.XY(j, i), leds.getPixelColor(leds.XY(j, i-1))); } }