Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D GEQ #143

Merged
merged 29 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2f2354
Add @TroyHacks 3D GEQ
netmindz Jul 10, 2024
e452d4d
Add @TroyHacks 3D GEQ
netmindz Jul 10, 2024
2d7e416
;
netmindz Jul 10, 2024
45f288a
3D GEQ - make front brightness a control
netmindz Jul 10, 2024
f6cd28c
3D GEQ - customisable number of bands
netmindz Jul 10, 2024
cb3d06b
3D GEQ - variable front brightness
netmindz Jul 10, 2024
3fd8078
3D GEQ - customisable number of bands
netmindz Jul 10, 2024
bda4bbe
3D GEQ - fade speed
netmindz Jul 10, 2024
8f4380b
Rename 3D GEQ to GEQ Laser
netmindz Jul 10, 2024
aed861d
GEQ Laser use SEGMENT.data
netmindz Jul 10, 2024
ce8f01b
Bugfixed GEQ 3D
troyhacks Jul 13, 2024
52130e1
Merge branch 'mdev' into 3DGEQ
troyhacks Jul 13, 2024
4c8d500
Seems someone improved drawline() - fixed for this
troyhacks Jul 13, 2024
643f82d
Don't use new soft drawline() option
troyhacks Jul 13, 2024
75f0c7c
Oopsy
troyhacks Jul 13, 2024
dddd157
(experimental) setPixelColorXY_fast speedup by setPixelColorXY_fast
softhack007 Jul 14, 2024
6aaf7a9
more sPC optimizations
softhack007 Jul 14, 2024
3857862
Optimized side-wall drawing
troyhacks Jul 15, 2024
6d16151
Merge branch 'mdev' into 3DGEQ
softhack007 Jul 15, 2024
4f6eb8b
prevent array bounds violation
softhack007 Jul 15, 2024
5401328
loop optimizations
softhack007 Jul 15, 2024
54f9d4c
Borders checkbox for @netmindz
troyhacks Jul 15, 2024
98c15d7
Borders checkbox
troyhacks Jul 15, 2024
9610408
speedup for pinwheel mapping
softhack007 Jul 15, 2024
6565e71
GEQ speedup
softhack007 Jul 15, 2024
e3d27de
better handling of perspective
softhack007 Jul 16, 2024
96584c6
better rounding
softhack007 Jul 16, 2024
e3b4a08
soft light option
softhack007 Jul 16, 2024
1f14673
workaround for "cannot read properties of undefined. reading 'split'
softhack007 Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8355,6 +8355,137 @@ uint16_t mode_2Dwavingcell() {
}
static const char _data_FX_MODE_2DWAVINGCELL[] PROGMEM = "Waving Cell@!,,Amplitude 1,Amplitude 2,Amplitude 3;;!;2";

uint16_t mode_3DGEQ(void) {
netmindz marked this conversation as resolved.
Show resolved Hide resolved

// Author: @TroyHacks

static uint16_t projector;
static uint16_t projector_dir = 1;
netmindz marked this conversation as resolved.
Show resolved Hide resolved

// delay(1000);

if (SEGENV.call == 0) {
projector = 0;
SEGMENT.setUpLeds(); // WLEDMM use lossless getPixelColor()
SEGMENT.fill(BLACK);
} else {
projector += projector_dir;
if (projector == SEGMENT.virtualWidth()) projector_dir = -1;
if (projector == 0) projector_dir = 1;
troyhacks marked this conversation as resolved.
Show resolved Hide resolved
}

if (SEGMENT.speed > 250) {
SEGMENT.fill(BLACK);
} else {
SEGMENT.fadeToBlackBy(SEGMENT.speed);
}

const int NUM_BANDS = map(SEGMENT.custom1, 0, 255, 1, 16);
const uint16_t cols = SEGMENT.virtualWidth();
const uint16_t rows = SEGMENT.virtualHeight();
const uint_fast8_t split = map(projector,0,SEGMENT.virtualWidth(),0,(NUM_BANDS - 1));

um_data_t *um_data;
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
// add support for no audio
um_data = simulateSound(SEGMENT.soundSim);
}
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];

uint8_t heights[NUM_BANDS] = { 0 };

for (int i=0; i<NUM_BANDS; i++) {
heights[i] = map(fftResult[i],0,255,0,rows-10); // TODO: avg don't just take lower bands?
}

for (int i=0; i<=split; i++) { // paint right vertical faces and top

uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);

int linex = i*(cols/NUM_BANDS);
softhack007 marked this conversation as resolved.
Show resolved Hide resolved

if (heights[i] > 1) {

for (int y = 0; y <= heights[i]; y++) {
SEGMENT.drawLine(linex+(cols/NUM_BANDS)-1,rows-y-1,projector,0,color_fade(ledColor,32,true));
}

for (int x=linex; x<=linex+(cols/NUM_BANDS)-1;x++) {
SEGMENT.drawLine(x, rows-heights[i]-2,projector,0,color_fade(ledColor,128,true)); // top perspective
}

}

}

for (int i=(NUM_BANDS - 1); i>split; i--) { // paint left vertical faces and top

uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
troyhacks marked this conversation as resolved.
Show resolved Hide resolved
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);

int linex = i*(cols/NUM_BANDS);

if (heights[i] > 1) {

for (int y = 0; y <= heights[i]; y++) {
SEGMENT.drawLine(linex ,rows-y-1,projector,0,color_fade(ledColor,32,true));
}

for (int x=linex; x<=linex+(cols/NUM_BANDS)-1;x++) {
SEGMENT.drawLine(x, rows-heights[i]-2,projector,0,color_fade(ledColor,128,true)); // top perspective
}

}

}

uint8_t frontBrightness = SEGMENT.custom2;
for (int i=0; i<NUM_BANDS; i++) {

uint16_t colorIndex = map(cols/NUM_BANDS*i, 0, cols-1, 0, 255);
uint32_t ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);

int linex = i*(cols/NUM_BANDS);

if (heights[i] > 1) {

if(frontBrightness > 250) {
// Full bright fronts, fills all front face.
for (int x=linex; x<linex+(cols/NUM_BANDS);x++) {
SEGMENT.drawLine(x,rows-1,x,rows-heights[i]-1,ledColor); // front fill
}
}
else if(frontBrightness >= 50) {
// Faded fronts, assumes border added later.
for (int x=linex+1; x<linex+(cols/NUM_BANDS)-1;x++) {
SEGMENT.drawLine(x,rows-2,x,rows-heights[i]-2,color_fade(ledColor,map(frontBrightness, 50, 250, 0, 255),true)); // front fill
}
}
else {
// "Negative Space" - draw pure black fronts
for (int x=linex; x<linex+(cols/NUM_BANDS);x++) {
SEGMENT.drawLine(x,rows-1,x,rows-heights[i]-1,BLACK); // front fill
}
}

if(frontBrightness >= 50) { // TODO: other values too? not sure exactly when we want the border
troyhacks marked this conversation as resolved.
Show resolved Hide resolved
// Border
SEGMENT.drawLine(linex, rows-1,linex,rows-heights[i]-1,ledColor); // left side line
SEGMENT.drawLine(linex+(cols/NUM_BANDS)-1,rows-1,linex+(cols/NUM_BANDS)-1,rows-heights[i]-1,ledColor); // right side line
SEGMENT.drawLine(linex, rows-heights[i]-2,linex+(cols/NUM_BANDS)-1,rows-heights[i]-2,ledColor); // top line
SEGMENT.drawLine(linex, rows-1,linex+(cols/NUM_BANDS)-1,rows-1,ledColor); // bottom line
}

}

}

return FRAMETIME;

}
static const char _data_FX_MODE_3DGEQ[] PROGMEM = "3D GEQ☾@!,,Bands,Fill Front,;;!;2"; // TODO set Audio, 2D and controls etc


#endif // WLED_DISABLE_2D

Expand Down Expand Up @@ -8601,6 +8732,9 @@ void WS2812FX::setupEffectData() {
addEffect(FX_MODE_2DWAVINGCELL, &mode_2Dwavingcell, _data_FX_MODE_2DWAVINGCELL);

addEffect(FX_MODE_2DAKEMI, &mode_2DAkemi, _data_FX_MODE_2DAKEMI); // audio

addEffect(FX_MODE_3DGEQ, &mode_3DGEQ, _data_FX_MODE_3DGEQ); // audio

#endif // WLED_DISABLE_2D

}
3 changes: 2 additions & 1 deletion wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ bool strip_uses_global_leds(void); // WLEDMM implemented in FX_fcn.
#define FX_MODE_STARBURST_AR 192 // WLED-SR audioreactive fireworks starburst
// #define FX_MODE_PALETTE_AR 193 // WLED-SR audioreactive palette
#define FX_MODE_FIREWORKS_AR 194 // WLED-SR audioreactive fireworks
#define FX_MODE_3DGEQ 195 // WLED-MM 3D GEQ

#define MODE_COUNT 195
#define MODE_COUNT 196

typedef enum mapping1D2D {
M12_Pixels = 0,
Expand Down
Loading