07-03-2007 02:57 AM
07-03-2007 03:44 AM
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
07-03-2007 04:26 AM
07-03-2007 10:13 AM
What you need is a simple state machine with three states: (1) [both off], (2) [A blinking], (3) [B blinking], best defined as a typedef enum. Use a boolean in a shift register to do the 1000ms on/off and have a case structure that wires the desired LED to it. The event structure simply switches state depending on what was pressed and what the current state is.
Attached is a simple example with a few diagram comments. (I use a plain enum in the example for simplicity). See if it helps.
Personally, I don't really like to use the "blinking" property, because it is less flexible in terms of rate. I my code it would be trivial to change it to blink ever 300ms or every 2 seconds. Here it always blinks between the regular on/off colors and not some other color scheme.
If you get stuck with code like you did, it always helps to observe the diagram in execution highlighting mode. You will see where the "hangup" is. 🙂
07-04-2007 09:57 PM