From: John Janus Date: Sun, 27 Aug 2017 08:28:54 +0000 (+0200) Subject: fix initialisation of btn pins X-Git-Url: https://git.johnzone.org/?a=commitdiff_plain;h=ebcab71460846b7732d7c50bb00e93fc1affc193;p=FakeRadio.git fix initialisation of btn pins --- diff --git a/simple_try.c b/simple_try.c index 9c8df92..d55a5fc 100644 --- a/simple_try.c +++ b/simple_try.c @@ -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);