-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Update camera example for support LED Intensity #6791
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
Conversation
libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino
Outdated
Show resolved
Hide resolved
My 2 cents:
|
This reverts commit 74bf57f.
|
//#define CONFIG_LED_ILLUMINATOR_ENABLED 1 | ||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED | ||
#define FLASH_LED_GPIO GPIO_NUM_4 | ||
#define CONFIG_LED_MAX_INTENSITY 255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_LED_MAX_INTENSITY - defined but not used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_LED_MAX_INTENSITY - defined but not used anywhere.
It used for UI led intensity limit
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED
void enable_led(bool en)
{ // Turn LED On or Off
int duty = en ? led_duty : 0;
if (en && isStreaming && (led_duty > CONFIG_LED_MAX_INTENSITY))
{
duty = CONFIG_LED_MAX_INTENSITY;
}
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);
ESP_LOGI(TAG, "Set LED intensity to %d", duty);
}
#endif
#else | ||
ESP_LOGI(TAG, "Flash led illumination is not configured"); | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all this code should go to CameraWebServer.ino
instead of here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all this code should go to
CameraWebServer.ino
instead of here.
Please take a look - CONFIG_LED_ILLUMINATOR_ENABLED is defined in a app_httpd.cpp file and MAY be undifined on compile time for CameraWebServer.ino since compile order may be various. So we have an issue in this case. This can be resolved by moving defines in the header file (as I suggest in the fist commit) but:
Changing the example structure it outside of the scope of the issue.
So what is your desision for this case? Move all defines in the one CameraWebServer.ino or separate header or something else?
cc: @me-no-dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually ... CONFIG_LED_ILLUMINATOR_ENABLED is defined nowhere.
I also searched it in sdkconfig and there is nothing there as well.
This is a sort of loose example, maybe coming from IDF.
I changed my mind... just leave it there. I see other code lines in app_httpd.cpp that test CONFIG_LED_ILLUMINATOR_ENABLED.
ledcSetup(LEDC_CHANNEL_0, 4000, LEDC_TIMER_8_BIT); | ||
ledcAttachPin(FLASH_LED_GPIO, LEDC_CHANNEL_0); | ||
#else | ||
ESP_LOGI(TAG, "Flash led illumination is not configured"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Arduino function log_i(...)
instead of IDF ESP_LOGI()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Arduino function log_i(...) instead of IDF ESP_LOGI()
There are more then one line with ESP_LOGI (I think example was ported from IDF), so all must be changed or only this one or maybe leave as is? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... it is used all over in app_httpd.cpp.
If possible, it should be changed everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it simple for now. Keep it using ESP_LOGI()
@@ -1304,3 +1315,14 @@ void startCameraServer() | |||
httpd_register_uri_handler(stream_httpd, &stream_uri); | |||
} | |||
} | |||
|
|||
void ledc_setup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ledc_setup()
could have as parameters all the information declared in the #define
, making it more generic and clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ledc_setup()
could have as parameters all the information declared in the#define
, making it more generic and clear.
This is possible of course, but requre a lot of changes and still requre a defines since some boards can have different GPIO pins for led or not have a led at all. I can prepare such changes if you ready to review it, but first of all please look to the comment above where discussing about example structure. Can I append new header file for defines or not? I will move forvard depending of answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ... maybe this example should be refactored for good.
Let's keep it simple for now. Keep it as you proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is a copy of another example we have for ESP-IDF and turned into Arduino sketch. Structure allows changes if they make sense :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are my suggestions for this PR.
This example seems to come from an IDF example/structure. I found some other Arduino and IDF implementations that are based on this same example: I think the whole code may need a refactoring and a review. Given it only modifies a tiny piece in the example, I'm also not sure what is best to do with it as well... |
Unfortunately I'm not ready to spend a lot of time with this example. Reason is quite simple - this is not so interesting for me and I better continue work with my own project: https://github.com/DmytroKorniienko/esp32cam_EmbUI which has intesity support too and based on Asyncwebser. Feel free to close this PR and start new work with code refactoring if you want. No offense on my part :). I'm willing to make partial corrections, but not a complete rewrite of the example, because I don't think byte array-packed resources (index.html) are a good idea and prefer using a filesystem. |
The ESP32-CAM Flight Light LED Illuminator solution which everyone is awaiting is now resolved by the blog author and programmer Bye Renzo Thank you ;) |
@PilnyTomas Please research shared resources and evaluate if the refactoring is needed and how. We can discuss later what are the options. Related HW is available. |
Have you tried compiling it for all the possible boards? Changes in PR should not break stuff for other users. |
any updates on this @DmytroKorniienko? Thanks |
Due to no answer, @PilnyTomas will take over and finish this PR. |
Hi, I have some other tasks not related with opensource, so can't monitor PR with a so long lifecycle))). But I can take a look if this still necessary. I have ESP32-CAM and ESP32,ESP32-C3,ESP32-S2,ESP32-S3 without attached camera - so can only test ability to compile/link without errors. Let me know if this what you need, otherwise - feel free to do all needed work by yourself.
|
You can use LOW SPEED mode, then code compiled without errors at S3: Moreover CONFIG_LED_ILLUMINATOR_ENABLED is DISABLED by default, so changes can't break something in an exising code. If you have any suggestions - please explain. CC: @VojtechBartoska |
Hi @DmytroKorniienko, the code should detect which board is used with |
Hi @PilnyTomas, as I said - CONFIG_LED_ILLUMINATOR_ENABLED is disabled by default. Are you think there is a good idea to enable it??? Some boards can be without leds at all, some have led on a other pin then ESP32_CAM module and at my opinion - impossible make universal variant for all cases. But if you want and going to do improvements - go ahead. BTW: Instead of analyzing CONFIG_IDF_TARGET_ESP32S3 better check SOC_LEDC_SUPPORT_HS_MODE, look at hal/ledc_types.h:
|
@DmytroKorniienko Thanks for your time, but closing this PR as I have created new PR #7533 with these changes. |
Closes #6790