This commit is contained in:
iceman1001 2023-12-14 23:38:04 +01:00
parent 6b9963b12a
commit 70520af03b

View file

@ -268,8 +268,9 @@ int BUTTON_HELD(int ms) {
int ticks = (48000 * (ms ? ms : 1000)) >> 10;
// If we're not even pressed, forget about it!
if (BUTTON_PRESS() == false)
if (BUTTON_PRESS() == false) {
return BUTTON_NO_CLICK;
}
// Borrow a PWM unit for my real-time clock
AT91C_BASE_PWMC->PWMC_ENA = PWM_CHANNEL(0);
@ -284,12 +285,14 @@ int BUTTON_HELD(int ms) {
uint16_t now = AT91C_BASE_PWMC_CH0->PWMC_CCNTR;
// As soon as our button let go, we didn't hold long enough
if (BUTTON_PRESS() == false)
if (BUTTON_PRESS() == false) {
return BUTTON_SINGLE_CLICK;
}
// Have we waited the full second?
else if (now == (uint16_t)(start + ticks))
else if (now == (uint16_t)(start + ticks)) {
return BUTTON_HOLD;
}
WDT_HIT();
}