update indentation

main
thyik 5 years ago
parent 1950f43ea4
commit 88adafbbc2

@ -3,82 +3,88 @@
## CameraWebServer_ESP32-CAM.ino ## CameraWebServer_ESP32-CAM.ino
* Configure WiFi SSID * Configure WiFi SSID
```
const char* ssid = "Your SSID"; ```
const char* password = "Your Password"; const char* ssid = "Your SSID";
``` const char* password = "Your Password";
```
* Setup Camera CSI pin assignment * Setup Camera CSI pin assignment
```
camera_config_t config; ```
config.ledc_channel = LEDC_CHANNEL_0; camera_config_t config;
config.ledc_timer = LEDC_TIMER_0; config.ledc_channel = LEDC_CHANNEL_0;
config.pin_d0 = Y2_GPIO_NUM; config.ledc_timer = LEDC_TIMER_0;
config.pin_d1 = Y3_GPIO_NUM; config.pin_d0 = Y2_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM;
config.xclk_freq_hz = 20000000; config.pin_reset = RESET_GPIO_NUM;
config.pixel_format = PIXFORMAT_JPEG; config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
``` ```
* Connect WiFi network * Connect WiFi network
```
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { ```
delay(500); WiFi.begin(ssid, password);
Serial.print(".");
} while (WiFi.status() != WL_CONNECTED) {
``` delay(500);
Serial.print(".");
}
```
* Start httpd Web Camera Server * Start httpd Web Camera Server
```
startCameraServer();
``` ```
startCameraServer();
```
## app_httpd.cpp ## app_httpd.cpp
* Setup Web Server endpoint * Setup Web Server endpoint
```
if (httpd_start(&camera_httpd, &config) == ESP_OK) { ```
httpd_register_uri_handler(camera_httpd, &index_uri); if (httpd_start(&camera_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(camera_httpd, &cmd_uri); httpd_register_uri_handler(camera_httpd, &index_uri);
httpd_register_uri_handler(camera_httpd, &status_uri); httpd_register_uri_handler(camera_httpd, &cmd_uri);
httpd_register_uri_handler(camera_httpd, &capture_uri); httpd_register_uri_handler(camera_httpd, &status_uri);
} httpd_register_uri_handler(camera_httpd, &capture_uri);
``` }
```
* index landing page callback to read camera source and publish camera image * index landing page callback to read camera source and publish camera image
```
static esp_err_t index_handler(httpd_req_t *req){ ```
httpd_resp_set_type(req, "text/html"); static esp_err_t index_handler(httpd_req_t *req){
httpd_resp_set_hdr(req, "Content-Encoding", "gzip"); httpd_resp_set_type(req, "text/html");
sensor_t * s = esp_camera_sensor_get(); httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
if (s->id.PID == OV3660_PID) { sensor_t * s = esp_camera_sensor_get();
return httpd_resp_send(req, (const char *)index_ov3660_html_gz, index_ov3660_html_gz_len); if (s->id.PID == OV3660_PID) {
return httpd_resp_send(req, (const char *)index_ov3660_html_gz, index_ov3660_html_gz_len);
}
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len);
} }
return httpd_resp_send(req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len); ```
}
```
* streaming of camera source * streaming of camera source
```
static esp_err_t stream_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
size_t _jpg_buf_len = 0;
``` ```
static esp_err_t stream_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
size_t _jpg_buf_len = 0;
```
Loading…
Cancel
Save