-
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
Changes from all commits
74bf57f
f5dffd3
0aeed97
5fde24a
55a27b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,17 @@ | |
#include "sdkconfig.h" | ||
#include "camera_index.h" | ||
|
||
//#define CONFIG_LED_ILLUMINATOR_ENABLED 1 | ||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED | ||
#define FLASH_LED_GPIO GPIO_NUM_4 | ||
#define CONFIG_LED_MAX_INTENSITY 255 | ||
#define CONFIG_LED_LEDC_CHANNEL LEDC_CHANNEL_0 | ||
#endif | ||
|
||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED | ||
#include "esp32-hal-ledc.h" | ||
#endif | ||
|
||
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) | ||
#include "esp32-hal-log.h" | ||
#define TAG "" | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe reason will be displayed to describe this comment to others. Learn more. Yes, ... maybe this example should be refactored for good. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) |
||
{ | ||
#ifdef CONFIG_LED_ILLUMINATOR_ENABLED | ||
// PWM | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Please use Arduino function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe reason will be displayed to describe this comment to others. Learn more. I see... it is used all over in app_httpd.cpp. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep it simple for now. Keep it using |
||
#endif | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that all this code should go to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
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:
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 commentThe reason will be displayed to describe this comment to others. Learn more. Actually ... CONFIG_LED_ILLUMINATOR_ENABLED is defined nowhere. 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. |
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.
It used for UI led intensity limit