mirror of https://github.com/arendst/Tasmota.git
Fix possible Pow Exception 0
This commit is contained in:
parent
0c59eb5585
commit
0de07df099
|
@ -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 **5.6.1c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **5.6.1d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
### ATTENTION All versions
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* 5.6.1c
|
||||
/* 5.6.1d
|
||||
* Fix settings order during startup to allow for displaying debug messages
|
||||
* Add more Sonoff Pow range checking (#772)
|
||||
*
|
||||
* 5.6.1c
|
||||
* Add more precision to Sonoff Pow period and power results using command WattRes 0|1 (#759)
|
||||
*
|
||||
* 5.6.1b
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||
====================================================*/
|
||||
|
||||
#define VERSION 0x05060103 // 5.6.1c
|
||||
#define VERSION 0x05060104 // 5.6.1d
|
||||
|
||||
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};
|
||||
|
@ -2789,19 +2789,20 @@ void setup()
|
|||
|
||||
osw_init();
|
||||
|
||||
sysCfg.bootcount++;
|
||||
snprintf_P(log, sizeof(log), PSTR("APP: Bootcount %d"), sysCfg.bootcount);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
stop_flash_rotate = sysCfg.flag.stop_flash_rotate;
|
||||
savedatacounter = sysCfg.savedata;
|
||||
seriallog_timer = SERIALLOG_TIMER;
|
||||
seriallog_level = sysCfg.seriallog_level;
|
||||
seriallog_timer = SERIALLOG_TIMER;
|
||||
#ifndef USE_EMULATION
|
||||
sysCfg.flag.emulation = 0;
|
||||
#endif // USE_EMULATION
|
||||
syslog_level = (sysCfg.flag.emulation) ? 0 : sysCfg.syslog_level;
|
||||
stop_flash_rotate = sysCfg.flag.stop_flash_rotate;
|
||||
savedatacounter = sysCfg.savedata;
|
||||
sleep = sysCfg.sleep;
|
||||
|
||||
sysCfg.bootcount++;
|
||||
snprintf_P(log, sizeof(log), PSTR("APP: Bootcount %d"), sysCfg.bootcount);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
GPIO_init();
|
||||
|
||||
if (Serial.baudRate() != Baudrate) {
|
||||
|
|
|
@ -112,9 +112,11 @@ void hlw_200mS()
|
|||
if (hlw_EDcntr) {
|
||||
hlw_len = 10000 / hlw_EDcntr;
|
||||
hlw_EDcntr = 0;
|
||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / 36;
|
||||
hlw_kWhtoday += hlw_temp;
|
||||
rtcMem.hlw_kWhtoday = hlw_kWhtoday;
|
||||
if (hlw_len) {
|
||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / 36;
|
||||
hlw_kWhtoday += hlw_temp;
|
||||
rtcMem.hlw_kWhtoday = hlw_kWhtoday;
|
||||
}
|
||||
}
|
||||
if (rtcTime.Valid) {
|
||||
if (rtc_loctime() == rtc_midnight()) {
|
||||
|
@ -184,8 +186,8 @@ void hlw_readEnergy(byte option, float &et, float &ed, float &e, float &w, float
|
|||
unsigned long hlw_w;
|
||||
unsigned long hlw_u;
|
||||
unsigned long hlw_i;
|
||||
int hlw_period;
|
||||
int hlw_interval;
|
||||
uint16_t hlw_period;
|
||||
uint16_t hlw_interval;
|
||||
|
||||
//char log[LOGSZ];
|
||||
//snprintf_P(log, sizeof(log), PSTR("HLW: CF %d, CF1U %d (%d), CF1I %d (%d)"), hlw_cf_plen, hlw_cf1u_plen, hlw_cf1u_pcntmax, hlw_cf1i_plen, hlw_cf1i_pcntmax);
|
||||
|
@ -203,14 +205,16 @@ void hlw_readEnergy(byte option, float &et, float &ed, float &e, float &w, float
|
|||
} else {
|
||||
hlw_period = rtc_loctime() - hlw_lasttime;
|
||||
}
|
||||
hlw_lasttime = rtc_loctime();
|
||||
if (hlw_period) {
|
||||
hlw_lasttime = rtc_loctime();
|
||||
hlw_interval = 3600 / hlw_period;
|
||||
if (hlw_Ecntr) {
|
||||
hlw_len = hlw_period * 1000000 / hlw_Ecntr;
|
||||
hlw_Ecntr = 0;
|
||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / hlw_interval;
|
||||
e = (float)hlw_temp / 10;
|
||||
if (hlw_interval && hlw_len) {
|
||||
hlw_Ecntr = 0;
|
||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / hlw_interval;
|
||||
e = (float)hlw_temp / 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue