diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 632d4cc3..0f0ce4e0 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -6,7 +6,7 @@ //see https://github.com/Aircoookie/WLED/issues/2 for flicker free ESP32 support //PIN CONFIGURATION -#define LEDPIN 5 //strip pin. Any for ESP32, gpio2 is recommended for ESP8266 +#define LEDPIN 3 //strip pin. Any for ESP32, gpio2 is recommended for ESP8266 #define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) #define IR_PIN 4 //infrared pin. #define AUXPIN 15 //unused auxiliary output pin diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index 83169cfe..e14a7c9e 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -892,10 +892,10 @@ uint16_t WS2812FX::mode_theater_chase_rainbow(void) { * Running lights effect with smooth sine transition. */ uint16_t WS2812FX::mode_running_lights(void) { - uint8_t x_scale = (SEGMENT.intensity >> 3) + (SEGMENT.intensity >> 4); + uint8_t x_scale = SEGMENT.intensity >> 2; for(uint16_t i=0; i < SEGMENT_LENGTH; i++) { - uint8_t s = sin8(i*x_scale +(SEGMENT_RUNTIME.counter_mode_step >> 3)); + uint8_t s = sin8(i*x_scale + (SEGMENT_RUNTIME.counter_mode_step >> 4)); setPixelColor(SEGMENT.start + i, color_blend(SEGMENT.colors[1], color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 0), s)); } SEGMENT_RUNTIME.counter_mode_step += SEGMENT.speed; @@ -1546,42 +1546,44 @@ uint16_t WS2812FX::mode_fire_flicker(void) { } +/* + * Gradient run base function + */ +uint16_t WS2812FX::gradient_base(bool loading) { + if (SEGMENT_RUNTIME.counter_mode_call == 0) SEGMENT_RUNTIME.counter_mode_step = 0; + float per,val; //0.0 = sec 1.0 = pri + float brd = SEGMENT.intensity; + if (!loading) brd = SEGMENT.intensity/2; + if (brd <1.0) brd = 1.0; + int pp = SEGMENT_RUNTIME.counter_mode_step; + int p1 = pp-SEGMENT_LENGTH; + int p2 = pp+SEGMENT_LENGTH; + + for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) + { + if (loading) + { + val = abs(((i>pp) ? p2:pp) -i); + } else { + val = min(abs(pp-i),min(abs(p1-i),abs(p2-i))); + } + per = val/brd; + if (per >1.0) per = 1.0; + setPixelColor(SEGMENT.start + i, color_blend(SEGMENT.colors[0], color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 1), per*255)); + } + + SEGMENT_RUNTIME.counter_mode_step++; + if (SEGMENT_RUNTIME.counter_mode_step > SEGMENT.stop) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.start; + if (SEGMENT.speed == 0) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.start + (SEGMENT_LENGTH >> 1); + return SPEED_FORMULA_L; +} + + /* * Gradient run */ uint16_t WS2812FX::mode_gradient(void) { - if (SEGMENT_RUNTIME.counter_mode_call == 0) SEGMENT_RUNTIME.counter_mode_step = 0; - byte p_w = (SEGMENT.colors[0] & 0xFF000000) >> 24; - byte p_r = (SEGMENT.colors[0] & 0xFF0000) >> 16; - byte p_g = (SEGMENT.colors[0] & 0xFF00) >> 8; - byte p_b = SEGMENT.colors[0] & 0xFF; - byte p_w2 = (SEGMENT.colors[1] & 0xFF000000) >> 24; - byte p_r2 = (SEGMENT.colors[1] & 0xFF0000) >> 16; - byte p_g2 = (SEGMENT.colors[1] & 0xFF00) >> 8; - byte p_b2 = SEGMENT.colors[1] & 0xFF; - byte nw,nr,ng,nb; - float per,val; //0.0 = sec 1.0 = pri - float brd = SEGMENT.intensity/2; if (brd <1.0) brd = 1.0; - int pp = SEGMENT_RUNTIME.counter_mode_step; - int p1 = pp-SEGMENT_LENGTH; - int p2 = pp+SEGMENT_LENGTH; - - for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) - { - val = min(abs(pp-i),min(abs(p1-i),abs(p2-i))); - per = val/brd; - if (per >1.0) per = 1.0; - nw = p_w+((p_w2 - p_w)*per); - nr = p_r+((p_r2 - p_r)*per); - ng = p_g+((p_g2 - p_g)*per); - nb = p_b+((p_b2 - p_b)*per); - setPixelColor(i,nr,ng,nb,nw); - } - - SEGMENT_RUNTIME.counter_mode_step++; - if (SEGMENT_RUNTIME.counter_mode_step > SEGMENT.stop) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.start; - if (SEGMENT.speed == 0) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.start + (SEGMENT_LENGTH >> 1); - return SPEED_FORMULA_L; + return gradient_base(false); } @@ -1589,39 +1591,7 @@ uint16_t WS2812FX::mode_gradient(void) { * Gradient run with hard transition */ uint16_t WS2812FX::mode_loading(void) { - if (SEGMENT_RUNTIME.counter_mode_call == 0) SEGMENT_RUNTIME.counter_mode_step = 0; - byte p_w = (SEGMENT.colors[0] & 0xFF000000) >> 24; - byte p_r = (SEGMENT.colors[0] & 0x00FF0000) >> 16; - byte p_g = (SEGMENT.colors[0] & 0x0000FF00) >> 8; - byte p_b = (SEGMENT.colors[0] & 0x000000FF) >> 0; - byte p_w2 = (SEGMENT.colors[1] & 0xFF000000) >> 24; - byte p_r2 = (SEGMENT.colors[1] & 0x00FF0000) >> 16; - byte p_g2 = (SEGMENT.colors[1] & 0x0000FF00) >> 8; - byte p_b2 = (SEGMENT.colors[1] & 0x000000FF) >> 0; - byte nw,nr,ng,nb; - float per,val; //0.0 = sec 1.0 = pri - float brd = SEGMENT.intensity; if (brd <1.0) brd = 1.0; - int pp = SEGMENT_RUNTIME.counter_mode_step; - int p1 = pp+SEGMENT_LENGTH; - - for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) - { - pp = SEGMENT_RUNTIME.counter_mode_step; - if (i > pp) pp+=SEGMENT_LENGTH; - val = abs(pp-i); - per = val/brd; - if (per >1.0) per = 1.0; - nw = p_w+((p_w2 - p_w)*per); - nr = p_r+((p_r2 - p_r)*per); - ng = p_g+((p_g2 - p_g)*per); - nb = p_b+((p_b2 - p_b)*per); - setPixelColor(i,nr,ng,nb,nw); - } - - SEGMENT_RUNTIME.counter_mode_step++; - if (SEGMENT_RUNTIME.counter_mode_step > SEGMENT.stop) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.start; - if (SEGMENT.speed == 0) SEGMENT_RUNTIME.counter_mode_step = SEGMENT.stop; - return SPEED_FORMULA_L; + return gradient_base(true); } @@ -2276,7 +2246,7 @@ uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8 if (SEGMENT.palette == 0 && mcol < 3) return SEGMENT.colors[mcol]; //WS2812FX default uint8_t paletteIndex = i; if (mapping) paletteIndex = map(i,SEGMENT.start,SEGMENT.stop,0,255); - if (!wrap) paletteIndex = map(paletteIndex, 0, 255, 0, 240); //cut off blend at palette "end" + if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end" CRGB fastled_col; fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND); return fastled_col.r*65536 + fastled_col.g*256 + fastled_col.b; diff --git a/wled00/WS2812FX.h b/wled00/WS2812FX.h index 0f9ba3bf..8ca04e9a 100644 --- a/wled00/WS2812FX.h +++ b/wled00/WS2812FX.h @@ -373,6 +373,7 @@ class WS2812FX { twinkle(uint32_t), dissolve(uint32_t), chase(uint32_t, uint32_t, uint32_t, uint8_t), + gradient_base(bool), running(uint32_t, uint32_t), fireworks(uint32_t), tricolor_chase(uint32_t, uint32_t, uint32_t); diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 504197f6..04ce2538 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -78,7 +78,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1902021 +#define VERSION 1902051 char versionString[] = "0.8.3-dev"; @@ -102,7 +102,7 @@ char ntpServerName[] = "0.wled.pool.ntp.org"; //NTP server to use //WiFi CONFIG (all these can be changed via web UI, no need to set them here) char clientSSID[33] = "Your_Network"; char clientPass[65] = ""; -char cmDNS[33] = "led"; //mDNS address (x.local), only for Apple and Windows, if Bonjour installed +char cmDNS[33] = "x"; //mDNS address (placeholder, will be replaced by wledXXXXXXXXXXXX.local) char apSSID[65] = ""; //AP off by default (unless setup) byte apChannel = 1; //2.4GHz WiFi AP channel (1-13) byte apHide = 0; //hidden AP SSID diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 458bc398..712e0bf9 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -53,7 +53,9 @@ void XML_response(bool isHTTP, bool includeTheme) oappendi(whiteSec); oappend(""); oappendi(useHSB); - oappend(""); + oappend(""); + oappendi(presetCyclingEnabled); + oappend(""); oappend(serverDescription); oappend(""); if (includeTheme) diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index e76b7eff..23956390 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -476,6 +476,7 @@ bool handleSet(String req) pos = req.indexOf("FX="); if (pos > 0) { effectCurrent = getNumVal(&req, pos); + presetCyclingEnabled = false; } //set effect speed pos = req.indexOf("SX="); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 21a59a30..18f732ab 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -11,11 +11,11 @@ void wledInit() #ifdef ARDUINO_ARCH_ESP32 if (ledCount > 600) ledCount = 600; #endif - if (!EEPROM.read(397)) strip.init(EEPROM.read(372),ledCount,EEPROM.read(2204)); //quick init - Serial.begin(115200); Serial.setTimeout(50); + if (!EEPROM.read(397)) strip.init(EEPROM.read(372),ledCount,EEPROM.read(2204)); //quick init + #ifdef USEFS SPIFFS.begin(); #endif @@ -58,6 +58,11 @@ void wledInit() } prepareIds(); //UUID from MAC (for Alexa and MQTT) + if (strcmp(cmDNS,"x") == 0) //fill in unique mdns default + { + strcpy(cmDNS, "wled-"); + strcat(cmDNS, escapedMac.c_str()); + } if (mqttDeviceTopic[0] == 0) { strcpy(mqttDeviceTopic, "wled/"); @@ -108,6 +113,7 @@ void wledInit() DEBUG_PRINTLN("mDNS responder started"); // Add service to MDNS MDNS.addService("http", "tcp", 80); + MDNS.addService("wled", "tcp", 80); } if (!initLedsLast) strip.service(); diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index 65396161..5e9d7aee 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -187,23 +187,18 @@ void handleTransitions() setLedsStandard(); return; } - if (tper - tperLast < 0.004) - { - return; - } + if (tper - tperLast < 0.004) return; tperLast = tper; - if (fadeTransition) + for (byte i = 0; i<3; i++) { - for (byte i = 0; i<3; i++) - { - colT[i] = colOld[i]+((col[i] - colOld[i])*tper); - colSecT[i] = colSecOld[i]+((colSec[i] - colSecOld[i])*tper); - } - whiteT = whiteOld +((white - whiteOld )*tper); - whiteSecT = whiteSecOld +((whiteSec - whiteSecOld )*tper); - briT = briOld +((bri - briOld )*tper); + colT[i] = colOld[i]+((col[i] - colOld[i])*tper); + colSecT[i] = colSecOld[i]+((colSec[i] - colSecOld[i])*tper); } - if (fadeTransition) setAllLeds(); + whiteT = whiteOld +((white - whiteOld )*tper); + whiteSecT = whiteSecOld +((whiteSec - whiteSecOld )*tper); + briT = briOld +((bri - briOld )*tper); + + setAllLeds(); } }