Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc7a549

Browse files
authored
fix(example): led flash not working if not using default model in camera example. (#11466)
* fix(example): led flash not working if not using default model in camera examplefix(example): add camera_config.h and enable LED FLASH based on board modelfix(example): Remove face detection description as no longer supported* fix(example): add header guard for board_config.h
1 parent212b12b commitbc7a549

File tree

3 files changed

+53
-50
lines changed

3 files changed

+53
-50
lines changed

‎libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,10 @@
11
#include"esp_camera.h"
22
#include<WiFi.h>
33

4-
//
5-
// WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
6-
// Ensure ESP32 Wrover Module or other board with PSRAM is selected
7-
// Partial images will be transmitted if image exceeds buffer size
8-
//
9-
// You must select partition scheme from the board menu that has at least 3MB APP space.
10-
// Face Recognition is DISABLED for ESP32 and ESP32-S2, because it takes up from 15
11-
// seconds to process single frame. Face Detection is ENABLED if PSRAM is enabled as well
12-
13-
// ===================
14-
// Select camera model
15-
// ===================
16-
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
17-
#defineCAMERA_MODEL_ESP_EYE// Has PSRAM
18-
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
19-
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
20-
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
21-
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
22-
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
23-
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
24-
//#define CAMERA_MODEL_M5STACK_CAMS3_UNIT // Has PSRAM
25-
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
26-
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
27-
//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
28-
// ** Espressif Internal Boards **
29-
//#define CAMERA_MODEL_ESP32_CAM_BOARD
30-
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
31-
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
32-
//#define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3 // Has PSRAM
33-
//#define CAMERA_MODEL_DFRobot_Romeo_ESP32S3 // Has PSRAM
34-
#include"camera_pins.h"
4+
// ===========================
5+
// Select camera model in board_config.h
6+
// ===========================
7+
#include"board_config.h"
358

369
// ===========================
3710
// Enter your WiFi credentials
@@ -40,7 +13,7 @@ const char *ssid = "**********";
4013
constchar *password ="**********";
4114

4215
voidstartCameraServer();
43-
voidsetupLedFlash(int pin);
16+
voidsetupLedFlash();
4417

4518
voidsetup() {
4619
Serial.begin(115200);
@@ -130,7 +103,7 @@ void setup() {
130103

131104
// Setup LED FLash if LED pin is defined in camera_pins.h
132105
#if defined(LED_GPIO_NUM)
133-
setupLedFlash(LED_GPIO_NUM);
106+
setupLedFlash();
134107
#endif
135108

136109
WiFi.begin(ssid, password);

‎libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@
1919
#include"esp32-hal-ledc.h"
2020
#include"sdkconfig.h"
2121
#include"camera_index.h"
22+
#include"board_config.h"
2223

2324
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2425
#include"esp32-hal-log.h"
2526
#endif
2627

27-
// Enable LED FLASH setting
28-
#defineCONFIG_LED_ILLUMINATOR_ENABLED1
29-
3028
// LED FLASH setup
31-
#if CONFIG_LED_ILLUMINATOR_ENABLED
32-
33-
#defineLED_LEDC_GPIO22//configure LED pin
29+
#if defined(LED_GPIO_NUM)
3430
#defineCONFIG_LED_MAX_INTENSITY255
3531

3632
int led_duty =0;
@@ -91,13 +87,13 @@ static int ra_filter_run(ra_filter_t *filter, int value) {
9187
}
9288
#endif
9389

94-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
90+
#ifdefined(LED_GPIO_NUM)
9591
voidenable_led(bool en) {// Turn LED On or Off
9692
int duty = en ? led_duty :0;
9793
if (en && isStreaming && (led_duty > CONFIG_LED_MAX_INTENSITY)) {
9894
duty = CONFIG_LED_MAX_INTENSITY;
9995
}
100-
ledcWrite(LED_LEDC_GPIO, duty);
96+
ledcWrite(LED_GPIO_NUM, duty);
10197
//ledc_set_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL, duty);
10298
//ledc_update_duty(CONFIG_LED_LEDC_SPEED_MODE, CONFIG_LED_LEDC_CHANNEL);
10399
log_i("Set LED intensity to %d", duty);
@@ -162,7 +158,7 @@ static esp_err_t capture_handler(httpd_req_t *req) {
162158
int64_t fr_start =esp_timer_get_time();
163159
#endif
164160

165-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
161+
#ifdefined(LED_GPIO_NUM)
166162
enable_led(true);
167163
vTaskDelay(150 / portTICK_PERIOD_MS);// The LED needs to be turned on ~150ms before the call to esp_camera_fb_get()
168164
fb =esp_camera_fb_get();// or it won't be visible in the frame. A better way to do this is needed.
@@ -230,7 +226,7 @@ static esp_err_t stream_handler(httpd_req_t *req) {
230226
httpd_resp_set_hdr(req,"Access-Control-Allow-Origin","*");
231227
httpd_resp_set_hdr(req,"X-Framerate","60");
232228

233-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
229+
#ifdefined(LED_GPIO_NUM)
234230
isStreaming =true;
235231
enable_led(true);
236232
#endif
@@ -293,7 +289,7 @@ static esp_err_t stream_handler(httpd_req_t *req) {
293289
);
294290
}
295291

296-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
292+
#ifdefined(LED_GPIO_NUM)
297293
isStreaming =false;
298294
enable_led(false);
299295
#endif
@@ -393,7 +389,7 @@ static esp_err_t cmd_handler(httpd_req_t *req) {
393389
}elseif (!strcmp(variable,"ae_level")) {
394390
res = s->set_ae_level(s, val);
395391
}
396-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
392+
#ifdefined(LED_GPIO_NUM)
397393
elseif (!strcmp(variable,"led_intensity")) {
398394
led_duty = val;
399395
if (isStreaming) {
@@ -481,7 +477,7 @@ static esp_err_t status_handler(httpd_req_t *req) {
481477
p +=sprintf(p,"\"vflip\":%u,", s->status.vflip);
482478
p +=sprintf(p,"\"dcw\":%u,", s->status.dcw);
483479
p +=sprintf(p,"\"colorbar\":%u", s->status.colorbar);
484-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
480+
#ifdefined(LED_GPIO_NUM)
485481
p +=sprintf(p,",\"led_intensity\":%u", led_duty);
486482
#else
487483
p +=sprintf(p,",\"led_intensity\":%d", -1);
@@ -843,10 +839,10 @@ void startCameraServer() {
843839
}
844840
}
845841

846-
voidsetupLedFlash(int pin) {
847-
#ifCONFIG_LED_ILLUMINATOR_ENABLED
848-
ledcAttach(pin,5000,8);
842+
voidsetupLedFlash() {
843+
#ifdefined(LED_GPIO_NUM)
844+
ledcAttach(LED_GPIO_NUM,5000,8);
849845
#else
850-
log_i("LED flash is disabled ->CONFIG_LED_ILLUMINATOR_ENABLED = 0");
846+
log_i("LED flash is disabled ->LED_GPIO_NUM undefined");
851847
#endif
852848
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndefBOARD_CONFIG_H
2+
#defineBOARD_CONFIG_H
3+
4+
//
5+
// WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality
6+
// Ensure ESP32 Wrover Module or other board with PSRAM is selected
7+
// Partial images will be transmitted if image exceeds buffer size
8+
//
9+
// You must select partition scheme from the board menu that has at least 3MB APP space.
10+
11+
// ===================
12+
// Select camera model
13+
// ===================
14+
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
15+
#defineCAMERA_MODEL_ESP_EYE// Has PSRAM
16+
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
17+
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
18+
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
19+
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
20+
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
21+
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
22+
//#define CAMERA_MODEL_M5STACK_CAMS3_UNIT // Has PSRAM
23+
//#define CAMERA_MODEL_AI_THINKER // Has PSRAM
24+
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
25+
//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
26+
// ** Espressif Internal Boards **
27+
//#define CAMERA_MODEL_ESP32_CAM_BOARD
28+
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
29+
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
30+
//#define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3 // Has PSRAM
31+
//#define CAMERA_MODEL_DFRobot_Romeo_ESP32S3 // Has PSRAM
32+
#include"camera_pins.h"
33+
34+
#endif// BOARD_CONFIG_H

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp