static volatile bool intro = false;
static volatile bool horn = false;
static volatile bool delaying = false;
-//static volatile bool sthchanged = false;
+static volatile bool sthchanged = false;
static pthread_cond_t* wakeup;
static pthread_mutex_t* mut;
static pthread_t playThread;
if (pwrstate==digitalRead(PWRBTN)) {
pwrOn = !pwrOn;
if (pwrOn) intro = false;
+ sthchanged = true;
}
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
delay(UNPRELL);
if (chnl1state==digitalRead(CHNL1BTN)) {
chnl1 = true;
+ sthchanged = true;
}
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
delay(UNPRELL);
if (chnl2state==digitalRead(CHNL2BTN)) {
chnl1 = false;
+ sthchanged = true;
}
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
if (introstate==digitalRead(INTROBTN)) {
intro = !intro;
horn = false;
+ sthchanged = true;
}
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
if (hornstate==digitalRead(HORNBTN)) {
horn = !horn;
intro = false;
+ sthchanged = true;
}
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
while (running) {
pthread_mutex_lock(mut);
pthread_cond_wait(wakeup, mut);
+ if (!sthchanged) {
+ pthread_mutex_unlock(mut);
+ continue;
+ }
+ sthchanged = false;
delaying = true;
if (playThread) {
pthread_cancel(playThread);