3.9.6 20170129
* Add dynamic sleep for WS2812 animation (#1)
This commit is contained in:
arendst 2017-01-29 14:52:31 +01:00
parent cc35f184ea
commit b68c5d49b2
7 changed files with 21 additions and 12 deletions

View File

@ -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.<br />
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)

Binary file not shown.

View File

@ -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

View File

@ -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
}

View File

@ -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);

View File

@ -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);

View File

@ -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":"");
}
/*********************************************************************************************\