Skip to content

fix(example): led flash not working if not using default model in camera example. #11466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
// LED FLASH setup
#if CONFIG_LED_ILLUMINATOR_ENABLED

#define LED_LEDC_GPIO 22 //configure LED pin
#define CONFIG_LED_MAX_INTENSITY 255

int led_pin = 22; // Store the actual LED pin used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22 is invalid GPIO on some chips. Code should be reworked so that CONFIG_LED_ILLUMINATOR_ENABLED and LED_LEDC_GPIO are defined in the camera board config and not just be enabled by default

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review, I'm working on a version that use #if defined(LED_GPIO_NUM) to check if LED is available.
I'll test on real hardware this weekend and upload the new fix.

int led_duty = 0;
bool isStreaming = false;

Expand Down Expand Up @@ -97,7 +97,7 @@ void enable_led(bool en) { // Turn LED On or Off
if (en && isStreaming && (led_duty > CONFIG_LED_MAX_INTENSITY)) {
duty = CONFIG_LED_MAX_INTENSITY;
}
ledcWrite(LED_LEDC_GPIO, duty);
ledcWrite(led_pin, duty);
//ledc_set_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL, duty);
//ledc_update_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL);
log_i("Set LED intensity to %d", duty);
Expand Down Expand Up @@ -845,6 +845,7 @@ void startCameraServer() {

void setupLedFlash(int pin) {
#if CONFIG_LED_ILLUMINATOR_ENABLED
led_pin = pin; // Store the actual LED pin used
ledcAttach(pin, 5000, 8);
#else
log_i("LED flash is disabled -> CONFIG_LED_ILLUMINATOR_ENABLED = 0");
Expand Down