| ??? 04/20/10 17:39 Modified: 04/20/10 17:40 Read: times |
#175188 - Sample superloop Responding to: ???'s previous message |
Notice that you are expected to place your code inside the the code/endcode tags, i.e. replace the text "...insert code here" with your code.
...insert code here Maybe something like this (assuming you have an ISR that updates a variable "time" every n ms.
for (;;) {
if (last_keyscan_time != time) {
last_keyscan_time = time;
key = get_key();
if (!key) {
key_armed = TRUE; // Have seen key lift, so may accept new key presses.
} else if (key == prev_key) {
// Multiple identical read.
if (key_armed) {
// First time same read since last key lift.
handle_key(key);
key_armed = FALSE; // Don't want key repetition.
}
} else {
// Still jittery detection - do nothing.
}
}
// Do other important stuff
handle_adc();
handle_received_data();
} // for
|



