From 4ec60b7c74222a690d56c9af99f68e771b384ffc Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 20 Jul 2024 01:13:48 +0200 Subject: [PATCH] Update status led --> active high --- .../ClassControllCamera.cpp | 7 ++++++ code/components/jomjol_helper/statusled.cpp | 24 +++++++++++++++++++ code/include/defines.h | 9 ++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index 8b325d0cc..5aee2ddda 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -963,10 +963,17 @@ void CCamera::setStatusLED(bool _status) /* Set the GPIO as a push/pull output */ gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW if (!_status) gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); else gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#else + if (_status) + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); + else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#endif } } diff --git a/code/components/jomjol_helper/statusled.cpp b/code/components/jomjol_helper/statusled.cpp index 5f8e7c87a..5d97db1df 100644 --- a/code/components/jomjol_helper/statusled.cpp +++ b/code/components/jomjol_helper/statusled.cpp @@ -25,7 +25,11 @@ void task_StatusLED(void *pvParameter) esp_rom_gpio_pad_select_gpio(GPIO_STATUS_LED_ONBOARD); // Init the GPIO gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); // Set the GPIO as a push/pull output +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1);// LED off +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0);// LED off +#endif for (int i=0; i<2; ) // Default: repeat 2 times { @@ -34,9 +38,17 @@ void task_StatusLED(void *pvParameter) for (int j = 0; j < StatusLEDDataInt.iSourceBlinkCnt; ++j) { +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#endif vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#endif vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); } @@ -44,9 +56,17 @@ void task_StatusLED(void *pvParameter) for (int j = 0; j < StatusLEDDataInt.iCodeBlinkCnt; ++j) { +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#endif vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#endif vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); } vTaskDelay(1500 / portTICK_PERIOD_MS); // Delay to signal new round @@ -147,5 +167,9 @@ void StatusLEDOff(void) esp_rom_gpio_pad_select_gpio(GPIO_STATUS_LED_ONBOARD); // Init the GPIO gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); // Set the GPIO as a push/pull output +#ifdef GPIO_STATUS_LED_ONBOARD_ACTIVELOW gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1);// LED off +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0);// LED off +#endif } \ No newline at end of file diff --git a/code/include/defines.h b/code/include/defines.h index 7293b9e84..55f8173cc 100644 --- a/code/include/defines.h +++ b/code/include/defines.h @@ -365,7 +365,8 @@ CONFIG_WPA_11R_SUPPORT=n // LEDs //------------------------------------------------- - #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_33 // Onboard red status LED + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_33 // Onboard status LED (red, active low) + #define GPIO_STATUS_LED_ONBOARD_ACTIVELOW #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_4 // Onboard flashlight LED #ifdef BOARD_SDCARD_SDMMC_BUS_WIDTH_1 @@ -442,7 +443,8 @@ CONFIG_WPA_11R_SUPPORT=n // LEDs //------------------------------------------------- - #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_21 // Onboard yellow status LED (USER LED) + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_21 // Onboard yellow status LED (USER LED, yellow, active low) + #define GPIO_STATUS_LED_ONBOARD_ACTIVELOW #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_NC // No onboard flashlight available #define GPIO_FLASHLIGHT_DEFAULT GPIO_NUM_1 // Default flashlight GPIO pin (can be modified by activiating GPIO functionality in WebUI) @@ -507,7 +509,8 @@ CONFIG_WPA_11R_SUPPORT=n // LEDs //------------------------------------------------- - #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_2 // Onboard status LED + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_2 // Onboard status LED (blue, active high) + //#define GPIO_STATUS_LED_ONBOARD_ACTIVELOW #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_48 // Onboard flashlight (WS2812) #define GPIO_FLASHLIGHT_DEFAULT GPIO_FLASHLIGHT_ONBOARD // Default flashlight GPIO pin (can be modified by activiating GPIO functionality in WebUI)