Code: Select all
enum {STANDBY, ACCESSORY, PRIMARY, FAULT} state = STANDBY;
// more variables and setup() function ...
void loop() {
switch(state) {
case STANDBY:
if(is_fault(0)) {
state = FAULT;
break;
}
// 20 more lines of code that i don't want to execute if the if-condition was true.
state = PRIMARY;
break;
case ACCESSORY:
if(is_fault(0)){
state = FAULT;
}
break;
case PRIMARY:
if(is_fault(1)) {
state = FAULT;
}
break;
case FAULT:
// do lots of stuff that I have not written yet
break;
}
}