From 277c222e3090ac6b7ac14a7249c6b9f8929569af Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Wed, 6 Aug 2025 16:14:13 +0300 Subject: [PATCH 1/6] Add new effects: music strob and flame jet --- platformio.ini | 2 +- wled00/FX.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ wled00/FX.h | 4 ++- wled00/wled.h | 2 +- 4 files changed, 101 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index d3b22653ff..c00dd120b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ # ------------------------------------------------------------------------------ # CI/release binaries -default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods +default_envs = d1_mini, nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods src_dir = ./wled00 data_dir = ./wled00/data diff --git a/wled00/FX.cpp b/wled00/FX.cpp index a680de64de..fe77229dfd 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -10644,6 +10644,100 @@ uint8_t WS2812FX::addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name) } } +/* + Simple bit strob +*/ +uint16_t mode_music_strob(void) { + um_data_t *um_data = getAudioData(); + if (!um_data) return FRAMETIME; + + bool samplePeak = *(bool*)um_data->u_data[3]; + int volumeRaw = *(int16_t*)um_data->u_data[1]; + + long mappedSpeed = map(SEGMENT.speed, 0, 255, 0, 20); + uint8_t fadeBy = 255 - mappedSpeed; + SEGMENT.fade_out(fadeBy); + + uint8_t threshold = SEGMENT.intensity; + + if (samplePeak && volumeRaw > threshold) { + SEGMENT.fill(SEGCOLOR(0)); + } + + return FRAMETIME; +} + +static const char _data_FX_MODE_MUSIC_STROB[] PROGMEM = "Music Strob@Fade speed,Threshold;!,!;!;1v;ix=128,sx=224,si=1"; + +/*--------------------------*/ + +/* + Flame jet +*/ +uint16_t mode_flame_jet(void) { + if (!SEGMENT.is2D()) return mode_static(); + + um_data_t *um_data = getAudioData(); + if (!um_data) return FRAMETIME; + + bool samplePeak = *(bool*)um_data->u_data[3]; + int volumeRaw = *(int16_t*)um_data->u_data[1]; + + long mappedFade = map(SEGMENT.intensity, 0, 255, 0, 64); + uint8_t fade_by = 255 - mappedFade; + + uint8_t threshold = SEGMENT.custom1; + + const uint16_t max_height = SEG_H; + + SEGMENT.fade_out(fade_by); + + if (samplePeak && volumeRaw > threshold && SEGENV.aux0 == 0) { + SEGENV.aux0 = 1; // start animation + } + + // --- Animation --- + if (SEGENV.aux0 > 0) { + long mappedSpeed = map(SEGMENT.speed, 0, 255, 0, 32); + uint16_t rise_amount = 1 + (uint16_t)(volumeRaw * (1 + (uint16_t)mappedSpeed)) / 2000; + + uint16_t start_y = SEG_H - 1; + + for (uint16_t y_offset = 0; y_offset < SEGENV.aux0; y_offset++) { + uint16_t current_y = start_y - y_offset; + + if (current_y >= SEG_H) continue; + + uint32_t base_color = SEGCOLOR(0); + CRGB fastled_color = CRGB(base_color); + + uint8_t heat_reduction = map(y_offset, 0, SEG_H, 0, 180); + fastled_color.g = qsub8(fastled_color.g, heat_reduction); + fastled_color.b = qsub8(fastled_color.b, heat_reduction * 2); + + for (uint16_t x = 0; x < SEG_W; x++) { + CRGB final_color = fastled_color; + + if (hw_random8() < 50) { + final_color.nscale8(220); + } + SEGMENT.setPixelColorXY(x, current_y, final_color); + } + } + + SEGENV.aux0 += rise_amount; + + if (SEGENV.aux0 >= max_height) { + SEGENV.aux0 = 0; + } + } + + return FRAMETIME; +} + +static const char _data_FX_MODE_FLAME_JET[] PROGMEM = "Flame Jet@Base Speed,Trail Length,Threshold;!;!;!;2v;ix=192,sx=128,c1=128,pal=35"; + + void WS2812FX::setupEffectData() { // Solid must be first! (assuming vector is empty upon call to setup) _mode.push_back(&mode_static); @@ -10778,6 +10872,7 @@ void WS2812FX::setupEffectData() { addEffect(FX_MODE_DYNAMIC_SMOOTH, &mode_dynamic_smooth, _data_FX_MODE_DYNAMIC_SMOOTH); // --- 1D audio effects --- + addEffect(FX_MODE_MUSIC_STROB, &mode_music_strob, _data_FX_MODE_MUSIC_STROB); addEffect(FX_MODE_PIXELS, &mode_pixels, _data_FX_MODE_PIXELS); addEffect(FX_MODE_PIXELWAVE, &mode_pixelwave, _data_FX_MODE_PIXELWAVE); addEffect(FX_MODE_JUGGLES, &mode_juggles, _data_FX_MODE_JUGGLES); @@ -10851,6 +10946,7 @@ void WS2812FX::setupEffectData() { addEffect(FX_MODE_2DOCTOPUS, &mode_2Doctopus, _data_FX_MODE_2DOCTOPUS); addEffect(FX_MODE_2DWAVINGCELL, &mode_2Dwavingcell, _data_FX_MODE_2DWAVINGCELL); addEffect(FX_MODE_2DAKEMI, &mode_2DAkemi, _data_FX_MODE_2DAKEMI); // audio + addEffect(FX_MODE_FLAME_JET, &mode_flame_jet, _data_FX_MODE_FLAME_JET); #ifndef WLED_DISABLE_PARTICLESYSTEM2D addEffect(FX_MODE_PARTICLEVOLCANO, &mode_particlevolcano, _data_FX_MODE_PARTICLEVOLCANO); diff --git a/wled00/FX.h b/wled00/FX.h index 097c857caf..24a2274e45 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -374,7 +374,9 @@ extern byte realtimeMode; // used in getMappedPixelIndex() #define FX_MODE_PS1DSONICBOOM 215 #define FX_MODE_PS1DSPRINGY 216 #define FX_MODE_PARTICLEGALAXY 217 -#define MODE_COUNT 218 +#define FX_MODE_MUSIC_STROB 218 +#define FX_MODE_FLAME_JET 219 +#define MODE_COUNT 220 #define BLEND_STYLE_FADE 0x00 // universal diff --git a/wled00/wled.h b/wled00/wled.h index 8ec6655977..ce1162004b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -282,7 +282,7 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument; // Global Variable definitions WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION)); WLED_GLOBAL char releaseString[] _INIT(WLED_RELEASE_NAME); // must include the quotes when defining, e.g -D WLED_RELEASE_NAME=\"ESP32_MULTI_USREMODS\" -#define WLED_CODENAME "Niji" +#define WLED_CODENAME "by Alexander Eroshin" // AP and OTA default passwords (for maximum security change them!) WLED_GLOBAL char apPass[65] _INIT(WLED_AP_PASS); From 5f29ce2c48ef8617c860b2b7e44fbc7c51877f25 Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Wed, 6 Aug 2025 16:29:44 +0300 Subject: [PATCH 2/6] Add new effects: music strob and flame jet --- wled00/wled.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/wled.h b/wled00/wled.h index ce1162004b..8ec6655977 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -282,7 +282,7 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument; // Global Variable definitions WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION)); WLED_GLOBAL char releaseString[] _INIT(WLED_RELEASE_NAME); // must include the quotes when defining, e.g -D WLED_RELEASE_NAME=\"ESP32_MULTI_USREMODS\" -#define WLED_CODENAME "by Alexander Eroshin" +#define WLED_CODENAME "Niji" // AP and OTA default passwords (for maximum security change them!) WLED_GLOBAL char apPass[65] _INIT(WLED_AP_PASS); From 70e06db03506c53aa1247b26657b7120debba612 Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Wed, 6 Aug 2025 16:35:32 +0300 Subject: [PATCH 3/6] Add new effects: music strob and flame jet --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index c00dd120b5..352623641f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ # ------------------------------------------------------------------------------ # CI/release binaries -default_envs = d1_mini, nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods +default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32dev_V4, esp32_eth, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover, usermods src_dir = ./wled00 data_dir = ./wled00/data From e7b1ec0ceb90be87268ec272bf81f6def8c71131 Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Fri, 8 Aug 2025 18:42:19 +0300 Subject: [PATCH 4/6] fix for 1D flame jet --- wled00/FX.cpp | 79 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index fe77229dfd..f6e720e075 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -10675,8 +10675,6 @@ static const char _data_FX_MODE_MUSIC_STROB[] PROGMEM = "Music Strob@Fade speed, Flame jet */ uint16_t mode_flame_jet(void) { - if (!SEGMENT.is2D()) return mode_static(); - um_data_t *um_data = getAudioData(); if (!um_data) return FRAMETIME; @@ -10685,13 +10683,10 @@ uint16_t mode_flame_jet(void) { long mappedFade = map(SEGMENT.intensity, 0, 255, 0, 64); uint8_t fade_by = 255 - mappedFade; + SEGMENT.fade_out(fade_by); uint8_t threshold = SEGMENT.custom1; - const uint16_t max_height = SEG_H; - - SEGMENT.fade_out(fade_by); - if (samplePeak && volumeRaw > threshold && SEGENV.aux0 == 0) { SEGENV.aux0 = 1; // start animation } @@ -10701,42 +10696,68 @@ uint16_t mode_flame_jet(void) { long mappedSpeed = map(SEGMENT.speed, 0, 255, 0, 32); uint16_t rise_amount = 1 + (uint16_t)(volumeRaw * (1 + (uint16_t)mappedSpeed)) / 2000; - uint16_t start_y = SEG_H - 1; - - for (uint16_t y_offset = 0; y_offset < SEGENV.aux0; y_offset++) { - uint16_t current_y = start_y - y_offset; - - if (current_y >= SEG_H) continue; + if (SEGMENT.is2D()) { + // --- 2D LOGIC --- + const uint16_t max_height = SEG_H; + uint16_t start_y = SEG_H - 1; + + for (uint16_t y_offset = 0; y_offset < SEGENV.aux0; y_offset++) { + uint16_t current_y = start_y - y_offset; + if (current_y >= SEG_H) continue; // Boundary check + + uint32_t base_color = SEGCOLOR(0); + CRGB fastled_color = CRGB(base_color); + + uint8_t heat_reduction = map(y_offset, 0, SEG_H, 0, 180); + fastled_color.g = qsub8(fastled_color.g, heat_reduction); + fastled_color.b = qsub8(fastled_color.b, heat_reduction * 2); + + for (uint16_t x = 0; x < SEG_W; x++) { + CRGB final_color = fastled_color; + if (hw_random8() < 50) { + final_color.nscale8(220); + } + SEGMENT.setPixelColorXY(x, current_y, final_color); + } + } + SEGENV.aux0 += rise_amount; + if (SEGENV.aux0 >= max_height) { + SEGENV.aux0 = 0; + } - uint32_t base_color = SEGCOLOR(0); - CRGB fastled_color = CRGB(base_color); + } else { + // --- 1D LOGIC --- + const uint16_t max_height = SEGLEN; + uint16_t start_index = 0; // Or SEGLEN - 1 if you want it from the other end - uint8_t heat_reduction = map(y_offset, 0, SEG_H, 0, 180); - fastled_color.g = qsub8(fastled_color.g, heat_reduction); - fastled_color.b = qsub8(fastled_color.b, heat_reduction * 2); + for (uint16_t i_offset = 0; i_offset < SEGENV.aux0; i_offset++) { + uint16_t current_index = start_index + i_offset; + if (current_index >= SEGLEN) continue; // Boundary check - for (uint16_t x = 0; x < SEG_W; x++) { - CRGB final_color = fastled_color; + uint32_t base_color = SEGCOLOR(0); + CRGB fastled_color = CRGB(base_color); + + uint8_t heat_reduction = map(i_offset, 0, SEGLEN, 0, 180); + fastled_color.g = qsub8(fastled_color.g, heat_reduction); + fastled_color.b = qsub8(fastled_color.b, heat_reduction * 2); if (hw_random8() < 50) { - final_color.nscale8(220); + fastled_color.nscale8(220); } - SEGMENT.setPixelColorXY(x, current_y, final_color); + SEGMENT.setPixelColor(current_index, fastled_color); + } + SEGENV.aux0 += rise_amount; + if (SEGENV.aux0 >= max_height) { + SEGENV.aux0 = 0; } - } - - SEGENV.aux0 += rise_amount; - - if (SEGENV.aux0 >= max_height) { - SEGENV.aux0 = 0; } } return FRAMETIME; } -static const char _data_FX_MODE_FLAME_JET[] PROGMEM = "Flame Jet@Base Speed,Trail Length,Threshold;!;!;!;2v;ix=192,sx=128,c1=128,pal=35"; - +// Также обновите строку метаданных, убрав из нее "2", чтобы показать, что эффект работает и в 1D +static const char _data_FX_MODE_FLAME_JET[] PROGMEM = "Flame Jet@Base Speed,Trail Length,Threshold;!;!;1v;ix=192,sx=128,c1=128,pal=35,si=1"; void WS2812FX::setupEffectData() { // Solid must be first! (assuming vector is empty upon call to setup) From 9ee7e4ea2faa4256d251b90feaad4c7be66c09e7 Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Fri, 8 Aug 2025 18:44:12 +0300 Subject: [PATCH 5/6] delete temp comment --- wled00/FX.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index f6e720e075..915bc160d6 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -10669,8 +10669,6 @@ uint16_t mode_music_strob(void) { static const char _data_FX_MODE_MUSIC_STROB[] PROGMEM = "Music Strob@Fade speed,Threshold;!,!;!;1v;ix=128,sx=224,si=1"; -/*--------------------------*/ - /* Flame jet */ @@ -10756,7 +10754,6 @@ uint16_t mode_flame_jet(void) { return FRAMETIME; } -// Также обновите строку метаданных, убрав из нее "2", чтобы показать, что эффект работает и в 1D static const char _data_FX_MODE_FLAME_JET[] PROGMEM = "Flame Jet@Base Speed,Trail Length,Threshold;!;!;1v;ix=192,sx=128,c1=128,pal=35,si=1"; void WS2812FX::setupEffectData() { From d2874e1b41c00073d69ab8f96ac967cb757baa6e Mon Sep 17 00:00:00 2001 From: Alexander Eroshin Date: Fri, 8 Aug 2025 19:12:04 +0300 Subject: [PATCH 6/6] strob to strobe --- wled00/FX.cpp | 8 ++++---- wled00/FX.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 915bc160d6..7ac0a6e1ec 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -10645,9 +10645,9 @@ uint8_t WS2812FX::addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name) } /* - Simple bit strob + Simple bit strobe */ -uint16_t mode_music_strob(void) { +uint16_t mode_music_strobe(void) { um_data_t *um_data = getAudioData(); if (!um_data) return FRAMETIME; @@ -10667,7 +10667,7 @@ uint16_t mode_music_strob(void) { return FRAMETIME; } -static const char _data_FX_MODE_MUSIC_STROB[] PROGMEM = "Music Strob@Fade speed,Threshold;!,!;!;1v;ix=128,sx=224,si=1"; +static const char _data_FX_MODE_MUSIC_STROBE[] PROGMEM = "Music Strobe@Fade speed,Threshold;!,!;!;1v;ix=128,sx=224,si=1"; /* Flame jet @@ -10890,7 +10890,7 @@ void WS2812FX::setupEffectData() { addEffect(FX_MODE_DYNAMIC_SMOOTH, &mode_dynamic_smooth, _data_FX_MODE_DYNAMIC_SMOOTH); // --- 1D audio effects --- - addEffect(FX_MODE_MUSIC_STROB, &mode_music_strob, _data_FX_MODE_MUSIC_STROB); + addEffect(FX_MODE_MUSIC_STROBE, &mode_music_strobe, _data_FX_MODE_MUSIC_STROBE); addEffect(FX_MODE_PIXELS, &mode_pixels, _data_FX_MODE_PIXELS); addEffect(FX_MODE_PIXELWAVE, &mode_pixelwave, _data_FX_MODE_PIXELWAVE); addEffect(FX_MODE_JUGGLES, &mode_juggles, _data_FX_MODE_JUGGLES); diff --git a/wled00/FX.h b/wled00/FX.h index 24a2274e45..e164a596ba 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -374,7 +374,7 @@ extern byte realtimeMode; // used in getMappedPixelIndex() #define FX_MODE_PS1DSONICBOOM 215 #define FX_MODE_PS1DSPRINGY 216 #define FX_MODE_PARTICLEGALAXY 217 -#define FX_MODE_MUSIC_STROB 218 +#define FX_MODE_MUSIC_STROBE 218 #define FX_MODE_FLAME_JET 219 #define MODE_COUNT 220