Skip to content

Commit e85f1ba

Browse files
bump dist to 2.7.13
1 parent b656935 commit e85f1ba

File tree

3 files changed

+138
-36
lines changed

3 files changed

+138
-36
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/eloquentarduino/EloquentEsp32cam"
88
},
9-
"version": "2.7.12",
9+
"version": "2.7.13",
1010
"authors": {
1111
"name": "Simone Salerno",
1212
"url": "https://github.com/eloquentarduino"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EloquentEsp32cam
2-
version=2.7.12
2+
version=2.7.13
33
author=Simone Salerno <support@eloquentarduino.com>
44
maintainer=Simone Salerno <support@eloquentarduino.com>
55
sentence=Use your Esp32-cam like an expert

src/eloquent_esp32cam/camera/pinout.h

Lines changed: 136 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef ELOQUENT_ESP32CAM_CAMERA_PINOUT
22
#define ELOQUENT_ESP32CAM_CAMERA_PINOUT
33

4+
#include <Preferences.h>
5+
#include <esp_camera.h>
46

57
namespace Eloquent {
68
namespace Esp32cam {
@@ -40,7 +42,7 @@ namespace Eloquent {
4042
/**
4143
*
4244
*/
43-
void aithinker() {
45+
bool aithinker() {
4446
pins.d0 = 5;
4547
pins.d1 = 18;
4648
pins.d2 = 19;
@@ -58,12 +60,13 @@ namespace Eloquent {
5860
pins.pwdn = 32;
5961
pins.reset = -1;
6062
pins.flashlight = 4;
63+
return true;
6164
}
6265

6366
/**
6467
*
6568
*/
66-
void m5() {
69+
bool m5() {
6770
pins.d0 = 32;
6871
pins.d1 = 35;
6972
pins.d2 = 34;
@@ -81,12 +84,13 @@ namespace Eloquent {
8184
pins.pwdn = -1;
8285
pins.reset = 15;
8386
pins.flashlight = 16;
87+
return true;
8488
}
8589

8690
/**
8791
*
8892
*/
89-
void m5_wide() {
93+
bool m5_wide() {
9094
pins.d0 = 32;
9195
pins.d1 = 35;
9296
pins.d2 = 34;
@@ -104,12 +108,13 @@ namespace Eloquent {
104108
pins.pwdn = -1;
105109
pins.reset = 15;
106110
pins.flashlight = 14;
111+
return true;
107112
}
108113

109114
/**
110115
*
111116
*/
112-
void eye() {
117+
bool eye() {
113118
pins.d0 = 34;
114119
pins.d1 = 13;
115120
pins.d2 = 14;
@@ -127,12 +132,13 @@ namespace Eloquent {
127132
pins.pwdn = -1;
128133
pins.reset = -1;
129134
pins.flashlight = 22;
135+
return true;
130136
}
131137

132138
/**
133139
*
134140
*/
135-
void wrover() {
141+
bool wrover() {
136142
pins.d0 = 4;
137143
pins.d1 = 5;
138144
pins.d2 = 18;
@@ -150,12 +156,13 @@ namespace Eloquent {
150156
pins.pwdn = -1;
151157
pins.reset = -1;
152158
pins.flashlight = -1;
159+
return true;
153160
}
154161

155162
/**
156163
*
157164
*/
158-
void wroom_s3() {
165+
bool wroom_s3() {
159166
pins.d0 = 11;
160167
pins.d1 = 9;
161168
pins.d2 = 8;
@@ -172,20 +179,21 @@ namespace Eloquent {
172179
pins.sccb_scl = 5;
173180
pins.pwdn = -1;
174181
pins.reset = -1;
175-
pins.flashlight = -1;
182+
pins.flashlight = -1;
183+
return true;
176184
}
177185

178186
/**
179187
*
180188
*/
181-
void freenove_s3() {
182-
wroom_s3();
189+
bool freenove_s3() {
190+
return wroom_s3();
183191
}
184192

185193
/**
186194
*
187195
*/
188-
void ttgo_lcd() {
196+
bool ttgo_lcd() {
189197
pins.d0 = 34;
190198
pins.d1 = 13;
191199
pins.d2 = 26;
@@ -203,12 +211,13 @@ namespace Eloquent {
203211
pins.pwdn = -1;
204212
pins.reset = -1;
205213
pins.flashlight = -1;
214+
return true;
206215
}
207216

208217
/**
209218
*
210219
*/
211-
void ttgo_pir() {
220+
bool ttgo_pir() {
212221
pins.d0 = 5;
213222
pins.d1 = 14;
214223
pins.d2 = 4;
@@ -226,12 +235,13 @@ namespace Eloquent {
226235
pins.pwdn = 26;
227236
pins.reset = -1;
228237
pins.flashlight = -1;
238+
return true;
229239
}
230240

231241
/**
232242
*
233243
*/
234-
void simcam() {
244+
bool simcam() {
235245
pins.d0 = 11;
236246
pins.d1 = 9;
237247
pins.d2 = 8;
@@ -249,12 +259,13 @@ namespace Eloquent {
249259
pins.pwdn = -1;
250260
pins.reset = 18;
251261
pins.flashlight = -1;
262+
return true;
252263
}
253264

254265
/**
255266
*
256267
*/
257-
void xiao() {
268+
bool xiao() {
258269
pins.d0 = 15;
259270
pins.d1 = 17;
260271
pins.d2 = 18;
@@ -272,12 +283,13 @@ namespace Eloquent {
272283
pins.pwdn = -1;
273284
pins.reset = -1;
274285
pins.flashlight = -1;
286+
return true;
275287
}
276288

277289
/**
278290
*
279291
*/
280-
void m5_timer() {
292+
bool m5_timer() {
281293
pins.d0 = 32;
282294
pins.d1 = 35;
283295
pins.d2 = 34;
@@ -295,12 +307,13 @@ namespace Eloquent {
295307
pins.pwdn = -1;
296308
pins.reset = 15;
297309
pins.flashlight = 2;
310+
return true;
298311
}
299312

300313
/**
301314
*
302315
*/
303-
void lilygo_tcamera_s3() {
316+
bool lilygo_tcamera_s3() {
304317
pins.d0 = 14;
305318
pins.d1 = 47;
306319
pins.d2 = 48;
@@ -318,29 +331,14 @@ namespace Eloquent {
318331
pins.pwdn = -1;
319332
pins.reset = 39;
320333
pins.flashlight = -1;
334+
return true;
321335
}
322336

323-
void eye_s3() {
324-
pins.d0 = 11;
325-
pins.d1 = 9;
326-
pins.d2 = 8;
327-
pins.d3 = 10;
328-
pins.d4 = 12;
329-
pins.d5 = 18;
330-
pins.d6 = 17;
331-
pins.d7 = 16;
332-
pins.xclk = 15;
333-
pins.pclk = 13;
334-
pins.vsync = 6;
335-
pins.href = 7;
336-
pins.sccb_sda = 4;
337-
pins.sccb_scl = 5;
338-
pins.pwdn = -1;
339-
pins.reset = -1;
340-
pins.flashlight = -1;
337+
bool eye_s3() {
338+
return wroom_s3();
341339
}
342340

343-
void kaluga() {
341+
bool kaluga() {
344342
pins.d0 = 36;
345343
pins.d1 = 37;
346344
pins.d2 = 41;
@@ -358,6 +356,110 @@ namespace Eloquent {
358356
pins.pwdn = -1;
359357
pins.reset = -1;
360358
pins.flashlight = -1;
359+
return true;
360+
}
361+
362+
/**
363+
* Automatically detect model
364+
*/
365+
bool autodetect() {
366+
preferences.begin("pinout:1", false);
367+
368+
bool detected = false
369+
|| aithinker() && test("aithinker")
370+
|| wroom_s3() && test("wroom_s3")
371+
|| xiao() && test("xiao")
372+
|| m5() && test("M5")
373+
|| m5_wide() && test("M5 wide")
374+
|| m5_timer() && test("M5 timer")
375+
|| eye() && test("ESP-EYE")
376+
|| eye_s3() && test("ESP-EYE S3")
377+
|| wrover() && test("Wrover")
378+
|| ttgo_lcd() && test("TTGO LCD")
379+
|| ttgo_pir() && test("TTGO PIR")
380+
|| lilygo_tcamera_s3() && test("T-CAMERA S3")
381+
|| simcam() && test("SIMCAM")
382+
;
383+
384+
preferences.end();
385+
386+
return detected;
387+
}
388+
389+
protected:
390+
Preferences preferences;
391+
392+
/**
393+
* Test current configuration
394+
* @return
395+
*/
396+
bool test(const char *model) {
397+
ESP_LOGI("Pinout", "Testing pinout for model %s", model);
398+
int8_t existing = preferences.getChar(model, 0);
399+
400+
// since a wrong config may cause a restart,
401+
// mark a failure by default
402+
preferences.putChar(model, -1);
403+
404+
// 1 is for correct config
405+
if (existing == 1)
406+
return true;
407+
408+
// -1 is for wrong config
409+
if (existing == -1)
410+
return false;
411+
412+
// new config, try it
413+
camera_config_t config;
414+
415+
config.pin_d0 = pins.d0;
416+
config.pin_d1 = pins.d1;
417+
config.pin_d2 = pins.d2;
418+
config.pin_d3 = pins.d3;
419+
config.pin_d4 = pins.d4;
420+
config.pin_d5 = pins.d5;
421+
config.pin_d6 = pins.d6;
422+
config.pin_d7 = pins.d7;
423+
config.pin_xclk = pins.xclk;
424+
config.pin_pclk = pins.pclk;
425+
config.pin_vsync = pins.vsync;
426+
config.pin_href = pins.href;
427+
config.pin_sccb_sda = pins.sccb_sda;
428+
config.pin_sccb_scl = pins.sccb_scl;
429+
config.pin_pwdn = -1;
430+
config.pin_reset = -1;
431+
432+
config.ledc_channel = LEDC_CHANNEL_0;
433+
config.ledc_timer = LEDC_TIMER_0;
434+
config.fb_count = 1;
435+
config.frame_size = FRAMESIZE_QQVGA;
436+
config.pixel_format = PIXFORMAT_JPEG;
437+
config.jpeg_quality = 10;
438+
config.xclk_freq_hz = 10000000ULL;
439+
config.grab_mode = CAMERA_GRAB_LATEST;
440+
441+
camera_fb_t *frame;
442+
443+
if (esp_camera_init(&config) == ESP_OK) {
444+
ESP_LOGI("Pinout", "Init ok! Trying to capture frame...");
445+
frame = esp_camera_fb_get();
446+
447+
if (frame != NULL && frame->len > 0) {
448+
ESP_LOGI("Pinout", "Match found!");
449+
preferences.putChar(model, 1);
450+
esp_camera_fb_return(frame);
451+
esp_camera_deinit();
452+
return true;
453+
}
454+
else
455+
ESP_LOGI("Pinout", "Cannot capture frame, moving to next model...");
456+
}
457+
458+
if (frame != NULL)
459+
esp_camera_fb_return(frame);
460+
461+
esp_camera_deinit();
462+
return false;
361463
}
362464
};
363465
}

0 commit comments

Comments
 (0)