diff --git a/main.c b/main.c index 8448e64..7be0460 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,7 @@ pthread_cond_t isr_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t isr_mtx = PTHREAD_MUTEX_INITIALIZER; unsigned int pin_pressed= 0; +unsigned int last_pressed_time = 0; #define FASTFORWARD_PIN 5 #define PLAYPAUSE_PIN 6 @@ -21,7 +22,13 @@ void serviceInterrupt(int pin) { pthread_mutex_lock(&isr_mtx); - pin_pressed = pin; + unsigned int now = millis(); + if ((last_pressed_time + 100) < now) { + pin_pressed = pin; + last_pressed = now; + } else { + pin_pressed = 0; + } pthread_cond_signal(&isr_cond); pthread_mutex_unlock(&isr_mtx); }