From a09e3f1973801013f04a24b5bf31f740ce60741a Mon Sep 17 00:00:00 2001 From: John Janus Date: Sun, 17 Sep 2017 11:09:19 +0200 Subject: [PATCH] add delaying mechanics, impl not good --- simple_try.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simple_try.c b/simple_try.c index ddc8f77..dbae4e5 100644 --- a/simple_try.c +++ b/simple_try.c @@ -22,6 +22,7 @@ static volatile bool running = true; static volatile bool pwrOn = false; static volatile bool chnl1 = true; static volatile bool intro = false; +static volatile bool delaying = false; //static volatile bool sthchanged = false; static pthread_cond_t* wakeup; static pthread_mutex_t* mut; @@ -38,6 +39,7 @@ void ctrlCHandler(int signum) { } void pwrBtn(void) { + if (delaying) return; pthread_mutex_lock(mut); pwrOn = !pwrOn; if (pwrOn) intro = false; @@ -46,6 +48,7 @@ void pwrBtn(void) { } void chnl1Btn(void) { + if (delaying) return; pthread_mutex_lock(mut); chnl1 = true; pthread_mutex_unlock(mut); @@ -53,6 +56,7 @@ void chnl1Btn(void) { } void chnl2Btn(void) { + if (delaying) return; pthread_mutex_lock(mut); chnl1 = false; pthread_mutex_unlock(mut); @@ -60,6 +64,7 @@ void chnl2Btn(void) { } void introBtn(void) { + if (delaying) return; pthread_mutex_lock(mut); intro = !intro; pthread_mutex_unlock(mut); @@ -104,7 +109,7 @@ int main(void) { while (running) { pthread_mutex_lock(mut); pthread_cond_wait(wakeup, mut); - + delaying = true; if (playThread) { pthread_cancel(playThread); } @@ -134,6 +139,7 @@ int main(void) { } } delay(500); + delaying = false; pthread_mutex_unlock(mut); } -- 2.47.0