From aeb8fd6fda2a88beb4d6a6796180e9529e5eda4b Mon Sep 17 00:00:00 2001 From: ewowi Date: Wed, 13 Jul 2022 15:40:40 +0200 Subject: [PATCH] make getPixelColor matrix (mapping) aware And change some mapping defaults of effects useing getPixelColor --- wled00/FX.cpp | 10 +++++----- wled00/FX_fcn.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 70f92657..16fbd223 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -6647,7 +6647,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline. return FRAMETIME; } // 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; } // 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; } // 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; } // 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; } // 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 diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 5bde6d7d..749b5e04 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -276,7 +276,30 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa) 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 += start; /* offset/phase */