02-16-2007 11:57 AM
02-20-2007 10:21 AM
02-20-2007 12:12 PM
@therealkilkenny wrote:
I have put my main code in the timeout case (BTW is that a bad move?) so that the main code executes if there are no events.
That really depends on what the main code does. As long as the timeout event does something useful (acquiring data, creating errors ;), etc) the solutions is fine. (If it just recalculates the same thing over and over again, it's a waste of CPU.)
Of course if the timeout case really does something useful and it needs to occur at regular intervals, the timeout case is not great, because any other event will mess with the timing. For example if you have a timeout of 1 second and press another button after 999ms, the spacing between timeout events will double for one iteration. This might not be acceptable. You can solve this partially by dynamically recalculating the timeout and feed it via a shift register.
In summary, I would not used the timeout case for anything that should happen very regularly.