Skip to content

Commit 030a6b9

Browse files
authored
feature: Add dfrobot-k10 vision recognition (#688)
1 parent 12cf213 commit 030a6b9

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

main/boards/df-k10/config.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,36 @@
4141
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_NC
4242
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
4343

44+
/* DFRobot K10 Camera pins */
45+
#define PWDN_GPIO_NUM -1
46+
#define RESET_GPIO_NUM -1
47+
#define XCLK_GPIO_NUM 7
48+
49+
#define VSYNC_GPIO_NUM 4
50+
#define HREF_GPIO_NUM 5
51+
#define PCLK_GPIO_NUM 17
52+
#define SIOD_GPIO_NUM 20
53+
#define SIOC_GPIO_NUM 19
54+
55+
/* Camera pins */
56+
#define CAMERA_PIN_PWDN PWDN_GPIO_NUM
57+
#define CAMERA_PIN_RESET RESET_GPIO_NUM
58+
#define CAMERA_PIN_XCLK XCLK_GPIO_NUM
59+
#define CAMERA_PIN_SIOD SIOD_GPIO_NUM
60+
#define CAMERA_PIN_SIOC SIOC_GPIO_NUM
61+
62+
#define CAMERA_PIN_D9 6
63+
#define CAMERA_PIN_D8 15
64+
#define CAMERA_PIN_D7 16
65+
#define CAMERA_PIN_D6 18
66+
#define CAMERA_PIN_D5 9
67+
#define CAMERA_PIN_D4 11
68+
#define CAMERA_PIN_D3 10
69+
#define CAMERA_PIN_D2 8
70+
#define CAMERA_PIN_VSYNC VSYNC_GPIO_NUM
71+
#define CAMERA_PIN_HREF HREF_GPIO_NUM
72+
#define CAMERA_PIN_PCLK PCLK_GPIO_NUM
73+
74+
#define XCLK_FREQ_HZ 20000000
4475

4576
#endif // _BOARD_CONFIG_H_

main/boards/df-k10/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
{
55
"name": "df-k10",
66
"sdkconfig_append": [
7-
"CONFIG_SPIRAM_MODE_OCT=y"
7+
"CONFIG_SPIRAM_MODE_OCT=y",
8+
"CONFIG_IOT_PROTOCOL_MCP=y"
89
]
910
}
1011
]

main/boards/df-k10/df_k10_board.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "button.h"
88
#include "config.h"
99
#include "iot/thing_manager.h"
10+
#include "esp32_camera.h"
11+
1012
#include "led/circular_strip.h"
1113
#include "assets/lang_config.h"
1214

@@ -30,6 +32,8 @@ class Df_K10Board : public WifiBoard {
3032
LcdDisplay *display_;
3133
button_handle_t btn_a;
3234
button_handle_t btn_b;
35+
Esp32Camera* camera_;
36+
3337
button_driver_t* btn_a_driver_ = nullptr;
3438
button_driver_t* btn_b_driver_ = nullptr;
3539

@@ -163,6 +167,40 @@ class Df_K10Board : public WifiBoard {
163167
}, this);
164168
}
165169

170+
void InitializeCamera() {
171+
172+
camera_config_t config = {};
173+
config.ledc_channel = LEDC_CHANNEL_2; // LEDC通道选择 用于生成XCLK时钟 但是S3不用
174+
config.ledc_timer = LEDC_TIMER_2; // LEDC timer选择 用于生成XCLK时钟 但是S3不用
175+
config.pin_d0 = CAMERA_PIN_D2;
176+
config.pin_d1 = CAMERA_PIN_D3;
177+
config.pin_d2 = CAMERA_PIN_D4;
178+
config.pin_d3 = CAMERA_PIN_D5;
179+
config.pin_d4 = CAMERA_PIN_D6;
180+
config.pin_d5 = CAMERA_PIN_D7;
181+
config.pin_d6 = CAMERA_PIN_D8;
182+
config.pin_d7 = CAMERA_PIN_D9;
183+
config.pin_xclk = CAMERA_PIN_XCLK;
184+
config.pin_pclk = CAMERA_PIN_PCLK;
185+
config.pin_vsync = CAMERA_PIN_VSYNC;
186+
config.pin_href = CAMERA_PIN_HREF;
187+
config.pin_sccb_sda = -1; // 这里如果写-1 表示使用已经初始化的I2C接口
188+
config.pin_sccb_scl = CAMERA_PIN_SIOC;
189+
config.sccb_i2c_port = 1; // 这里如果写1 默认使用I2C1
190+
config.pin_pwdn = CAMERA_PIN_PWDN;
191+
config.pin_reset = CAMERA_PIN_RESET;
192+
config.xclk_freq_hz = XCLK_FREQ_HZ;
193+
config.pixel_format = PIXFORMAT_RGB565;
194+
config.frame_size = FRAMESIZE_VGA;
195+
config.jpeg_quality = 12;
196+
config.fb_count = 1;
197+
config.fb_location = CAMERA_FB_IN_PSRAM;
198+
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
199+
200+
camera_ = new Esp32Camera(config);
201+
camera_->SetVFlip(1);
202+
}
203+
166204
void InitializeIli9341Display() {
167205
esp_lcd_panel_io_handle_t panel_io = nullptr;
168206
esp_lcd_panel_handle_t panel = nullptr;
@@ -217,6 +255,12 @@ class Df_K10Board : public WifiBoard {
217255
InitializeIli9341Display();
218256
InitializeButtons();
219257
InitializeIot();
258+
InitializeCamera();
259+
260+
#if CONFIG_IOT_PROTOCOL_XIAOZHI
261+
auto& thing_manager = iot::ThingManager::GetInstance();
262+
thing_manager.AddThing(iot::CreateThing("Speaker"));
263+
#endif
220264
}
221265

222266
virtual Led* GetLed() override {
@@ -241,6 +285,10 @@ class Df_K10Board : public WifiBoard {
241285
return &audio_codec;
242286
}
243287

288+
virtual Camera* GetCamera() override {
289+
return camera_;
290+
}
291+
244292
virtual Display *GetDisplay() override {
245293
return display_;
246294
}

0 commit comments

Comments
 (0)