mirror of https://github.com/arendst/Tasmota.git
Refactor to TimeReacged()
This commit is contained in:
parent
e74142724c
commit
4f62a0deab
|
@ -135,7 +135,7 @@ void MqttPublishDomoticzFanState(void) {
|
||||||
Response_P(DOMOTICZ_MESSAGE, (int)DomoticzRelayIdx(1), (0 == fan_speed) ? 0 : 2, svalue, DomoticzBatteryQuality(), DomoticzRssiQuality());
|
Response_P(DOMOTICZ_MESSAGE, (int)DomoticzRelayIdx(1), (0 == fan_speed) ? 0 : 2, svalue, DomoticzBatteryQuality(), DomoticzRssiQuality());
|
||||||
MqttPublish(domoticz_in_topic);
|
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) {
|
if (GetFanspeed() == svalue) {
|
||||||
return true; // Stop as already set
|
return true; // Stop as already set
|
||||||
}
|
}
|
||||||
if (TimePassedSince(Domoticz->fan_debounce) < 1000) {
|
if (!TimeReached(Domoticz->fan_debounce)) {
|
||||||
return true; // Stop if device in limbo
|
return true; // Stop if device in limbo
|
||||||
}
|
}
|
||||||
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_FANSPEED));
|
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_FANSPEED));
|
||||||
|
|
|
@ -215,13 +215,7 @@ void ShutterAllowPreStartProcedure(uint8_t i) {
|
||||||
#ifdef USE_RULES
|
#ifdef USE_RULES
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]);
|
||||||
// wait for response from rules
|
// wait for response from rules
|
||||||
/*
|
uint32_t end_time = millis() + 10000; // 10 seconds
|
||||||
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") {
|
while (!TimeReached(end_time) && (String)rules_vars[i] == "99") {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
@ -1389,12 +1383,6 @@ void ShutterUpdateVelocity(uint8_t i)
|
||||||
|
|
||||||
void ShutterWaitForMotorStart(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;
|
uint32_t end_time = Shutter[i].last_stop_time + ShutterSettings.shutter_motorstop;
|
||||||
while (!TimeReached(end_time)) {
|
while (!TimeReached(end_time)) {
|
||||||
loop();
|
loop();
|
||||||
|
|
|
@ -654,12 +654,6 @@ void ShutterWaitForMotorStop(uint8_t i)
|
||||||
|
|
||||||
void ShutterWaitForMotorStart(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;
|
uint32_t end_time = Shutter[i].last_stop_time + Settings->shutter_motorstop;
|
||||||
while (!TimeReached(end_time)) {
|
while (!TimeReached(end_time)) {
|
||||||
loop();
|
loop();
|
||||||
|
@ -740,12 +734,6 @@ void ShutterAllowPreStartProcedure(uint8_t i) {
|
||||||
#ifdef USE_RULES
|
#ifdef USE_RULES
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i + 1, rules_vars[i]);
|
||||||
// wait for response from rules
|
// 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;
|
||||||
while (!TimeReached(end_time) && (String)rules_vars[i] == "99") {
|
while (!TimeReached(end_time) && (String)rules_vars[i] == "99") {
|
||||||
delay(1);
|
delay(1);
|
||||||
|
|
|
@ -135,8 +135,8 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
|
||||||
ExsSerial->flush();
|
ExsSerial->flush();
|
||||||
|
|
||||||
// wait for any response
|
// wait for any response
|
||||||
uint32_t snd_time = millis();
|
uint32_t snd_time = millis() + EXS_ACK_TIMEOUT;
|
||||||
while ((TimePassedSince(snd_time) < EXS_ACK_TIMEOUT) &&
|
while ((!TimeReached(snd_time)) &&
|
||||||
(!ExsSerial->available()))
|
(!ExsSerial->available()))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -550,8 +550,8 @@ void CmndExsState(void)
|
||||||
ExsSendCmd(EXS_GET_VALUES, 0);
|
ExsSendCmd(EXS_GET_VALUES, 0);
|
||||||
|
|
||||||
// wait for data
|
// wait for data
|
||||||
uint32_t snd_time = millis();
|
uint32_t snd_time = millis() + EXS_ACK_TIMEOUT;
|
||||||
while ((TimePassedSince(snd_time) < EXS_ACK_TIMEOUT) &&
|
while ((!TimeReached(snd_time)) &&
|
||||||
(!ExsSerial->available()))
|
(!ExsSerial->available()))
|
||||||
;
|
;
|
||||||
ExsSerialInput();
|
ExsSerialInput();
|
||||||
|
|
|
@ -277,8 +277,8 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
|
||||||
ShdSerial->flush();
|
ShdSerial->flush();
|
||||||
|
|
||||||
// wait for any response
|
// wait for any response
|
||||||
uint32_t snd_time = millis();
|
uint32_t snd_time = millis() + SHD_ACK_TIMEOUT;
|
||||||
while (TimePassedSince(snd_time) < SHD_ACK_TIMEOUT)
|
while (!TimeReached(snd_time))
|
||||||
{
|
{
|
||||||
if (ShdSerialInput())
|
if (ShdSerialInput())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -89,8 +89,8 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
|
||||||
NovaSdsSerial->flush();
|
NovaSdsSerial->flush();
|
||||||
|
|
||||||
// wait for any response
|
// wait for any response
|
||||||
unsigned long cmndtime = millis();
|
unsigned long cmndtime = millis() + NOVA_SDS_RECDATA_TIMEOUT;
|
||||||
while ( (TimePassedSince(cmndtime) < NOVA_SDS_RECDATA_TIMEOUT) && ( ! NovaSdsSerial->available() ) );
|
while ( (!TimeReached(cmndtime)) && ( ! NovaSdsSerial->available() ) );
|
||||||
if ( ! NovaSdsSerial->available() ) {
|
if ( ! NovaSdsSerial->available() ) {
|
||||||
// timeout
|
// timeout
|
||||||
return false;
|
return false;
|
||||||
|
@ -98,7 +98,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
|
||||||
uint8_t recbuf[10];
|
uint8_t recbuf[10];
|
||||||
memset(recbuf, 0, sizeof(recbuf));
|
memset(recbuf, 0, sizeof(recbuf));
|
||||||
// sync to 0xAA header
|
// 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] ) {
|
if ( 0xAA != recbuf[0] ) {
|
||||||
// no head found
|
// no head found
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue