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
|
## 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.
|
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
|
### 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)
|
* Add more precision to Sonoff Pow period and power results using command WattRes 0|1 (#759)
|
||||||
*
|
*
|
||||||
* 5.6.1b
|
* 5.6.1b
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- 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 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};
|
enum week_t {Last, First, Second, Third, Fourth};
|
||||||
|
@ -2789,19 +2789,20 @@ void setup()
|
||||||
|
|
||||||
osw_init();
|
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_level = sysCfg.seriallog_level;
|
||||||
|
seriallog_timer = SERIALLOG_TIMER;
|
||||||
#ifndef USE_EMULATION
|
#ifndef USE_EMULATION
|
||||||
sysCfg.flag.emulation = 0;
|
sysCfg.flag.emulation = 0;
|
||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
syslog_level = (sysCfg.flag.emulation) ? 0 : sysCfg.syslog_level;
|
syslog_level = (sysCfg.flag.emulation) ? 0 : sysCfg.syslog_level;
|
||||||
|
stop_flash_rotate = sysCfg.flag.stop_flash_rotate;
|
||||||
|
savedatacounter = sysCfg.savedata;
|
||||||
sleep = sysCfg.sleep;
|
sleep = sysCfg.sleep;
|
||||||
|
|
||||||
|
sysCfg.bootcount++;
|
||||||
|
snprintf_P(log, sizeof(log), PSTR("APP: Bootcount %d"), sysCfg.bootcount);
|
||||||
|
addLog(LOG_LEVEL_DEBUG, log);
|
||||||
|
|
||||||
GPIO_init();
|
GPIO_init();
|
||||||
|
|
||||||
if (Serial.baudRate() != Baudrate) {
|
if (Serial.baudRate() != Baudrate) {
|
||||||
|
|
|
@ -112,10 +112,12 @@ void hlw_200mS()
|
||||||
if (hlw_EDcntr) {
|
if (hlw_EDcntr) {
|
||||||
hlw_len = 10000 / hlw_EDcntr;
|
hlw_len = 10000 / hlw_EDcntr;
|
||||||
hlw_EDcntr = 0;
|
hlw_EDcntr = 0;
|
||||||
|
if (hlw_len) {
|
||||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / 36;
|
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / 36;
|
||||||
hlw_kWhtoday += hlw_temp;
|
hlw_kWhtoday += hlw_temp;
|
||||||
rtcMem.hlw_kWhtoday = hlw_kWhtoday;
|
rtcMem.hlw_kWhtoday = hlw_kWhtoday;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (rtcTime.Valid) {
|
if (rtcTime.Valid) {
|
||||||
if (rtc_loctime() == rtc_midnight()) {
|
if (rtc_loctime() == rtc_midnight()) {
|
||||||
sysCfg.hlw_kWhyesterday = hlw_kWhtoday;
|
sysCfg.hlw_kWhyesterday = hlw_kWhtoday;
|
||||||
|
@ -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_w;
|
||||||
unsigned long hlw_u;
|
unsigned long hlw_u;
|
||||||
unsigned long hlw_i;
|
unsigned long hlw_i;
|
||||||
int hlw_period;
|
uint16_t hlw_period;
|
||||||
int hlw_interval;
|
uint16_t hlw_interval;
|
||||||
|
|
||||||
//char log[LOGSZ];
|
//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);
|
//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,17 +205,19 @@ void hlw_readEnergy(byte option, float &et, float &ed, float &e, float &w, float
|
||||||
} else {
|
} else {
|
||||||
hlw_period = rtc_loctime() - hlw_lasttime;
|
hlw_period = rtc_loctime() - hlw_lasttime;
|
||||||
}
|
}
|
||||||
if (hlw_period) {
|
|
||||||
hlw_lasttime = rtc_loctime();
|
hlw_lasttime = rtc_loctime();
|
||||||
|
if (hlw_period) {
|
||||||
hlw_interval = 3600 / hlw_period;
|
hlw_interval = 3600 / hlw_period;
|
||||||
if (hlw_Ecntr) {
|
if (hlw_Ecntr) {
|
||||||
hlw_len = hlw_period * 1000000 / hlw_Ecntr;
|
hlw_len = hlw_period * 1000000 / hlw_Ecntr;
|
||||||
|
if (hlw_interval && hlw_len) {
|
||||||
hlw_Ecntr = 0;
|
hlw_Ecntr = 0;
|
||||||
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / hlw_interval;
|
hlw_temp = ((HLW_PREF * sysCfg.hlw_pcal) / hlw_len) / hlw_interval;
|
||||||
e = (float)hlw_temp / 10;
|
e = (float)hlw_temp / 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
w = 0;
|
w = 0;
|
||||||
if (hlw_cf_plen) {
|
if (hlw_cf_plen) {
|
||||||
hlw_w = (HLW_PREF * sysCfg.hlw_pcal) / hlw_cf_plen;
|
hlw_w = (HLW_PREF * sysCfg.hlw_pcal) / hlw_cf_plen;
|
||||||
|
|
Loading…
Reference in New Issue