]> Johnzone git - FakeRadio.git/commitdiff
fix initialisation of btn pins
authorJohn Janus <mail@johnzone.org>
Sun, 27 Aug 2017 08:28:54 +0000 (10:28 +0200)
committerJohn Janus <mail@johnzone.org>
Sun, 27 Aug 2017 08:28:54 +0000 (10:28 +0200)
simple_try.c

index 9c8df92d3c77c5f444857a341f52d70f85c499a0..d55a5fc51699444f338a6490866046b335630018 100644 (file)
@@ -34,39 +34,33 @@ void chnl2Btn(void) {
 }
 
 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);
@@ -77,8 +71,10 @@ int main(void) {
             digitalWrite(CHNL2LED, LOW);
             digitalWrite(CHNL1LED, HIGH);
         }
+        delay(200);
 
     }
+    printf("ShuttingDown\n");
     digitalWrite(PWRLED, HIGH);
     digitalWrite(CHNL1LED, HIGH);
     digitalWrite(CHNL2LED, HIGH);