diff --git a/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino b/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino index adfdec32c..31211fe58 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_07_domoticz.ino @@ -135,7 +135,7 @@ void MqttPublishDomoticzFanState(void) { Response_P(DOMOTICZ_MESSAGE, (int)DomoticzRelayIdx(1), (0 == fan_speed) ? 0 : 2, svalue, DomoticzBatteryQuality(), DomoticzRssiQuality()); MqttPublish(domoticz_in_topic); - Domoticz->fan_debounce = millis(); + Domoticz->fan_debounce = millis() + 1000; // 1 second } } @@ -321,7 +321,7 @@ bool DomoticzMqttData(void) { if (GetFanspeed() == svalue) { return true; // Stop as already set } - if (TimePassedSince(Domoticz->fan_debounce) < 1000) { + if (!TimeReached(Domoticz->fan_debounce)) { return true; // Stop if device in limbo } snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_FANSPEED)); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino index 95a1272dc..ed9dbf9a1 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino @@ -215,13 +215,7 @@ void ShutterAllowPreStartProcedure(uint8_t i) { #ifdef USE_RULES AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]); // wait for response from rules -/* - uint32_t start_time = millis(); - while (TimePassedSince(start_time) < 10000 && (String)rules_vars[i] == "99") { - delay(1); - } -*/ - uint32_t end_time = millis() + 10000; + uint32_t end_time = millis() + 10000; // 10 seconds while (!TimeReached(end_time) && (String)rules_vars[i] == "99") { delay(1); } @@ -1389,12 +1383,6 @@ void ShutterUpdateVelocity(uint8_t i) void ShutterWaitForMotorStart(uint8_t i) { -/* - uint32_t start_time = Shutter[i].last_stop_time; - while (TimePassedSince(start_time) < ShutterSettings.shutter_motorstop && TimePassedSince(start_time) > 0) { - loop(); - } -*/ uint32_t end_time = Shutter[i].last_stop_time + ShutterSettings.shutter_motorstop; while (!TimeReached(end_time)) { loop(); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino index e019cd2e0..491081904 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino @@ -654,12 +654,6 @@ void ShutterWaitForMotorStop(uint8_t i) void ShutterWaitForMotorStart(uint8_t i) { -/* - uint32_t start_time = Shutter[i].last_stop_time; - while (TimePassedSince(start_time) < Settings->shutter_motorstop && TimePassedSince(start_time) > 0) { - loop(); - } -*/ uint32_t end_time = Shutter[i].last_stop_time + Settings->shutter_motorstop; while (!TimeReached(end_time)) { loop(); @@ -740,12 +734,6 @@ void ShutterAllowPreStartProcedure(uint8_t i) { #ifdef USE_RULES AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]); // wait for response from rules -/* - uint32_t start_time = millis(); - while (TimePassedSince(start_time) < 10000 && (String)rules_vars[i] == "99") { - delay(1); - } -*/ uint32_t end_time = millis() + 10000; while (!TimeReached(end_time) && (String)rules_vars[i] == "99") { delay(1); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_30_exs_dimmer.ino b/tasmota/tasmota_xdrv_driver/xdrv_30_exs_dimmer.ino index 6b80805c6..38981fecb 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_30_exs_dimmer.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_30_exs_dimmer.ino @@ -135,8 +135,8 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) ExsSerial->flush(); // wait for any response - uint32_t snd_time = millis(); - while ((TimePassedSince(snd_time) < EXS_ACK_TIMEOUT) && + uint32_t snd_time = millis() + EXS_ACK_TIMEOUT; + while ((!TimeReached(snd_time)) && (!ExsSerial->available())) ; @@ -550,8 +550,8 @@ void CmndExsState(void) ExsSendCmd(EXS_GET_VALUES, 0); // wait for data - uint32_t snd_time = millis(); - while ((TimePassedSince(snd_time) < EXS_ACK_TIMEOUT) && + uint32_t snd_time = millis() + EXS_ACK_TIMEOUT; + while ((!TimeReached(snd_time)) && (!ExsSerial->available())) ; ExsSerialInput(); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_45_shelly_dimmer.ino b/tasmota/tasmota_xdrv_driver/xdrv_45_shelly_dimmer.ino index 560f2cfbe..0d0f7dbce 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_45_shelly_dimmer.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_45_shelly_dimmer.ino @@ -277,8 +277,8 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) ShdSerial->flush(); // wait for any response - uint32_t snd_time = millis(); - while (TimePassedSince(snd_time) < SHD_ACK_TIMEOUT) + uint32_t snd_time = millis() + SHD_ACK_TIMEOUT; + while (!TimeReached(snd_time)) { if (ShdSerialInput()) return true; diff --git a/tasmota/tasmota_xsns_sensor/xsns_20_novasds.ino b/tasmota/tasmota_xsns_sensor/xsns_20_novasds.ino index 417aa699d..1e993b219 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_20_novasds.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_20_novasds.ino @@ -89,8 +89,8 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor NovaSdsSerial->flush(); // wait for any response - unsigned long cmndtime = millis(); - while ( (TimePassedSince(cmndtime) < NOVA_SDS_RECDATA_TIMEOUT) && ( ! NovaSdsSerial->available() ) ); + unsigned long cmndtime = millis() + NOVA_SDS_RECDATA_TIMEOUT; + while ( (!TimeReached(cmndtime)) && ( ! NovaSdsSerial->available() ) ); if ( ! NovaSdsSerial->available() ) { // timeout return false; @@ -98,7 +98,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor uint8_t recbuf[10]; memset(recbuf, 0, sizeof(recbuf)); // sync to 0xAA header - while ( (TimePassedSince(cmndtime) < NOVA_SDS_RECDATA_TIMEOUT) && ( NovaSdsSerial->available() > 0) && (0xAA != (recbuf[0] = NovaSdsSerial->read())) ); + while ( (!TimeReached(cmndtime)) && ( NovaSdsSerial->available() > 0) && (0xAA != (recbuf[0] = NovaSdsSerial->read())) ); if ( 0xAA != recbuf[0] ) { // no head found return false;