Hi, I have started working on an app that will work long term. It will be powered by a battery that will be recharged from the grid/solar panel. So unless there is some problem, the app can run for up to a few years.
The processes will be queued using millis() function. This is where the overflow problem occurs. So I was looking for a solution and I found actually a very simple one.
Instead of:
if(lastJob + 2000 <= millis()){
Use:
if ((unsigned long)(millis() - lastJob) > 2000){
Which I verified with this dump:
if ((unsigned long)(millis() - lastJob) > 2000)
{
Serial.print(millis() - lastJob);
Serial.print("/");
Serial.println(millis());
lastJob = millis();
}
And I guess it works, but I wonder how it's really going to be in the long run. The millis() method did once reach its limit based on the data type.
Or am I understanding the whole thing wrong?