From 693bf4816b78bd9bf58f0312141ce2dfe7388f46 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 30 Jun 2024 10:44:25 +0200 Subject: [PATCH] Minor tweaks. --- wled00/FX.cpp | 7 +++---- wled00/bus_manager.cpp | 6 +++--- wled00/bus_manager.h | 3 ++- wled00/colors.cpp | 10 +++++----- wled00/data/index.css | 1 + wled00/data/index.js | 19 ++++++++++--------- wled00/data/settings_leds.htm | 2 +- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 4b7f9ce36..c50b9383f 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -4875,7 +4875,7 @@ uint16_t mode_2DBlackHole(void) { // By: Stepko https://editor.soulma // central white dot SEGMENT.setPixelColorXY(cols/2, rows/2, WHITE); // blur everything a bit - SEGMENT.blur(16); + SEGMENT.blur(cols*rows > 100 ? 16 : 0); return FRAMETIME; } // mode_2DBlackHole() @@ -5671,8 +5671,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g const uint8_t kBorderWidth = 2; SEGMENT.fadeToBlackBy(24); - uint8_t blurAmount = SEGMENT.custom3>>1; // reduced resolution slider - SEGMENT.blur(blurAmount); + SEGMENT.blur(SEGMENT.custom3>>1); // Use two out-of-sync sine waves int i = beatsin8(19, kBorderWidth, cols-kBorderWidth); @@ -6461,7 +6460,7 @@ uint16_t mode_2DWaverly(void) { SEGMENT.addPixelColorXY((cols - 1) - i, (rows - 1) - j, ColorFromPalette(SEGPALETTE, map(j, 0, thisMax, 250, 0), 255, LINEARBLEND)); } } - SEGMENT.blur(16); + SEGMENT.blur(cols*rows > 100 ? 16 : 0); return FRAMETIME; } // mode_2DWaverly() diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 73d3d0fb3..1f70bb257 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -385,14 +385,14 @@ BusPwm::BusPwm(BusConfig &bc) uint8_t numPins = NUM_PWM_PINS(bc.type); _frequency = bc.frequency ? bc.frequency : WLED_PWM_FREQ; - #ifdef ESP8266 +#ifdef ESP8266 // duty cycle resolution (_depth) can be extracted from this formula: 1MHz > _frequency * 2^_depth if (_frequency > 1760) _depth = 8; else if (_frequency > 880) _depth = 9; else _depth = 10; // WLED_PWM_FREQ <= 880Hz analogWriteRange((1<<_depth)-1); analogWriteFreq(_frequency); - #else +#else _ledcStart = pinManager.allocateLedc(numPins); if (_ledcStart == 255) { //no more free LEDC channels deallocatePins(); return; @@ -402,7 +402,7 @@ BusPwm::BusPwm(BusConfig &bc) else if (_frequency > 39062) _depth = 10; else if (_frequency > 19531) _depth = 11; else _depth = 12; // WLED_PWM_FREQ <= 19531Hz - #endif +#endif for (unsigned i = 0; i < numPins; i++) { uint8_t currentPin = bc.pins[i]; diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b1f5f13c8..e2c4239d8 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -169,10 +169,11 @@ class Bus { type == TYPE_FW1906 || type == TYPE_WS2805 ) return true; return false; } - static int16_t getCCT() { return _cct; } + static inline int16_t getCCT() { return _cct; } static void setCCT(int16_t cct) { _cct = cct; } + static inline uint8_t getCCTBlend() { return _cctBlend; } static void setCCTBlend(uint8_t b) { if (b > 100) b = 100; _cctBlend = (b * 127) / 100; diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 30d2c069e..55fb5d477 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -208,13 +208,13 @@ CRGBPalette16 generateRandomPalette(void) //generate fully random palette void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb { - float h = ((float)hue)/65535.0f; + float h = ((float)hue)/10922.5f; // hue*6/65535 float s = ((float)sat)/255.0f; - int i = floorf(h*6); - float f = h * 6.0f - i; + int i = int(h); + float f = h - i; int p = int(255.0f * (1.0f-s)); - int q = int(255.0f * (1.0f-f*s)); - int t = int(255.0f * (1.0f-(1.0f-f)*s)); + int q = int(255.0f * (1.0f-s*f)); + int t = int(255.0f * (1.0f-s*(1.0f-f))); p = constrain(p, 0, 255); q = constrain(q, 0, 255); t = constrain(t, 0, 255); diff --git a/wled00/data/index.css b/wled00/data/index.css index 6ac3f3a1f..0952cca21 100644 --- a/wled00/data/index.css +++ b/wled00/data/index.css @@ -923,6 +923,7 @@ select.sel-p, select.sel-pl, select.sel-ple { margin: 5px 0; width: 100%; height: 40px; + padding: 0 20px 0 8px; } div.sel-p { position: relative; diff --git a/wled00/data/index.js b/wled00/data/index.js index 58cf7b466..adddc38fb 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -588,7 +588,7 @@ function loadFXData(callback = null) fxdata = []; if (!retry) { retry = true; - setTimeout(loadFXData, 500); // retry + setTimeout(()=>{loadFXData(loadFX);}, 500); // retry } showToast(e, true); }) @@ -1707,9 +1707,7 @@ function requestJson(command=null) fetch(getURL('/json/si'), { method: type, - headers: { - "Content-type": "application/json; charset=UTF-8" - }, + headers: {"Content-Type": "application/json; charset=UTF-8"}, body: req }) .then(res => { @@ -2692,7 +2690,9 @@ function setBalance(b) function rmtTgl(ip,i) { event.preventDefault(); event.stopPropagation(); - fetch(`http://${ip}/win&T=2`, {method: 'get'}) + fetch(`http://${ip}/win&T=2`, { + method: 'get' + }) .then((r)=>{ return r.text(); }) @@ -2784,10 +2784,7 @@ function loadPalettesData(callback = null) function getPalettesData(page, callback) { fetch(getURL(`/json/palx?page=${page}`), { - method: 'get', - headers: { - "Content-type": "application/json; charset=UTF-8" - } + method: 'get' }) .then(res => { if (!res.ok) showErrorToast(); @@ -2800,6 +2797,10 @@ function getPalettesData(page, callback) else callback(); }) .catch((error)=>{ + if (!retry) { + retry = true; + setTimeout(()=>{getPalettesData(page,callback);}, 500); // retry + } showToast(error, true); }); } diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index ac40afa0b..164dc5a77 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -290,7 +290,7 @@ // do we have a led count field if (nm=="LC") { let c = parseInt(LC.value,10); //get LED count - if (c > 300 && i < 8) maxB = min(oMaxB,10); //TODO: hard limit for buses when using ESP32 parallel I2S + if (c > 300 && i < 8) maxB = oMaxB - max(maxD-7,0); //TODO: hard limit for buses when using ESP32 parallel I2S if (!customStarts || !startsDirty[n]) gId("ls"+n).value=sLC; //update start value gId("ls"+n).disabled = !customStarts; //enable/disable field editing if (c) {