diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..d09c8a60 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 +ARG VARIANT="3" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..867d7d46 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,46 @@ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 + "VARIANT": "3", + // Options + "INSTALL_NODE": "true", + "NODE_VERSION": "lts/*" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} + diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fbe900f..24c6becc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ ### WLED version 0.11.0 +#### Build 2012010 + +- Fixed compilation for analog (PWM) LEDs + +#### Build 2011290 + +- Release of WLED 0.11.0 "Mirai" +- Workaround for weird empty %f Espalexa issue +- Fixed crash on saving preset with HTTP API `PS` +- Improved performance for color changes in non-main segment + #### Build 2011270 - Added tooltips for speed and intensity sliders (PR #1378) diff --git a/platformio_override.ini.example b/platformio_override.ini.example index cf9da268..d486dff0 100644 --- a/platformio_override.ini.example +++ b/platformio_override.ini.example @@ -29,7 +29,7 @@ build_flags = ${common.build_flags_esp8266} ; -D LEDPIN=2 ; -D BTNPIN=0 ; -D TOUCHPIN=T0 -; -D IR_PIN=4 +; -D IRPIN=4 ; -D RLYPIN=12 ; -D RLYMDE=1 ; digital LED strip types - uncomment only one ! - this will disable WS281x / SK681x support diff --git a/usermods/TTGO-T-Display/platformio_override.ini b/usermods/TTGO-T-Display/platformio_override.ini index 4b176096..7e42d9a5 100644 --- a/usermods/TTGO-T-Display/platformio_override.ini +++ b/usermods/TTGO-T-Display/platformio_override.ini @@ -3,6 +3,6 @@ build_flags = ${common.build_flags_esp32} ; PIN defines - uncomment and change, if needed: ; -D LEDPIN=2 -D BTNPIN=35 -; -D IR_PIN=4 +; -D IRPIN=4 ; -D RLYPIN=12 ; -D RLYMDE=1 diff --git a/usermods/esp32_multistrip/NpbWrapper.h b/usermods/esp32_multistrip/NpbWrapper.h index 4fbcce26..e468e46e 100644 --- a/usermods/esp32_multistrip/NpbWrapper.h +++ b/usermods/esp32_multistrip/NpbWrapper.h @@ -24,8 +24,8 @@ #define LEDPIN 1 // Legacy pin def required by some other portions of code. This pin is not used do drive LEDs. #endif -#ifndef IR_PIN - #define IR_PIN -1 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#ifndef IRPIN + #define IRPIN -1 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 #endif #ifndef RLYPIN diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index ddb49f6f..4418cfb7 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -928,7 +928,7 @@ void WS2812FX::setRgbwPwm(void) { c.R = col >> 16; c.G = col >> 8; c.B = col; c.W = col >> 24; byte b = getBrightness(); - if (color == _analogLastColor && b == _analogLastBri) return; + if (c == _analogLastColor && b == _analogLastBri) return; // check color values for Warm / Cold white mix (for RGBW) // EsplanexaDevice.cpp #ifdef WLED_USE_5CH_LEDS @@ -948,7 +948,7 @@ void WS2812FX::setRgbwPwm(void) { #else bus->SetRgbwPwm(c.R * b / 255, c.G * b / 255, c.B * b / 255, c.W * b / 255); #endif - _analogLastColor = color; + _analogLastColor = c; _analogLastBri = b; } #else diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 6316dcf8..6e56efe5 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -25,8 +25,8 @@ //#define TOUCHPIN T0 //touch pin. Behaves the same as button. ESP32 only. #endif -#ifndef IR_PIN -#define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#ifndef IRPIN +#define IRPIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 #endif #ifndef RLYPIN @@ -71,8 +71,8 @@ #define WPIN 14 //W pin for analog LED strip #define W2PIN 04 //W2 pin for analog LED strip #undef BTNPIN - #undef IR_PIN - #define IR_PIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 + #undef IRPIN + #define IRPIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 #elif defined(WLED_USE_BWLT11) //PWM pins - to use with BW-LT11 #define RPIN 12 //R pin for analog LED strip @@ -93,7 +93,7 @@ #define BPIN 14 //B pin for analog LED strip #define WPIN 4 //W pin for analog LED strip #define W2PIN 5 //W2 pin for analog LED strip - #undef IR_PIN + #undef IRPIN #else //Enable override of Pins by using the platformio_override.ini file //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index c12f8848..9e5c9e82 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -434,8 +434,8 @@ void serializeConfig() { #if defined(IRPIN) && IRPIN > -1 JsonObject hw_ir = hw.createNestedObject("ir"); - hw_ir[F("pin")] = IR_PIN; - hw_ir[F("type")] = 0; + hw_ir[F("pin")] = IRPIN; + hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled ) #endif #if defined(RLYPIN) && RLYPIN > -1 diff --git a/wled00/ir.cpp b/wled00/ir.cpp index 1405187e..70c920e0 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -488,7 +488,7 @@ void initIR() { if (irEnabled > 0) { - irrecv = new IRrecv(IR_PIN); + irrecv = new IRrecv(IRPIN); irrecv->enableIRIn(); } } diff --git a/wled00/json.cpp b/wled00/json.cpp index d8d8f57e..7c3ce05f 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -68,6 +68,7 @@ void deserializeSegment(JsonObject elem, byte it) if (i == 1) {colSec[0] = rgbw[0]; colSec[1] = rgbw[1]; colSec[2] = rgbw[2]; colSec[3] = rgbw[3];} } else { //normal case, apply directly to segment (=> no transition!) seg.colors[i] = ((rgbw[3] << 24) | ((rgbw[0]&0xFF) << 16) | ((rgbw[1]&0xFF) << 8) | ((rgbw[2]&0xFF))); + if (seg.mode == FX_MODE_STATIC) strip.trigger(); //instant refresh } } } diff --git a/wled00/presets.cpp b/wled00/presets.cpp index e5e2015f..7fd2e5d2 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -37,33 +37,37 @@ bool applyPreset(byte index) void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj) { if (index == 0 || index > 250) return; - bool docAlloc = fileDoc; + bool docAlloc = (fileDoc != nullptr); JsonObject sObj = saveobj; if (!docAlloc) { DEBUGFS_PRINTLN(F("Allocating saving buffer")); - fileDoc = new DynamicJsonDocument(JSON_BUFFER_SIZE); - sObj = fileDoc->to(); + DynamicJsonDocument lDoc(JSON_BUFFER_SIZE); + sObj = lDoc.to(); if (pname) sObj["n"] = pname; - } else { + DEBUGFS_PRINTLN(F("Save current state")); + serializeState(sObj, true); + currentPreset = index; + + writeObjectToFileUsingId("/presets.json", index, &lDoc); + } else { //from JSON API DEBUGFS_PRINTLN(F("Reuse recv buffer")); sObj.remove(F("psave")); sObj.remove(F("v")); - } - if (!sObj["o"]) { - DEBUGFS_PRINTLN(F("Save current state")); - serializeState(sObj, true, sObj["ib"], sObj["sb"]); - currentPreset = index; - } - sObj.remove("o"); - sObj.remove("ib"); - sObj.remove("sb"); - sObj.remove(F("error")); - sObj.remove(F("time")); + if (!sObj["o"]) { + DEBUGFS_PRINTLN(F("Save current state")); + serializeState(sObj, true, sObj["ib"], sObj["sb"]); + currentPreset = index; + } + sObj.remove("o"); + sObj.remove("ib"); + sObj.remove("sb"); + sObj.remove(F("error")); + sObj.remove(F("time")); - writeObjectToFileUsingId("/presets.json", index, fileDoc); - if (!docAlloc) delete fileDoc; + writeObjectToFileUsingId("/presets.json", index, fileDoc); + } presetsModifiedTime = now(); //unix time updateFSInfo(); } diff --git a/wled00/src/dependencies/espalexa/Espalexa.h b/wled00/src/dependencies/espalexa/Espalexa.h index cf42f9ff..b0962c49 100644 --- a/wled00/src/dependencies/espalexa/Espalexa.h +++ b/wled00/src/dependencies/espalexa/Espalexa.h @@ -144,8 +144,11 @@ private: char buf_col[80] = ""; //color support if (static_cast(dev->getType()) > 2) - sprintf_P(buf_col,PSTR(",\"hue\":%u,\"sat\":%u,\"effect\":\"none\",\"xy\":[%f,%f]") - ,dev->getHue(), dev->getSat(), dev->getX(), dev->getY()); + //TODO: %f is not working for some reason on ESP8266 in v0.11.0 (was fine in 0.10.2). Need to investigate + //sprintf_P(buf_col,PSTR(",\"hue\":%u,\"sat\":%u,\"effect\":\"none\",\"xy\":[%f,%f]") + // ,dev->getHue(), dev->getSat(), dev->getX(), dev->getY()); + sprintf_P(buf_col,PSTR(",\"hue\":%u,\"sat\":%u,\"effect\":\"none\",\"xy\":[%s,%s]"),dev->getHue(), dev->getSat(), + ((String)dev->getX()).c_str(), ((String)dev->getY()).c_str()); char buf_ct[16] = ""; //white spectrum support diff --git a/wled00/wled.h b/wled00/wled.h index 7c2b032f..93ca1378 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2011270 +#define VERSION 2012010 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -129,7 +129,7 @@ Comment out this error message to build regardless. #endif -#if IR_PIN < 0 +#if IRPIN < 0 #ifndef WLED_DISABLE_INFRARED #define WLED_DISABLE_INFRARED #endif