From f2c30ba3f74c5b5ea597599e149397591a80fe44 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 17 Feb 2024 12:58:04 +0100 Subject: [PATCH 1/4] Effect: modified KITT (Scanner) - add delay - add dual checkmark - rename Fade rate to Trail (inverse) - makes Scanner Dual obsolete --- wled00/FX.cpp | 83 +++++++++++++++++++++++++++------------------------ wled00/FX.h | 2 +- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 1f626bc9a..4d2c84511 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1125,57 +1125,62 @@ uint16_t mode_running_random(void) { static const char _data_FX_MODE_RUNNING_RANDOM[] PROGMEM = "Stream@!,Zone size;;!"; -uint16_t larson_scanner(bool dual) { - if (SEGLEN == 1) return mode_static(); - uint16_t counter = strip.now * ((SEGMENT.speed >> 2) +8); - uint16_t index = (counter * SEGLEN) >> 16; - - SEGMENT.fade_out(SEGMENT.intensity); - - if (SEGENV.step > index && SEGENV.step - index > SEGLEN/2) { - SEGENV.aux0 = !SEGENV.aux0; - } - - for (int i = SEGENV.step; i < index; i++) { - uint16_t j = (SEGENV.aux0)?i:SEGLEN-1-i; - SEGMENT.setPixelColor( j, SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0)); - } - if (dual) { - uint32_t c; - if (SEGCOLOR(2) != 0) { - c = SEGCOLOR(2); - } else { - c = SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0); - } - - for (int i = SEGENV.step; i < index; i++) { - uint16_t j = (SEGENV.aux0)?SEGLEN-1-i:i; - SEGMENT.setPixelColor(j, c); - } - } - - SEGENV.step = index; - return FRAMETIME; -} - - /* * K.I.T.T. */ uint16_t mode_larson_scanner(void){ - return larson_scanner(false); -} -static const char _data_FX_MODE_LARSON_SCANNER[] PROGMEM = "Scanner@!,Fade rate;!,!;!;;m12=0"; + if (SEGLEN == 1) return mode_static(); + const unsigned speed = FRAMETIME * map(SEGMENT.speed, 0, 255, 96, 2); // map into useful range + const unsigned pixels = SEGLEN / speed; // how many pixels to advance per frame + + SEGMENT.fade_out(255-SEGMENT.intensity); + + if (SEGENV.step > strip.now) return FRAMETIME; // we have a pause + + unsigned index = SEGENV.aux1 + pixels; + // are we slow enough to use frames per pixel? + if (pixels == 0) { + const unsigned frames = speed / SEGLEN; // how many frames per 1 pixel + if (SEGENV.step++ < frames) return FRAMETIME; + SEGENV.step = 0; + index++; + } + + if (index > SEGLEN) { + + SEGENV.aux0 = !SEGENV.aux0; // change direction + SEGENV.aux1 = 0; // reset position + // set delay + if (SEGENV.aux0 || SEGMENT.check2) SEGENV.step = strip.now + SEGMENT.custom1 * 25; // multiply by 25ms + else SEGENV.step = 0; + + } else { + + // paint as many pixels as needed + for (unsigned i = SEGENV.aux1; i < index; i++) { + unsigned j = (SEGENV.aux0) ? i : SEGLEN - 1 - i; + uint32_t c = SEGMENT.color_from_palette(j, true, PALETTE_SOLID_WRAP, 0); + SEGMENT.setPixelColor(j, c); + if (SEGMENT.check1) { + SEGMENT.setPixelColor(SEGLEN - 1 - j, SEGCOLOR(2) ? SEGCOLOR(2) : c); + } + } + SEGENV.aux1 = index; + } + return FRAMETIME; +} +static const char _data_FX_MODE_LARSON_SCANNER[] PROGMEM = "Scanner@!,Trail,Delay,,,Dual,Bi-delay;!,!,!;!;;m12=0,c1=0"; /* * Creates two Larson scanners moving in opposite directions * Custom mode by Keith Lord: https://github.com/kitesurfer1404/WS2812FX/blob/master/src/custom/DualLarson.h */ uint16_t mode_dual_larson_scanner(void){ - return larson_scanner(true); + SEGMENT.check1 = true; + return mode_larson_scanner(); } -static const char _data_FX_MODE_DUAL_LARSON_SCANNER[] PROGMEM = "Scanner Dual@!,Fade rate;!,!,!;!;;m12=0"; +static const char _data_FX_MODE_DUAL_LARSON_SCANNER[] PROGMEM = "Scanner Dual@!,Trail,Delay,,,Dual,Bi-delay;!,!,!;!;;m12=0,c1=0"; /* diff --git a/wled00/FX.h b/wled00/FX.h index 3aa19bc35..34001aace 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -187,7 +187,7 @@ #define FX_MODE_LIGHTNING 57 #define FX_MODE_ICU 58 #define FX_MODE_MULTI_COMET 59 -#define FX_MODE_DUAL_LARSON_SCANNER 60 +#define FX_MODE_DUAL_LARSON_SCANNER 60 // candidate for removal (use Scanner with with check 1) #define FX_MODE_RANDOM_CHASE 61 #define FX_MODE_OSCILLATE 62 #define FX_MODE_PRIDE_2015 63 From bd1c06a7a7f811e40381ee692944a2ffe1b5d062 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Wed, 10 Apr 2024 20:06:46 +0200 Subject: [PATCH 2/4] Changelog update --- CHANGELOG.md | 19 ++++++++++++++++++- wled00/wled.h | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f6df2de..f29c05f73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ ## WLED changelog +#### Build 2404100 +- Internals: #3859, #3862, #3873, #3875 +- Prefer I2S1 over RMT on ESP32 +- usermod for Adafruit MAX17048 (#3667 by @ccruz09) +- Runtime detection of ESP32 PICO, general PSRAM support +- Extend JSON API "info" object + - add "clock" - CPU clock in MHz + - add "flash" - flash size in MB +- Fix for #3879 +- Analog PWM fix for ESP8266 (#3887 by @gaaat98) +- Fix for #3870 (#3880 by @DedeHai) +- ESP32 S3/S2 touch fix (#3798 by @DedeHai) +- PIO env. PSRAM fix for S3 & S3 with 4M flash + - audioreactive always included for S3 & S2 +- Fix for #3889 +- BREAKING: Effect: modified KITT (Scanner) (#3763) + #### Build 2403280 - Individual color channel control for JSON API (fixes #3860) - "col":[int|string|object|array, int|string|object|array, int|string|object|array] @@ -16,7 +33,7 @@ - v0.15.0-b2 - WS2805 support (RGB + WW + CW, 600kbps) - Unified PSRAM use -- NeoPixelBus v2.7.9 (for future WS2805 support) +- NeoPixelBus v2.7.9 - Ubiquitous PSRAM mode for all variants of ESP32 - SSD1309_64 I2C Support for FLD Usermod (#3836 by @THATDONFC) - Palette cycling fix (add support for `{"seg":[{"pal":"X~Y~"}]}` or `{"seg":[{"pal":"X~Yr"}]}`) diff --git a/wled00/wled.h b/wled00/wled.h index f96be3c1b..ef53e643f 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2404050 +#define VERSION 2404100 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG From 30435e640678bc6a4b3aa363015b5c7a4d6d2945 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 11 Apr 2024 20:11:29 +0200 Subject: [PATCH 3/4] 2D compile fix --- wled00/FX.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wled00/FX.h b/wled00/FX.h index 2b1a05229..829307918 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -635,6 +635,7 @@ typedef struct Segment { #else inline uint16_t XY(uint16_t x, uint16_t y) { return x; } inline void setPixelColorXY(int x, int y, uint32_t c) { setPixelColor(x, c); } + inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColor(int(x), c); } inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColor(x, RGBW32(r,g,b,w)); } inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0)); } inline void setPixelColorXY(float x, float y, uint32_t c, bool aa = true) { setPixelColor(x, c, aa); } From 94cdd884746636b5d0843ff34ac2af5fbce51d47 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sat, 13 Apr 2024 18:25:25 +0200 Subject: [PATCH 4/4] Version bump B3 - fix for #3896 - fix WS2815 current - conditional AA setPixelColor() --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- wled00/FX.cpp | 8 ++++++-- wled00/FX.h | 6 ++++++ wled00/FX_2Dfcn.cpp | 2 ++ wled00/FX_fcn.cpp | 2 ++ wled00/data/settings_leds.htm | 4 ++-- wled00/improv.cpp | 2 +- wled00/wled.h | 4 ++-- 10 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f29c05f73..59c58dfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## WLED changelog +#### Build 2404120 +- v0.15.0-b3 +- fix for #3896 & WS2815 current saving +- conditional compile for AA setPixelColor() + #### Build 2404100 - Internals: #3859, #3862, #3873, #3875 - Prefer I2S1 over RMT on ESP32 diff --git a/package-lock.json b/package-lock.json index db66b554b..b9dc5e0e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wled", - "version": "0.15.0-b2", + "version": "0.15.0-b3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wled", - "version": "0.15.0-b2", + "version": "0.15.0-b3", "license": "ISC", "dependencies": { "clean-css": "^5.3.3", diff --git a/package.json b/package.json index 6f7d634d3..b19ecc48a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wled", - "version": "0.15.0-b2", + "version": "0.15.0-b3", "description": "Tools for WLED project", "main": "tools/cdata.js", "directories": { diff --git a/wled00/FX.cpp b/wled00/FX.cpp index c0495ea24..5592f7ba8 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3018,8 +3018,12 @@ uint16_t mode_bouncing_balls(void) { } int pos = roundf(balls[i].height * (SEGLEN - 1)); + #ifdef WLED_USE_AA_PIXELS if (SEGLEN<32) SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index else SEGMENT.setPixelColor(balls[i].height + (stripNr+1)*10.0f, color); + #else + SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index + #endif } } }; @@ -6052,8 +6056,8 @@ uint16_t mode_2Dfloatingblobs(void) { } } uint32_t c = SEGMENT.color_from_palette(blob->color[i], false, false, 0); - if (blob->r[i] > 1.f) SEGMENT.fill_circle(blob->x[i], blob->y[i], roundf(blob->r[i]), c); - else SEGMENT.setPixelColorXY(blob->x[i], blob->y[i], c); + if (blob->r[i] > 1.f) SEGMENT.fill_circle(roundf(blob->x[i]), roundf(blob->y[i]), roundf(blob->r[i]), c); + else SEGMENT.setPixelColorXY((int)roundf(blob->x[i]), (int)roundf(blob->y[i]), c); // move x if (blob->x[i] + blob->r[i] >= cols - 1) blob->x[i] += (blob->sX[i] * ((cols - 1 - blob->x[i]) / blob->r[i] + 0.005f)); else if (blob->x[i] - blob->r[i] <= 0) blob->x[i] += (blob->sX[i] * (blob->x[i] / blob->r[i] + 0.005f)); diff --git a/wled00/FX.h b/wled00/FX.h index 829307918..66e748602 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -575,9 +575,11 @@ typedef struct Segment { inline void setPixelColor(unsigned n, uint32_t c) { setPixelColor(int(n), c); } inline void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); } inline void setPixelColor(int n, CRGB c) { setPixelColor(n, RGBW32(c.r,c.g,c.b,0)); } + #ifdef WLED_USE_AA_PIXELS void setPixelColor(float i, uint32_t c, bool aa = true); inline void setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = true) { setPixelColor(i, RGBW32(r,g,b,w), aa); } inline void setPixelColor(float i, CRGB c, bool aa = true) { setPixelColor(i, RGBW32(c.r,c.g,c.b,0), aa); } + #endif uint32_t getPixelColor(int i); // 1D support functions (some implement 2D as well) void blur(uint8_t); @@ -603,9 +605,11 @@ typedef struct Segment { inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColorXY(int(x), int(y), c); } inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); } + #ifdef WLED_USE_AA_PIXELS void setPixelColorXY(float x, float y, uint32_t c, bool aa = true); inline void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColorXY(x, y, RGBW32(r,g,b,w), aa); } inline void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), aa); } + #endif uint32_t getPixelColorXY(uint16_t x, uint16_t y); // 2D support functions inline void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) { setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend)); } @@ -638,9 +642,11 @@ typedef struct Segment { inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColor(int(x), c); } inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColor(x, RGBW32(r,g,b,w)); } inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0)); } + #ifdef WLED_USE_AA_PIXELS inline void setPixelColorXY(float x, float y, uint32_t c, bool aa = true) { setPixelColor(x, c, aa); } inline void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColor(x, RGBW32(r,g,b,w), aa); } inline void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0), aa); } + #endif inline uint32_t getPixelColorXY(uint16_t x, uint16_t y) { return getPixelColor(x); } inline void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t c, uint8_t blend) { blendPixelColor(x, c, blend); } inline void blendPixelColorXY(uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColor(x, RGBW32(c.r,c.g,c.b,0), blend); } diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index fde05928e..b049ab6f0 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -218,6 +218,7 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) } } +#ifdef WLED_USE_AA_PIXELS // anti-aliased version of setPixelColorXY() void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa) { @@ -261,6 +262,7 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa) setPixelColorXY(uint16_t(roundf(fX)), uint16_t(roundf(fY)), col); } } +#endif // returns RGBW values of pixel uint32_t IRAM_ATTR Segment::getPixelColorXY(uint16_t x, uint16_t y) { diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index c9dd082ea..9ab1f578b 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -777,6 +777,7 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) } } +#ifdef WLED_USE_AA_PIXELS // anti-aliased normalized version of setPixelColor() void Segment::setPixelColor(float i, uint32_t col, bool aa) { @@ -809,6 +810,7 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa) setPixelColor(uint16_t(roundf(fC)) | (vStrip<<16), col); } } +#endif uint32_t IRAM_ATTR Segment::getPixelColor(int i) { diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index dddedd471..4ad4cb16e 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -153,7 +153,7 @@ { const t = parseInt(d.Sf["LT"+n].value); // LED type SELECT gId('LAdis'+n).style.display = s.selectedIndex==5 ? "inline" : "none"; - d.Sf["LA"+n].value = s.value==="0" ? 55 : s.value; + if (s.value!=="0") d.Sf["LA"+n].value = s.value; d.Sf["LA"+n].min = (isVir(t) || isAna(t)) ? 0 : 1; } function setABL() @@ -417,7 +417,7 @@ mA/LED:
- +
PSU: mA
Color Order: diff --git a/wled00/improv.cpp b/wled00/improv.cpp index 0090b4bd6..1536218ff 100644 --- a/wled00/improv.cpp +++ b/wled00/improv.cpp @@ -210,7 +210,7 @@ void sendImprovInfoResponse() { //Use serverDescription if it has been changed from the default "WLED", else mDNS name bool useMdnsName = (strcmp(serverDescription, "WLED") == 0 && strlen(cmDNS) > 0); char vString[20]; - sprintf_P(vString, PSTR("0.15.0-b2/%i"), VERSION); + sprintf_P(vString, PSTR("0.15.0-b3/%i"), VERSION); const char *str[4] = {"WLED", vString, bString, useMdnsName ? cmDNS : serverDescription}; sendImprovRPCResult(ImprovRPCType::Request_Info, 4, str); diff --git a/wled00/wled.h b/wled00/wled.h index ef53e643f..b94f7790b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -3,12 +3,12 @@ /* Main sketch, global variable declarations @title WLED project sketch - @version 0.15.0-b2 + @version 0.15.0-b3 @author Christian Schwinne */ // version code in format yymmddb (b = daily build) -#define VERSION 2404100 +#define VERSION 2404120 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG