From 292c4e25ba8985ba9205404d13f92cef8f597aa2 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 1 Apr 2023 22:13:46 +0200 Subject: [PATCH] small updates * colors.cpp: disable gamma calculation if CIE table mode is active (WLED_USE_CIE_BRIGHTNESS_TABLE) * fx.cpp: small improvement to FreqMap, and bugfix for effects that modify binNum / maxVol * pio: update for Line-In shield pins (final hardware version) --- platformio.ini | 13 +++++++++++-- wled00/FX.cpp | 15 +++++++++++++++ wled00/colors.cpp | 4 +++- wled00/wled.h | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 48c5c79b..df001a91 100644 --- a/platformio.ini +++ b/platformio.ini @@ -940,9 +940,16 @@ build_flags = -D SR_SQUELCH=10 -D SR_GAIN=40 -D SR_FREQ_PROF=7 ; SPM1423 specific [Shield_LineIn] +build_unflags = + -D BTNPIN=17 ;; remove - its in conflict with on-shield rotary + -D ENCODER_SW_PIN=5 ;; remove - its in conflict with on-shield rotary + -D BTNPIN=0 ;; remove - its in conflict with MCLK pin build_flags = - -D SR_DMTYPE=4 -D MCLK_PIN=0 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ; for audio Line-In shield - -D SR_SQUELCH=2 -D SR_GAIN=40 -D SR_FREQ_PROF=1 ; CS5343 Line-In specific + -D BTNPIN=-1 + -D SR_DMTYPE=4 -D MCLK_PIN=0 -D I2S_SDPIN=26 -D I2S_WSPIN=25 -D I2S_CKPIN=27 ; for audio Line-In shield, final version + -D SR_LINE_DETECT=34 ; line-in plug insert detection sensor (future support) + -D SR_SQUELCH=8 -D SR_GAIN=40 -D SR_FREQ_PROF=1 ; CS5343 Line-In specific + -D ENCODER_DT_PIN=35 -D ENCODER_CLK_PIN=39 -D ENCODER_SW_PIN=17 ; on-shield rotary encoder [Debug_Flags] build_flags = @@ -1547,6 +1554,7 @@ build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags} ${Shield_SPM1423.buil [env:wemos_shield_esp32_4MB_LineIn_M] extends = wemos_shield_esp32_4MB_M_base +build_unflags = ${common.build_unflags} ${Shield_LineIn.build_unflags} build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags} ${Shield_LineIn.build_flags} -D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_LineIn_M @@ -1602,6 +1610,7 @@ board_build.partitions = tools/WLED_ESP32_16MB.csv ;; WLED standard for [env:wemos_shield_esp32_16MB_LineIn_M] extends = wemos_shield_esp32_4MB_M_base +build_unflags = ${common.build_unflags} ${Shield_LineIn.build_unflags} build_flags = ${wemos_shield_esp32_4MB_M_base.build_flags} ${Shield_LineIn.build_flags} -D WLED_RELEASE_NAME=wemos_shield_esp32_16MB_LineIn_M board = esp32_16MB diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 9a66b74b..16853469 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -6037,6 +6037,8 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli SEGMENT.custom1 = *binNum; SEGMENT.custom2 = *maxVol * 2; } + if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings + if (SEGMENT.custom2 < 48) SEGMENT.custom1 = 48; // WLEDMM prevent stupid settings *binNum = SEGMENT.custom1; // Select a bin. *maxVol = SEGMENT.custom2 / 2; // Our volume comparator. @@ -6598,6 +6600,8 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline. SEGMENT.custom1 = *binNum; SEGMENT.custom2 = *maxVol * 2; } + if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings + if (SEGMENT.custom2 < 48) SEGMENT.custom1 = 48; // WLEDMM prevent stupid settings *binNum = SEGMENT.custom1; // Select a bin. *maxVol = SEGMENT.custom2 / 2; // Our volume comparator. @@ -6794,9 +6798,17 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN. uint16_t pixCol = (log10f(FFT_MajorPeak) - 1.78f) * 255.0f/(MAX_FREQ_LOG10 - 1.78f); // Scale log10 of frequency values to the 255 colour index. if (FFT_MajorPeak < 61.0f) pixCol = 0; // handle underflow +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) + uint16_t bright = (int) (sqrtf(my_magnitude)*16.0f); // WLEDMM sqrt scaling, to make peaks more prominent +#else uint16_t bright = (int)my_magnitude; +#endif SEGMENT.setPixelColor(locn, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(SEGMENT.intensity+pixCol, false, PALETTE_SOLID_WRAP, 0), bright)); + if (SEGMENT.speed > 228) { // WLEDMM looks nice in 2D + SEGMENT.blur(5*(SEGMENT.speed - 224)); + SEGMENT.setPixelColor(locn, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(SEGMENT.intensity+pixCol, false, PALETTE_SOLID_WRAP, 0), bright)); + } return FRAMETIME; } // mode_freqmap() @@ -7110,6 +7122,9 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin SEGMENT.custom2 = *maxVol * 2; } + if (SEGMENT.custom1 < 2) SEGMENT.custom1 = 2; // WLEDMM prevent stupid settings + if (SEGMENT.custom2 < 48) SEGMENT.custom1 = 48; // WLEDMM prevent stupid settings + *binNum = SEGMENT.custom1; // Select a bin. *maxVol = SEGMENT.custom2 / 2; // Our volume comparator. diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 8a4a4ebd..61457eba 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -326,7 +326,7 @@ static byte gammaT[256] = { // https://github.com/Aircoookie/WLED/issues/2767#issuecomment-1310961308 // unfortunately NepixelsBu has its own internal table, that kills low brightness values similar to the original WLED table. // see https://github.com/Makuna/NeoPixelBus/blob/master/src/internal/NeoGamma.h -static byte gammaT[256] = { +static const byte gammaT[256] = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, @@ -354,9 +354,11 @@ uint8_t gamma8_cal(uint8_t b, float gamma) // re-calculates & fills gamma table void calcGammaTable(float gamma) { +#if !defined(WLED_USE_CIE_BRIGHTNESS_TABLE) // WLEDMM not possible when using the CIE table for (uint16_t i = 0; i < 256; i++) { gammaT[i] = gamma8_cal(i, gamma); } +#endif } // used for individual channel or brightness gamma correction diff --git a/wled00/wled.h b/wled00/wled.h index 92f4f53b..a6119316 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2303300 +#define VERSION 2303310 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG