Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
why can't you just go (new - current)? Where a positive result is counting forward and a negative result is counting backward?
Arithmetic works on enum types.
#define CHKPTR(ptr,sz) if((ptr)>=(sz)) ptr=0
enum {DISP1, DISP2, DISP3, NDISP};
while(curProg != newProg) {
curProg++;
CHKPTR(curProg, NDISP);
}
#define CHKPTR(ptr,sz) if((ptr)>=(sz)) ptr=0
enum {DISP1, DISP2, DISP3, NDISP};
int main(void) {
// read curProg from non-volatile source - eeprom/flash
curProg = get_curProg();
curProg++;
CHKPTR(curProg, NDISP);
// store
set_curProg(curProg);
// ...continue with regular prog....
}