Skip to content

Commit

Permalink
Update status led --> active high
Browse files Browse the repository at this point in the history
  • Loading branch information
Slider0007 committed Jul 19, 2024
1 parent 8236d29 commit 4ec60b7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions code/components/jomjol_controlcamera/ClassControllCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
24 changes: 24 additions & 0 deletions code/components/jomjol_helper/statusled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -34,19 +38,35 @@ 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);
}

vTaskDelay(500 / portTICK_PERIOD_MS); // Delay between module code and error code

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
Expand Down Expand Up @@ -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
}
9 changes: 6 additions & 3 deletions code/include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4ec60b7

Please sign in to comment.