Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dfff308

Browse files
authored
Merge pull request espressif#88 from jjsch-dev/master
adding a OV7670 driver.
2 parents 0347377 + 85f7c63 commit dfff308

File tree

10 files changed

+867
-13
lines changed

10 files changed

+867
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if(IDF_TARGET STREQUAL "esp32")
99
sensors/ov3660.c
1010
sensors/ov5640.c
1111
sensors/ov7725.c
12+
sensors/ov7670.c
1213
conversions/yuv.c
1314
conversions/to_jpg.cpp
1415
conversions/to_bmp.c

Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ config OV2640_SUPPORT
77
Enable this option if you want to use the OV2640.
88
Disable this option to save memory.
99

10+
config OV7670_SUPPORT
11+
bool "OV7670 Support"
12+
default y
13+
help
14+
Enable this option if you want to use the OV7670.
15+
Disable this option to safe memory.
16+
1017
config OV7725_SUPPORT
1118
bool "OV7725 Support"
1219
default n

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## General Information
44

5-
This repository hosts ESP32 compatible driver for OV2640, OV3660, OV5640 and OV7725 image sensors. Additionally it provides a few tools, which allow converting the captured frame data to the more common BMP and JPEG formats.
5+
This repository hosts ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors. Additionally it provides a few tools, which allow converting the captured frame data to the more common BMP and JPEG formats.
66

77
## Important to Remember
88

conversions/to_bmp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
#include "sdkconfig.h"
2121
#include "esp_jpg_decode.h"
2222

23+
#include "esp_system.h"
24+
#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+
25+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
26+
#include "esp32/spiram.h"
27+
#else
28+
#error Target CONFIG_IDF_TARGET is not supported
29+
#endif
30+
#else // ESP32 Before IDF 4.0
31+
#include "esp_spiram.h"
32+
#endif
33+
2334
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2435
#include "esp32-hal-log.h"
2536
#define TAG ""

driver/camera.c

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
#if CONFIG_OV5640_SUPPORT
4949
#include "ov5640.h"
5050
#endif
51+
#if CONFIG_OV7670_SUPPORT
52+
#include "ov7670.h"
53+
#endif
5154

5255
typedef enum {
5356
CAMERA_NONE = 0,
@@ -56,6 +59,7 @@ typedef enum {
5659
CAMERA_OV2640 = 2640,
5760
CAMERA_OV3660 = 3660,
5861
CAMERA_OV5640 = 5640,
62+
CAMERA_OV7670 = 7670,
5963
} camera_model_t;
6064

6165
#define REG_PID 0x0A
@@ -1060,6 +1064,12 @@ esp_err_t camera_probe(const camera_config_t* config, camera_model_t* out_camera
10601064
*out_camera_model = CAMERA_OV5640;
10611065
ov5640_init(&s_state->sensor);
10621066
break;
1067+
#endif
1068+
#if CONFIG_OV7670_SUPPORT
1069+
case OV7670_PID:
1070+
*out_camera_model = CAMERA_OV7670;
1071+
ov7670_init(&s_state->sensor);
1072+
break;
10631073
#endif
10641074
default:
10651075
id->PID = 0;
@@ -1116,6 +1126,13 @@ esp_err_t camera_init(const camera_config_t* config)
11161126
frame_size = FRAMESIZE_QSXGA;
11171127
}
11181128
break;
1129+
#endif
1130+
#if CONFIG_OV7670_SUPPORT
1131+
case OV7670_PID:
1132+
if (frame_size > FRAMESIZE_VGA) {
1133+
frame_size = FRAMESIZE_VGA;
1134+
}
1135+
break;
11191136
#endif
11201137
default:
11211138
return ESP_ERR_CAMERA_NOT_SUPPORTED;
@@ -1147,20 +1164,28 @@ esp_err_t camera_init(const camera_config_t* config)
11471164
}
11481165
s_state->fb_bytes_per_pixel = 1; // frame buffer stores Y8
11491166
} else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) {
1150-
s_state->fb_size = s_state->width * s_state->height * 2;
1151-
if (is_hs_mode() && s_state->sensor.id.PID != OV7725_PID) {
1152-
s_state->sampling_mode = SM_0A00_0B00;
1153-
s_state->dma_filter = &dma_filter_yuyv_highspeed;
1154-
} else {
1155-
s_state->sampling_mode = SM_0A0B_0C0D;
1156-
s_state->dma_filter = &dma_filter_yuyv;
1157-
}
1158-
s_state->in_bytes_per_pixel = 2; // camera sends YU/YV
1159-
s_state->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565
1167+
s_state->fb_size = s_state->width * s_state->height * 2;
1168+
if (is_hs_mode() && s_state->sensor.id.PID != OV7725_PID) {
1169+
if(s_state->sensor.id.PID == OV7670_PID) {
1170+
s_state->sampling_mode = SM_0A0B_0B0C;
1171+
}else{
1172+
s_state->sampling_mode = SM_0A00_0B00;
1173+
}
1174+
s_state->dma_filter = &dma_filter_yuyv_highspeed;
1175+
} else {
1176+
s_state->sampling_mode = SM_0A0B_0C0D;
1177+
s_state->dma_filter = &dma_filter_yuyv;
1178+
}
1179+
s_state->in_bytes_per_pixel = 2; // camera sends YU/YV
1180+
s_state->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565
11601181
} else if (pix_format == PIXFORMAT_RGB888) {
11611182
s_state->fb_size = s_state->width * s_state->height * 3;
11621183
if (is_hs_mode()) {
1163-
s_state->sampling_mode = SM_0A00_0B00;
1184+
if(s_state->sensor.id.PID == OV7670_PID) {
1185+
s_state->sampling_mode = SM_0A0B_0B0C;
1186+
}else{
1187+
s_state->sampling_mode = SM_0A00_0B00;
1188+
}
11641189
s_state->dma_filter = &dma_filter_rgb888_highspeed;
11651190
} else {
11661191
s_state->sampling_mode = SM_0A0B_0C0D;
@@ -1324,6 +1349,8 @@ esp_err_t esp_camera_init(const camera_config_t* config)
13241349
ESP_LOGI(TAG, "Detected OV3660 camera");
13251350
} else if (camera_model == CAMERA_OV5640) {
13261351
ESP_LOGI(TAG, "Detected OV5640 camera");
1352+
} else if (camera_model == CAMERA_OV7670) {
1353+
ESP_LOGI(TAG, "Detected OV7670 camera");
13271354
} else {
13281355
ESP_LOGI(TAG, "Camera not supported");
13291356
err = ESP_ERR_CAMERA_NOT_SUPPORTED;

driver/include/sensor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define OV2640_PID (0x26)
1717
#define OV3660_PID (0x36)
1818
#define OV5640_PID (0x56)
19+
#define OV7670_PID (0x76)
1920

2021
typedef enum {
2122
PIXFORMAT_RGB565, // 2BPP/RGB565

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "esp32-camera",
33
"version": "1.0.0",
44
"keywords": "esp32, camera, espressif, esp32-cam",
5-
"description": "ESP32 compatible driver for OV2640, OV3660, OV5640 and OV7725 image sensors.",
5+
"description": "ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors.",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/espressif/esp32-camera"

0 commit comments

Comments
 (0)