diff --git a/main.c b/main.c index fa9cacd..5dd15af 100644 --- a/main.c +++ b/main.c @@ -54,23 +54,35 @@ wiringPiISR(VOLUMEUP_PIN, INT_EDGE_FALLING, &volumeUpInterrupt); for(;;) { + int last_pin_pressed = 0; pthread_mutex_lock(&isr_mtx); while (pin_pressed == 0) { pthread_cond_wait(&isr_cond, &isr_mtx); } - printf("Pressed %d\n", pin_pressed); - switch(pin_pressed) { + last_pin_pressed = pin_pressed; + pin_pressed = 0; + pthread_mutex_unlock(&isr_mtx); + switch(last_pin_pressed) { case PLAYPAUSE_PIN: - mpd_send_toggle_pause(conn); + case ONOFF_PIN: + mpd_run_toggle_pause(conn); break; case FASTFORWARD_PIN: - mpd_send_next(conn); + mpd_run_next(conn); + break; + case REWIND_PIN: + mpd_run_previous(conn); + break; + case VOLUMEDOWN_PIN: + mpd_run_change_volume(conn, -10); + break; + case VOLUMEUP_PIN: + mpd_run_change_volume(conn, 10); break; default: break; } - pin_pressed = 0; - pthread_mutex_unlock(&isr_mtx); + } return 0;