#define CHNL1BTN 2
#define CHNL2BTN 3
#define INTROBTN 13
+#define HORNBTN 11
static volatile bool running = true;
static volatile bool pwrOn = false;
static volatile bool chnl1 = true;
static volatile bool intro = false;
+static volatile bool horn = false;
static volatile bool delaying = false;
//static volatile bool sthchanged = false;
static pthread_cond_t* wakeup;
pthread_cond_signal(wakeup);
}
+void hornBtn(void) {
+ if (delaying || pwrOn) return;
+ pthread_mutex_lock(mut);
+ horn = !horn;
+ pthread_mutex_unlock(mut);
+ pthread_cond_signal(wakeup);
+}
+
int main(void) {
printf("Initializing...\n");
if (wiringPiSetup() == -1) {
pinMode(CHNL1BTN, INPUT);
pinMode(CHNL2BTN, INPUT);
pinMode(INTROBTN, INPUT);
+ pinMode(HORNBTN, INPUT);
pullUpDnControl(PWRBTN, PUD_UP);
pullUpDnControl(CHNL1BTN, PUD_UP);
pullUpDnControl(CHNL2BTN, PUD_UP);
pullUpDnControl(INTROBTN, PUD_UP);
+ pullUpDnControl(HORNBTN, PUD_UP);
if (wiringPiISR(PWRBTN, INT_EDGE_RISING, pwrBtn)) printf("failed to initialize pwrBtn\n");
if (wiringPiISR(CHNL1BTN, INT_EDGE_RISING, chnl1Btn)) printf("failed to initialize chnl1Btn\n");
if (wiringPiISR(CHNL2BTN, INT_EDGE_RISING, chnl2Btn)) printf("failed to initialize chnl2Btn\n");
if (wiringPiISR(INTROBTN, INT_EDGE_RISING, introBtn)) printf("failed to initialize introBtn\n");
+ if (wiringPiISR(HORNBTN, INT_EDGE_RISING, hornBtn)) printf("failed to initialize hornBtn\n");
printf("Set LED pins to output\n");
pinMode(PWRLED, OUTPUT);
if (intro) {
playThread = startPlayThread("intro.mp3", true);
digitalWrite(INTROLED, LOW);
+ horn = false;
+ } else if (horn) {
+ playThread = startPlayThread("nebelhorn.mp3", true);
+ intro = false;
+ digitalWrite(INTROLED, HIGH);
} else {
digitalWrite(INTROLED, HIGH);
}
}
printf("ShuttingDown\n");
+ pthread_cancel(playThread);
pthread_cond_destroy(wakeup);
pthread_mutex_destroy(mut);
free(wakeup);