diff --git a/README.md b/README.md index 4849e163f..645e99376 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Sonoff-Tasmota Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. -Current version is **3.9.5** - See ```sonoff/_releasenotes.ino``` for change information. +Current version is **3.9.6** - See ```sonoff/_releasenotes.ino``` for change information. - This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic. - Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```. @@ -11,7 +11,7 @@ Current version is **3.9.5** - See ```sonoff/_releasenotes.ino``` for change inf See [Wiki](wiki) for more information.
See [Community](https://groups.google.com/d/forum/sonoffusers) for forum and more user experience. -The following devices are supported: +Starting with version 2.0.0 the following devices are supported: - [iTead Sonoff Basic](http://sonoff.itead.cc/en/products/sonoff/sonoff-basic) - [iTead Sonoff RF](http://sonoff.itead.cc/en/products/sonoff/sonoff-rf) - [iTead Sonoff SV](https://www.itead.cc/sonoff-sv.html) diff --git a/api/arduino/sonoff.ino.bin b/api/arduino/sonoff.ino.bin index ee5225f79..fa2783e8b 100644 Binary files a/api/arduino/sonoff.ino.bin and b/api/arduino/sonoff.ino.bin differ diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 7ea36323e..8dd3a0552 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,7 @@ -/* 3.9.5 2017018 +/* 3.9.6 20170129 + * Add dynamic sleep for WS2812 animation (#1) + * + * 3.9.5 20170128 * Fix error message in case of wrong Domoticz command * * 3.9.4 20170127 diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 3c4dff6a8..53890c57a 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -10,7 +10,7 @@ * ==================================================== */ -#define VERSION 0x03090500 // 3.9.5 +#define VERSION 0x03090600 // 3.9.6 enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; enum week_t {Last, First, Second, Third, Fourth}; @@ -383,6 +383,7 @@ byte syslog_level; // Current copy of sysCfg.syslog_level uint16_t syslog_timer = 0; // Timer to re-enable syslog_level byte seriallog_level; // Current copy of sysCfg.seriallog_level uint16_t seriallog_timer = 0; // Timer to disable Seriallog +uint8_t sleep; // Current copy of sysCfg.sleep int blinks = 201; // Number of LED blinks uint8_t blinkstate = 0; // LED state @@ -1283,9 +1284,10 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len) else if (!strcmp(type,"SLEEP")) { if ((data_len > 0) && (payload >= 0) && (payload < 251)) { sysCfg.sleep = payload; - restartflag = 2; + sleep = payload; +// restartflag = 2; } - snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s\"}"), sysCfg.sleep, (sysCfg.value_units) ? " mS" : ""); + snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.value_units) ? " mS" : ""); } else if (!strcmp(type,"UPGRADE") || !strcmp(type,"UPLOAD")) { if ((data_len > 0) && (payload == 1)) { @@ -2456,6 +2458,7 @@ void setup() seriallog_timer = SERIALLOG_TIMER; seriallog_level = sysCfg.seriallog_level; syslog_level = sysCfg.syslog_level; + sleep = sysCfg.sleep; GPIO_init(); @@ -2525,7 +2528,7 @@ void loop() if (millis() >= timerxs) stateloop(); if (sysCfg.mqtt_enabled) mqttClient.loop(); if (Serial.available()) serial(); - yield(); - if (sysCfg.sleep) delay(sysCfg.sleep); +// yield(); // yield == delay(0), delay contains yield, auto yield in loop + delay(sleep); // https://github.com/esp8266/Arduino/issues/2021 } diff --git a/sonoff/support.ino b/sonoff/support.ino index 21585b824..e3b35f33a 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -421,7 +421,8 @@ void WIFI_begin(uint8_t flag) } WiFi.disconnect(); WiFi.mode(WIFI_STA); // Disable AP mode - if (sysCfg.sleep) wifi_set_sleep_type(LIGHT_SLEEP_T); // Allow light sleep during idle times +// if (sysCfg.sleep) wifi_set_sleep_type(LIGHT_SLEEP_T); // Allow light sleep during idle times + WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times // if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) WiFi.setPhyMode(WIFI_PHY_MODE_11N); if (!WiFi.getAutoConnect()) WiFi.setAutoConnect(true); // WiFi.setAutoReconnect(true); diff --git a/sonoff/xdrv_ws2812.ino b/sonoff/xdrv_ws2812.ino index acb560021..d56cfb7d2 100644 --- a/sonoff/xdrv_ws2812.ino +++ b/sonoff/xdrv_ws2812.ino @@ -372,10 +372,12 @@ void ws2812_animate() stripTimerCntr++; if (power == 0) { // Power Off + sleep = sysCfg.sleep; stripTimerCntr = 0; tcolor = 0; } else { + sleep = 0; switch (sysCfg.ws_scheme) { case 0: // Power On ws2812_setDim(sysCfg.ws_dimmer); diff --git a/sonoff/xsns_hlw8012.ino b/sonoff/xsns_hlw8012.ino index 9b1b7484f..a15b62ded 100644 --- a/sonoff/xsns_hlw8012.ino +++ b/sonoff/xsns_hlw8012.ino @@ -29,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. * Based on Source: Shenzhen Heli Technology Co., Ltd \*********************************************************************************************/ -#define FEATURE_POWER_LIMIT false +#define FEATURE_POWER_LIMIT true /*********************************************************************************************/ @@ -512,8 +512,8 @@ boolean hlw_command(char *type, uint16_t index, char *dataBuf, uint16_t data_len void hlw_commands(char *svalue, uint16_t ssvalue) { - snprintf_P(svalue, ssvalue, PSTR("{\"Commands\":\"PowerLow, PowerHigh, VoltageLow, VoltageHigh, CurrentLow, CurrentHigh%s\"}"), - (FEATURE_POWER_LIMIT)?"SafePower, SafePowerHold, SafePowerWindow, MaxPower, MaxPowerHold, MaxPowerWindow, MaxEnergy, MaxEnergyStart":""); + snprintf_P(svalue, ssvalue, PSTR("{\"Commands\":\"PowerLow, PowerHigh, VoltageLow, VoltageHigh, CurrentLow, CurrentHigh, HlwPcal, HlwUcal, HlwIcal%s\"}"), + (FEATURE_POWER_LIMIT)?", SafePower, SafePowerHold, SafePowerWindow, MaxPower, MaxPowerHold, MaxPowerWindow, MaxEnergy, MaxEnergyStart":""); } /*********************************************************************************************\