Skip to content

Commit

Permalink
Add FunkyPlank
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Mar 4, 2024
1 parent ab2c8dc commit 43e002d
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned short, std::allocator<unsigned short> >::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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 43e002d

Please sign in to comment.