System.updatesPending() returns true if System.disableUpdates(); has been called and an update has been attempted but the update does not go through because it was disabled.
The system does not later try to re-flash after System.enableUpdates(); has been called.
I’m thinking that System.updatesPending() should return false after a timeout or if the update failed? Below is the code that I’m using to control the use of updates.
Is there a way to force System.updatesPending() to false is a timeout has occurred?
void systemUpdateScreen(){
if(System.updatesPending()){
systemUpdateReady = true;
}
if(millis() - systemUpdateTimeOut > 60000){ //time out if update doenst complete within this time
systemUpdating = false;
}
if(millis() - systemUpdateMillis > 3000){
byte tempNextEvent = currEvent + 1;
if (tempNextEvent > eventCt) {
tempNextEvent = 0;
}
byte updateDelay = 5; //minutes before mode 2 to prevent system update
int tempNextStartAdjusted = dataArr[tempNextEvent][0] - updateDelay;
if (tempNextStartAdjusted < 0) {
tempNextStartAdjusted += 1440;
}
String tempNextStartAdj = String(tempNextStartAdjusted);
//setWhite19Text();
//pxs.print(85, 10, String(tempNextStartAdj));
//printMidText(10, tempNextStartAdj);
if(mode == 3 || mode == 2 || (currTime >= tempNextStartAdjusted && currTime <= (tempNextStartAdjusted + updateDelay + timeToEnd))){
System.disableUpdates();
} else {
if(systemUpdateReady && !systemUpdating){
pxs.setBackground(255,128,0); //orange
pxs.clear();
setWhite19Text();
pxs.setBackground(255,204,153); // light orange for antialiased
printMidText("System Update", 100);
printMidText("Started", 125);
printMidText("PLEASE DO NOT", 170);
printMidText("TURN OFF POWER", 195);
systemUpdating = true;
systemUpdateTimeOut = millis();
}
System.enableUpdates();
}
systemUpdateMillis = millis();
}
}