I have the following code that works unexpected, it returns true always, even if called directly after start_tme was set millis(). platform arduino, processoresp32-s3 devkitc-1
/**
* @brief checks if a start + wait time greater than millis(), start time was set
* from millis() some time before
* @param start_time
* @param wait_time
* @returns TRUE if condition met, FALSE if not
*/
bool my_timer(unsigned long start_time, unsigned long wait_time)
{
bool erg;
erg = false;
Serial.print("millis ");Serial.println(millis());
Serial.print("start_time ");Serial.println(start_time);
Serial.print("wait ");Serial.println(wait_time);
if ((millis()) > (start_time + wait_time));
{
erg = true;
}
return erg;
} // END my_timer
first I had the following Version.
bool my_timer(unsigned long start_time, unsigned long wait_time)
{
bool erg;
erg = false;
if (millis() > start_time + wait_time)
{
erg = true;
}
return erg;
} // END my_timer
it worked sometimes and call from an other part in the code, the same returns true even if time not over. wait_time is alwasy 30000
in this application overflow is not a theme as it is shure the system is restartet at least once a day. On the other hand I still do unterstand why the first version returned true while the wait time is not reached. I need two none blocking timers so I used millis(), So I have one variable and a constant all unsigned long, for each timer, a start time, that is set with millis() the it is started and the constant with the wait time.
the 50 years I am programming I never had a function doing different things by entering the same values