From c94273f8bfb3dd16ff6c6b508f4002ca27850d2f Mon Sep 17 00:00:00 2001 From: fastium Date: Fri, 24 Apr 2026 14:08:39 +0200 Subject: [PATCH] feat(lab03): setup epoll on 3 button --- src/03-led-controller/main.c | 104 ++++++++++++++++------------------ src/03-led-controller/setup.c | 4 +- 2 files changed, 50 insertions(+), 58 deletions(-) diff --git a/src/03-led-controller/main.c b/src/03-led-controller/main.c index a2d5e5f..fb5bf33 100644 --- a/src/03-led-controller/main.c +++ b/src/03-led-controller/main.c @@ -1,27 +1,3 @@ -/** - * Copyright 2018 University of Applied Sciences Western Switzerland / Fribourg - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Project: HEIA-FR / HES-SO MSE - MA-CSEL1 Laboratory - * - * Abstract: System programming - file system - * - * Purpose: NanoPi silly status led control system - * - * Autĥor: Daniel Gachet - * Date: 07.11.2018 - */ #include #include #include @@ -42,30 +18,36 @@ * power led - gpiol.10 --> gpio362 */ -#define GPIO_LED "/sys/class/gpio/gpio10" -#define LED "10" +#define GPIO_LED "/sys/class/gpio/gpio10" +#define LED "10" #define GPIO_BTN1 "/sys/class/gpio/gpio0" -#define BTN1 "0" +#define BTN1 "0" #define GPIO_BTN2 "/sys/class/gpio/gpio2" -#define BTN2 "2" +#define BTN2 "2" #define GPIO_BTN3 "/sys/class/gpio/gpio3" -#define BTN3 "3" - +#define BTN3 "3" +#define NBR_BTN 3 +// constant +const char* GPIO_BTN[NBR_BTN] = {GPIO_BTN1, GPIO_BTN2, GPIO_BTN3}; +const char* BTN[NBR_BTN] = {BTN1, BTN2, BTN3}; int main(void) { - printf("Starting Button 1 Test...\n"); - int btn1 = open_btn(GPIO_BTN1, BTN1); - if (btn1 < 0) { - perror("Failed to open button"); - return 1; + // Open all button with the right flags + int btn[NBR_BTN] = {0}; + for(int i=0; i