make getPixelColor matrix (mapping) aware

And change some mapping defaults of effects useing getPixelColor
This commit is contained in:
ewowi 2022-07-13 15:40:40 +02:00
parent 615f807909
commit aeb8fd6fda
2 changed files with 29 additions and 6 deletions

View File

@ -6647,7 +6647,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
return FRAMETIME; return FRAMETIME;
} // mode_matripix() } // mode_matripix()
static const char *_data_FX_MODE_MATRIPIX PROGMEM = " ♪ Matripix@!,Brightness=64;,!;!;mp12=0;ssim=0;rev=1"; // Pixel, Beatsin, reverseX static const char *_data_FX_MODE_MATRIPIX PROGMEM = " ♪ Matripix@!,Brightness=64;,!;!;mp12=2;ssim=1;rev=1"; // Circle, Beatsin, reverseX
////////////////////// //////////////////////
@ -6790,7 +6790,7 @@ uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
return FRAMETIME; return FRAMETIME;
} // mode_pixelwave() } // mode_pixelwave()
static const char *_data_FX_MODE_PIXELWAVE PROGMEM = " ♪ Pixelwave@!,Sensitivity=64;!,!;!;mp12=0;ssim=0"; // Pixels, Beatsin static const char *_data_FX_MODE_PIXELWAVE PROGMEM = " ♪ Pixelwave@!,Sensitivity=64;!,!;!;mp12=2;ssim=0"; // Circle, Beatsin
////////////////////// //////////////////////
@ -7131,7 +7131,7 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
return FRAMETIME; return FRAMETIME;
} // mode_freqmap() } // mode_freqmap()
static const char *_data_FX_MODE_FREQMAP PROGMEM = " ♫ Freqmap@Fade rate,Starting color;,!;!;mp12=0;ssim=0"; // Pixels, Beatsin static const char *_data_FX_MODE_FREQMAP PROGMEM = " ♫ Freqmap@Fade rate,Starting color;,!;!;mp12=2;ssim=0"; // Circle, Beatsin
/////////////////////// ///////////////////////
@ -7288,7 +7288,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
return FRAMETIME; return FRAMETIME;
} // mode_freqwave() } // mode_freqwave()
static const char *_data_FX_MODE_FREQWAVE PROGMEM = " ♫ Freqwave@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=0;ssim=0"; // Pixels, Beatsin static const char *_data_FX_MODE_FREQWAVE PROGMEM = " ♫ Freqwave@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=2;ssim=0"; // Circle, Beatsin
/////////////////////// ///////////////////////
@ -7464,7 +7464,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
return FRAMETIME; return FRAMETIME;
} // mode_waterfall() } // mode_waterfall()
static const char *_data_FX_MODE_WATERFALL PROGMEM = " ♫ Waterfall@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=0;ssim=0"; // Pixels, Beatsin static const char *_data_FX_MODE_WATERFALL PROGMEM = " ♫ Waterfall@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=2;ssim=0"; // Circles, Beatsin
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D

View File

@ -276,7 +276,30 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa)
uint32_t Segment::getPixelColor(uint16_t i) uint32_t Segment::getPixelColor(uint16_t i)
{ {
if (getOption(SEG_OPTION_REVERSED)) i = virtualLength() - i - 1; if (strip.isMatrix) {
switch (SEGMENT.mapping12) {
case M12_Pixels:
return getPixelColorXY(i%SEGMENT.virtualWidth(), i/SEGMENT.virtualWidth());
break;
case M12_VerticalBar:
// map linear pixel into 2D segment area (even for 1D segments, expanding vertically)
return getPixelColorXY(i, 0);
break;
case M12_Circle:
{
int x = roundf(roundf((SEGMENT.virtualWidth() / 2) * 10)/10);
int y = roundf(roundf((i + SEGMENT.virtualHeight() / 2) * 10)/10);
return getPixelColorXY(x,y);
}
break;
case M12_Block:
return getPixelColorXY(SEGMENT.virtualWidth() / 2, SEGMENT.virtualHeight() / 2 - i - 1);
break;
}
return 0;
}
if (getOption(SEG_OPTION_REVERSED)) i = strip.getMappingLength() - i - 1;
i *= groupLength(); i *= groupLength();
i += start; i += start;
/* offset/phase */ /* offset/phase */