}
int main(void) {
+ printf("Initializing...\n");
if (wiringPiSetup() == -1) {
- printf("Error during setup");
+ printf("Error during setup\n");
return 1;
}
signal(SIGINT, ctrlCHandler);
- wiringPiISR(PWRBTN, INT_EDGE_RISING, pwrBtn);
- wiringPiISR(CHNL1BTN, INT_EDGE_RISING, chnl1Btn);
- wiringPiISR(CHNL2BTN, INT_EDGE_RISING, chnl2Btn);
- pinMode(PWRLED, OUTPUT);
- pinMode(CHNL1LED, OUTPUT);
- pinMode(CHNL2LED, OUTPUT);
-
- /*pinMode(PWRBTN, INPUT);
+ pinMode(PWRBTN, INPUT);
pinMode(CHNL1BTN, INPUT);
pinMode(CHNL2BTN, INPUT);
pullUpDnControl(PWRBTN, PUD_UP);
pullUpDnControl(CHNL1BTN, PUD_UP);
- pullUpDnControl(CHNL2BTN, PUD_UP);*/
-
+ pullUpDnControl(CHNL2BTN, 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");
+ printf("Set LED Pins to output\n");
+
+ pinMode(PWRLED, OUTPUT);
+ pinMode(CHNL1LED, OUTPUT);
+ pinMode(CHNL2LED, OUTPUT);
+ printf("Start Main Loop\n");
while (running) {
- /*digitalWrite(PWRLED, LOW);
- digitalWrite(CHNL1LED, LOW);
- digitalWrite(CHNL2LED, HIGH);
- delay(5000);
- digitalWrite(CHNL2LED, LOW);
- digitalWrite(CHNL1LED, HIGH);
- delay(5000);*/
if (!pwrOn) {
digitalWrite(PWRLED, HIGH);
digitalWrite(CHNL1LED, HIGH);
digitalWrite(CHNL2LED, HIGH);
- delay(500);
continue;
}
digitalWrite(PWRLED, LOW);
digitalWrite(CHNL2LED, LOW);
digitalWrite(CHNL1LED, HIGH);
}
+ delay(200);
}
+ printf("ShuttingDown\n");
digitalWrite(PWRLED, HIGH);
digitalWrite(CHNL1LED, HIGH);
digitalWrite(CHNL2LED, HIGH);