From 9d9028979c6614df6026b837f4decb7ad9678511 Mon Sep 17 00:00:00 2001 From: Tom Van Braeckel Date: Sun, 4 Aug 2024 19:24:43 +0200 Subject: [PATCH] Add RG_GPIO_LED_ACTIVE_LOW option On the Fri3d Camp 2024 badge, the RG_GPIO_LED is active low, meaning it is on when the output is 0/low and off when the output is 3V3/high. Therefore, we need a way to invert the regular RG_GPIO_LED. At first I used RG_GPIO_LED_INVERT but that is less descriptive than RG_GPIO_LED_ACTIVE_LOW. --- components/retro-go/rg_system.c | 4 ++++ components/retro-go/targets/fri3d-2024/config.h | 1 + 2 files changed, 5 insertions(+) diff --git a/components/retro-go/rg_system.c b/components/retro-go/rg_system.c index 502153f16..468fcffaa 100644 --- a/components/retro-go/rg_system.c +++ b/components/retro-go/rg_system.c @@ -887,7 +887,11 @@ void rg_system_set_led(int value) { #if defined(ESP_PLATFORM) && defined(RG_GPIO_LED) if (app.ledValue != value) +#ifndef RG_GPIO_LED_ACTIVE_LOW gpio_set_level(RG_GPIO_LED, value); +#else + gpio_set_level(RG_GPIO_LED, !value); +#endif #endif app.ledValue = value; } diff --git a/components/retro-go/targets/fri3d-2024/config.h b/components/retro-go/targets/fri3d-2024/config.h index 760ebefa4..b20989125 100644 --- a/components/retro-go/targets/fri3d-2024/config.h +++ b/components/retro-go/targets/fri3d-2024/config.h @@ -86,6 +86,7 @@ // Status LED #define RG_GPIO_LED GPIO_NUM_21 +#define RG_GPIO_LED_ACTIVE_LOW // setting RG_GPIO_LED low turns on the LED, while high turns it off // Battery #define RG_BATTERY_DRIVER 1