EasyManua.ls Logo

Freenove ESP32-S3

Default Icon
142 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Any concerns? support@freenove.com
117
Chapter 7 Camera Web Server
www.freenove.com
The following is the main program code. You need include other code files in the same folder when write
your own code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "esp_camera.h"
#define CAMERA_MODEL_ESP32S3_EYE
#include "camera_pins.h"
#include "ws2812.h"
#include "sd_read_write.h"
#define BUTTON_PIN 0
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(false);
Serial.println();
pinMode(BUTTON_PIN, INPUT_PULLUP);
ws2812Init();
sdmmcInit();
//removeDir(SD_MMC, "/camera");
createDir(SD_MMC, "/camera");
listDir(SD_MMC, "/camera", 0);
if(cameraSetup()==1){
ws2812SetColor(2);
}
else{
ws2812SetColor(1);
return;
}
}
void loop() {
if(digitalRead(BUTTON_PIN)==LOW){
delay(20);
if(digitalRead(BUTTON_PIN)==LOW){
ws2812SetColor(3);
while(digitalRead(BUTTON_PIN)==LOW);
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if (fb != NULL) {
int photo_index = readFileNum(SD_MMC, "/camera");
if(photo_index!=-1)
{
String path = "/camera/" + String(photo_index) +".jpg";
writejpg(SD_MMC, path.c_str(), fb->buf, fb->len);
}