Because 'TOGGLE' doesn't really have anything to do with switches or inputs, except to make inputs into outputs and 'TOGGLE' the state of that output.
You set up a couple of routines, one for each display, add in a flag variable.
In the main loop, you check your switches. If the correct switch is pushed, the loop jumps to one of the routines (according to the 'flag' setting) to display AND sets the 'flag' to X, then jumps back to the main loop.
If another switch is pushed, the loop jumps to another one of the routines (again, according to the 'flag' setting) to display AND sets the 'flag' to Y, and again, jumps back to the main loop to await another switch push.
Your program looks like it should work just fine, it's just a bit jumbled around and, as you pointed out, isn't quite as efficient as it could be. Then again, if it works, who cares![]()
Bookmarks