diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8111ca5..2321c9a0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ### Builds after release 0.12.0 +#### Build 2106180 + +- Fixed DOS on Chrome tab restore causing reboot + +#### Build 2106170 + +- Optimized JSON buffer usage (pre-serialized color arrays) + #### Build 2106140 - Updated main logo diff --git a/package-lock.json b/package-lock.json index 2f3a4c29a..0fe61f7ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -761,9 +761,9 @@ } }, "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "requires": { "is-glob": "^4.0.1" } @@ -1572,9 +1572,9 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, "normalize-url": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", - "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==" }, "nth-check": { "version": "1.0.2", diff --git a/tools/WLED_ESP32_4MB_1MB_FS.csv b/tools/WLED_ESP32_4MB_1MB_FS.csv index 09455c6a9..5dec3c067 100644 --- a/tools/WLED_ESP32_4MB_1MB_FS.csv +++ b/tools/WLED_ESP32_4MB_1MB_FS.csv @@ -1,6 +1,6 @@ # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, -app0, app, ota_0, 0x10000, 0x17B000, -app1, app, ota_1, 0x18B000,0x17B000, -spiffs, data, spiffs, 0x306000,0x0FA000, \ No newline at end of file +app0, app, ota_0, 0x10000, 0x180000, +app1, app, ota_1, 0x190000,0x180000, +spiffs, data, spiffs, 0x310000,0xF0000, \ No newline at end of file diff --git a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h index 465b22f77..3fd1fafa1 100644 --- a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h +++ b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h @@ -2,7 +2,7 @@ #include "wled.h" -//Pin defaults for QuinLed Dig-Uno +//Pin defaults for QuinLed Dig-Uno (A0) #define PHOTORESISTOR_PIN A0 // the frequency to check photoresistor, 10 seconds @@ -38,6 +38,12 @@ class Usermod_SN_Photoresistor : public Usermod { private: + float referenceVoltage = USERMOD_SN_PHOTORESISTOR_REFERENCE_VOLTAGE; + float resistorValue = USERMOD_SN_PHOTORESISTOR_RESISTOR_VALUE; + float adcPrecision = USERMOD_SN_PHOTORESISTOR_ADC_PRECISION; + int8_t offset = USERMOD_SN_PHOTORESISTOR_OFFSET_VALUE; + + unsigned long readingInterval = USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL; // set last reading as "40 sec before boot", so first reading is taken after 20 sec unsigned long lastMeasurement = UINT32_MAX - (USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL - USERMOD_SN_PHOTORESISTOR_FIRST_MEASUREMENT_AT); // flag to indicate we have finished the first getTemperature call @@ -46,6 +52,18 @@ private: bool getLuminanceComplete = false; uint16_t lastLDRValue = -1000; + // flag set at startup + bool disabled = false; + + // strings to reduce flash memory usage (used more than twice) + static const char _name[]; + static const char _enabled[]; + static const char _readInterval[]; + static const char _referenceVoltage[]; + static const char _resistorValue[]; + static const char _adcPrecision[]; + static const char _offset[]; + bool checkBoundSensor(float newValue, float prevValue, float maxDiff) { return isnan(prevValue) || newValue <= prevValue - maxDiff || newValue >= prevValue + maxDiff; @@ -55,8 +73,8 @@ private: { // http://forum.arduino.cc/index.php?topic=37555.0 // https://forum.arduino.cc/index.php?topic=185158.0 - float volts = analogRead(PHOTORESISTOR_PIN) * (USERMOD_SN_PHOTORESISTOR_REFERENCE_VOLTAGE / USERMOD_SN_PHOTORESISTOR_ADC_PRECISION); - float amps = volts / USERMOD_SN_PHOTORESISTOR_RESISTOR_VALUE; + float volts = analogRead(PHOTORESISTOR_PIN) * (referenceVoltage / adcPrecision); + float amps = volts / resistorValue; float lux = amps * 1000000 * 2.0; lastMeasurement = millis(); @@ -67,23 +85,27 @@ private: public: void setup() { + // set pinmode pinMode(PHOTORESISTOR_PIN, INPUT); } void loop() { + if (disabled || strip.isUpdating()) + return; + unsigned long now = millis(); // check to see if we are due for taking a measurement // lastMeasurement will not be updated until the conversion // is complete the the reading is finished - if (now - lastMeasurement < USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL) + if (now - lastMeasurement < readingInterval) { return; } uint16_t currentLDRValue = getLuminance(); - if (checkBoundSensor(currentLDRValue, lastLDRValue, USERMOD_SN_PHOTORESISTOR_OFFSET_VALUE)) + if (checkBoundSensor(currentLDRValue, lastLDRValue, offset)) { lastLDRValue = currentLDRValue; @@ -104,7 +126,8 @@ public: void addToJsonInfo(JsonObject &root) { JsonObject user = root[F("u")]; - if (user.isNull()) user = root.createNestedObject(F("u")); + if (user.isNull()) + user = root.createNestedObject(F("u")); JsonArray lux = user.createNestedArray(F("Luminance")); @@ -125,4 +148,63 @@ public: { return USERMOD_ID_SN_PHOTORESISTOR; } + + /** + * addToConfig() (called from set.cpp) stores persistent properties to cfg.json + */ + void addToConfig(JsonObject &root) + { + // we add JSON object. + JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname + top[FPSTR(_enabled)] = !disabled; + top[FPSTR(_readInterval)] = readingInterval / 1000; + top[FPSTR(_referenceVoltage)] = referenceVoltage; + top[FPSTR(_resistorValue)] = resistorValue; + top[FPSTR(_adcPrecision)] = adcPrecision; + top[FPSTR(_offset)] = offset; + + DEBUG_PRINTLN(F("Photoresistor config saved.")); + } + + /** + * readFromConfig() is called before setup() to populate properties from values stored in cfg.json + */ + void readFromConfig(JsonObject &root) + { + // we look for JSON object. + JsonObject top = root[FPSTR(_name)]; + + if (!top.isNull()) + { + if (top[FPSTR(_enabled)].is()) + { + disabled = !top[FPSTR(_enabled)].as(); + } + else + { + String str = top[FPSTR(_enabled)]; // checkbox -> off or on + disabled = (bool)(str == "off"); // off is guaranteed to be present + }; + + readingInterval = min(120, max(10, top[FPSTR(_readInterval)].as())) * 1000; // convert to ms + referenceVoltage = top[FPSTR(_referenceVoltage)].as(); + resistorValue = top[FPSTR(_resistorValue)].as(); + adcPrecision = top[FPSTR(_adcPrecision)].as(); + offset = top[FPSTR(_offset)].as(); + DEBUG_PRINTLN(F("Photoresistor config (re)loaded.")); + } + else + { + DEBUG_PRINTLN(F("No config found. (Using defaults.)")); + } + } }; + +// strings to reduce flash memory usage (used more than twice) +const char Usermod_SN_Photoresistor::_name[] PROGMEM = "Photoresistor"; +const char Usermod_SN_Photoresistor::_enabled[] PROGMEM = "enabled"; +const char Usermod_SN_Photoresistor::_readInterval[] PROGMEM = "read-interval-s"; +const char Usermod_SN_Photoresistor::_referenceVoltage[] PROGMEM = "supplied-voltage"; +const char Usermod_SN_Photoresistor::_resistorValue[] PROGMEM = "resistor-value"; +const char Usermod_SN_Photoresistor::_adcPrecision[] PROGMEM = "adc-precision"; +const char Usermod_SN_Photoresistor::_offset[] PROGMEM = "offset"; \ No newline at end of file diff --git a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h index 20c02a6a2..6fc1c3f91 100644 --- a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h +++ b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h @@ -66,7 +66,9 @@ typedef enum { NONE = 0, SSD1306, // U8X8_SSD1306_128X32_UNIVISION_HW_I2C SH1106, // U8X8_SH1106_128X64_WINSTAR_HW_I2C - SSD1306_64 // U8X8_SSD1306_128X64_NONAME_HW_I2C + SSD1306_64, // U8X8_SSD1306_128X64_NONAME_HW_I2C + SSD1305, // U8X8_SSD1305_128X32_ADAFRUIT_HW_I2C + SSD1305_64 // U8X8_SSD1305_128X64_ADAFRUIT_HW_I2C } DisplayType; class FourLineDisplayUsermod : public Usermod { @@ -156,6 +158,22 @@ class FourLineDisplayUsermod : public Usermod { #endif u8x8 = (U8X8 *) new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA break; + case SSD1305: + #ifdef ESP8266 + if (!(sclPin==5 && sdaPin==4)) + u8x8 = (U8X8 *) new U8X8_SSD1305_128X32_NONAME_SW_I2C(sclPin, sdaPin); // SCL, SDA, reset + else + #endif + u8x8 = (U8X8 *) new U8X8_SSD1305_128X32_ADAFRUIT_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA + break; + case SSD1305_64: + #ifdef ESP8266 + if (!(sclPin==5 && sdaPin==4)) + u8x8 = (U8X8 *) new U8X8_SSD1305_128X64_ADAFRUIT_SW_I2C(sclPin, sdaPin); // SCL, SDA, reset + else + #endif + u8x8 = (U8X8 *) new U8X8_SSD1305_128X64_ADAFRUIT_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA + break; default: u8x8 = nullptr; type = NONE; diff --git a/wled00/const.h b/wled00/const.h index 6c07c9782..de521c88e 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -167,13 +167,15 @@ #define BTN_TYPE_ANALOG_INVERTED 8 //Ethernet board types -#define WLED_NUM_ETH_TYPES 5 +#define WLED_NUM_ETH_TYPES 7 #define WLED_ETH_NONE 0 #define WLED_ETH_WT32_ETH01 1 #define WLED_ETH_ESP32_POE 2 #define WLED_ETH_WESP32 3 #define WLED_ETH_QUINLED 4 +#define WLED_ETH_TWILIGHTLORD 5 +#define WLED_ETH_ESP32DEUX 6 //Hue error codes #define HUE_ERROR_INACTIVE 0 diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 67fb058a0..37ed67166 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -54,27 +54,29 @@ Hide AP name:
AP password (leave empty for open):

Access Point WiFi channel:
- AP opens: -
+ AP opens: +
AP IP: Not active

Experimental

Disable WiFi sleep:
Can help with connectivity issues.
- Do not enable if WiFi is working correctly, increases power consumption.
-
+ Do not enable if WiFi is working correctly, increases power consumption. +

Ethernet Type



+ + + + + + + +

+

diff --git a/wled00/html_settings.h b/wled00/html_settings.h index cd46052c3..159fa8755 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -64,11 +64,12 @@ Never (not recommended)
AP IP: Not active name="WS">
Can help with connectivity issues.
Do not enable if WiFi is working correctly, increases power consumption.

Ethernet Type




)====="; +


+)====="; // Autogenerated from wled00/data/settings_leds.htm, do not edit!! diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 2abf41a9c..83e27f1bf 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1,5 +1,6 @@ #define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp! #include "wled.h" +#include "wled_ethernet.h" #include #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) @@ -16,16 +17,6 @@ WLED::WLED() } #ifdef WLED_USE_ETHERNET -// settings for various ethernet boards -typedef struct EthernetSettings { - uint8_t eth_address; - int eth_power; - int eth_mdc; - int eth_mdio; - eth_phy_type_t eth_type; - eth_clock_mode_t eth_clk_mode; -} ethernet_settings; - ethernet_settings ethernetBoards[] = { // None { @@ -73,6 +64,26 @@ ethernet_settings ethernetBoards[] = { 18, // eth_mdio, ETH_PHY_LAN8720, // eth_type, ETH_CLOCK_GPIO17_OUT // eth_clk_mode + }, + + // TwilightLord-ESP32 Ethernet Shield + { + 0, // eth_address, + 5, // eth_power, + 23, // eth_mdc, + 18, // eth_mdio, + ETH_PHY_LAN8720, // eth_type, + ETH_CLOCK_GPIO17_OUT // eth_clk_mode + }, + + // ESP3DEUXQuattro + { + 1, // eth_address, + -1, // eth_power, + 23, // eth_mdc, + 18, // eth_mdio, + ETH_PHY_LAN8720, // eth_type, + ETH_CLOCK_GPIO17_OUT // eth_clk_mode } }; #endif diff --git a/wled00/wled.h b/wled00/wled.h index 64334f5ec..65db4b03b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2106192 +#define VERSION 2106201 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG diff --git a/wled00/wled_ethernet.h b/wled00/wled_ethernet.h new file mode 100644 index 000000000..c8001aa10 --- /dev/null +++ b/wled00/wled_ethernet.h @@ -0,0 +1,18 @@ +#ifndef WLED_ETHERNET_H +#define WLED_ETHERNET_H + +#ifdef WLED_USE_ETHERNET +// settings for various ethernet boards +typedef struct EthernetSettings { + uint8_t eth_address; + int eth_power; + int eth_mdc; + int eth_mdio; + eth_phy_type_t eth_type; + eth_clock_mode_t eth_clk_mode; +} ethernet_settings; + +extern ethernet_settings ethernetBoards[]; +#endif + +#endif \ No newline at end of file diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 92eba9340..01f5a6f43 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -1,4 +1,5 @@ #include "wled.h" +#include "wled_ethernet.h" /* * Sending XML status files to client @@ -273,12 +274,16 @@ void getSettingsJS(byte subPage, char* dest) if (obj["pin"].is()) { JsonArray pins = obj["pin"].as(); for (JsonVariant pv : pins) { - if (i++) oappend(SET_F(",")); - oappendi(pv.as()); + if (pv.as() > -1) { + if (i++) oappend(SET_F(",")); + oappendi(pv.as()); + } } } else { - if (i++) oappend(SET_F(",")); - oappendi(obj["pin"].as()); + if (obj["pin"].as() > -1) { + if (i++) oappend(SET_F(",")); + oappendi(obj["pin"].as()); + } } } } @@ -314,18 +319,25 @@ void getSettingsJS(byte subPage, char* dest) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) if (psramFound()) oappend(SET_F(",16,17")); // GPIO16 & GPIO17 reserved for SPI RAM #endif - //TODO: add reservations for Ethernet shield pins #ifdef WLED_USE_ETHERNET - /* if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) { ethernet_settings es = ethernetBoards[ethernetType]; - if (es.eth_power>0) pinManager.allocatePin(es.eth_power); - if (es.eth_mdc>0) pinManager.allocatePin(es.eth_mdc); - if (es.eth_mdio>0) pinManager.allocatePin(es.eth_mdio); - //if (es.eth_type>0) pinManager.allocatePin(es.eth_type); - //if (es.eth_clk_mode>0) pinManager.allocatePin(es.eth_clk_mode); + if (es.eth_power>0) { oappend(","); oappend(itoa(es.eth_power,nS,10)); } + if (es.eth_mdc>0) { oappend(","); oappend(itoa(es.eth_mdc,nS,10)); } + if (es.eth_mdio>0) { oappend(","); oappend(itoa(es.eth_mdio,nS,10)); } + switch (es.eth_clk_mode) { + case ETH_CLOCK_GPIO0_IN: + case ETH_CLOCK_GPIO0_OUT: + oappend(SET_F(",0")); + break; + case ETH_CLOCK_GPIO16_OUT: + oappend(SET_F(",16")); + break; + case ETH_CLOCK_GPIO17_OUT: + oappend(SET_F(",17")); + break; + } } - */ #endif } oappend(SET_F("];"));