int buttonPress (void)
{
static int downCount= 0; // static = value isn't lost between calls.
int currentButton = ((IO0PIN & 0x00000200) == 0x00000200);
if (currentButton ) { // button is down
if (downCount == 5) { // button has been down for 5 counts
downCount++; // increase the count so we don't trigger next time
return 1;
} else { // some count other than 5
if (downCount < 5) // increase if it's less than 5
downCount++;
}
} else { // button is up
downCount = 0;
}
return 0;
}
if (currentButton ) { // button is down
if (downCount == 5) { // button has been down for 5 counts
downCount++; // increase the count so we don't trigger next time
while (downCount > 5) {
if (debounce == 300000) {
flag_5SEC = 1;
}
else if (debounce < 300000) {
debounce++;
}
}
return 1;
} else { // some count other than 5
if (downCount < 5) // increase if it's less than 5
downCount++;
}
}