#define PWRLED 8
#define CHNL1LED 9
#define CHNL2LED 7
+#define INTROLED 12
#define PWRBTN 0
#define CHNL1BTN 2
#define CHNL2BTN 3
+#define INTROBTN 13
static volatile bool running = true;
static volatile bool pwrOn = false;
static volatile bool chnl1 = true;
+static volatile bool intro = false;
//static volatile bool sthchanged = false;
static pthread_cond_t* wakeup;
static pthread_mutex_t* mut;
void pwrBtn(void) {
pthread_mutex_lock(mut);
pwrOn = !pwrOn;
+ if (pwrOn) intro = false;
pthread_mutex_unlock(mut);
pthread_cond_signal(wakeup);
}
pthread_cond_signal(wakeup);
}
+void introBtn(void) {
+ pthread_mutex_lock(mut);
+ intro = !intro;
+ pthread_mutex_unlock(mut);
+ pthread_cond_signal(wakeup);
+}
+
int main(void) {
printf("Initializing...\n");
if (wiringPiSetup() == -1) {
pinMode(PWRBTN, INPUT);
pinMode(CHNL1BTN, INPUT);
pinMode(CHNL2BTN, INPUT);
+ pinMode(INTROBTN, INPUT);
pullUpDnControl(PWRBTN, PUD_UP);
pullUpDnControl(CHNL1BTN, PUD_UP);
pullUpDnControl(CHNL2BTN, PUD_UP);
+ pullUpDnControl(INTROBTN, 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");
printf("Set LED pins to output\n");
pinMode(PWRLED, OUTPUT);
pinMode(CHNL1LED, OUTPUT);
pinMode(CHNL2LED, OUTPUT);
+ pinMode(INTROLED, OUTPUT);
printf("initialize mutex and condition variable\n");
mut = malloc (sizeof(pthread_mutex_t));
digitalWrite(CHNL1LED, HIGH);
digitalWrite(CHNL2LED, HIGH);
chnl1=true;
+ if (intro) playThread = startPlayThread("intro.mp3");
} else {
digitalWrite(PWRLED, LOW);
if (chnl1) {
digitalWrite(PWRLED, HIGH);
digitalWrite(CHNL1LED, HIGH);
digitalWrite(CHNL2LED, HIGH);
+ digitalWrite(INTROLED, HIGH);
pullUpDnControl(PWRBTN, PUD_DOWN);
pullUpDnControl(CHNL1BTN, PUD_DOWN);
pullUpDnControl(CHNL2BTN, PUD_DOWN);
+ pullUpDnControl(INTROBTN, PUD_DOWN);
}