15
15
// Pin settings
16
16
#define CAM_PIN_PWDN -1
17
17
#define CAM_PIN_RESET -1
18
- #define CAM_PIN_XCLK - 1
19
- #define CAM_PIN_SIOD - 1
20
- #define CAM_PIN_SIOC - 1
18
+ #define CAM_PIN_XCLK 2
19
+ #define CAM_PIN_SIOD 12
20
+ #define CAM_PIN_SIOC 11
21
21
#define CAM_PIN_D7 47
22
22
#define CAM_PIN_D6 48
23
23
#define CAM_PIN_D5 16
24
24
#define CAM_PIN_D4 15
25
25
#define CAM_PIN_D3 42
26
- #define CAM_PIN_D4 15
27
26
#define CAM_PIN_D2 41
28
27
#define CAM_PIN_D1 40
29
28
#define CAM_PIN_D0 39
30
29
#define CAM_PIN_VSYNC 46
31
30
#define CAM_PIN_HREF 38
32
31
#define CAM_PIN_PCLK 45
33
32
34
- extern void startCameraServer (); // server.cpp
33
+ extern void startCameraServer (); // app_httpd.cpp
34
+
35
+ // #define USING_EXISTING_I2C
36
+
37
+ #if defined(USING_EXISTING_I2C)
38
+ static camera_config_t camera_config =
39
+ {
40
+ .pin_pwdn = CAM_PIN_PWDN;
41
+ .pin_reset = CAM_PIN_RESET;
42
+ .pin_xclk = CAM_PIN_XCLK;
43
+ // .pin_xclk = -1;
44
+ // .pin_sccb_sda = CAM_PIN_SIOD;
45
+ .pin_sccb_sda = -1 ;
46
+ // .pin_sccb_scl = CAM_PIN_SIOC;
47
+ .pin_sccb_scl = -1 ;
48
+
49
+ .pin_d7 = CAM_PIN_D7;
50
+ .pin_d6 = CAM_PIN_D6;
51
+ .pin_d5 = CAM_PIN_D5;
52
+ .pin_d4 = CAM_PIN_D4;
53
+ .pin_d3 = CAM_PIN_D3;
54
+ .pin_d2 = CAM_PIN_D2;
55
+ .pin_d1 = CAM_PIN_D1;
56
+ .pin_d0 = CAM_PIN_D0;
57
+ .pin_vsync = CAM_PIN_VSYNC;
58
+ .pin_href = CAM_PIN_HREF;
59
+ .pin_pclk = CAM_PIN_PCLK;
60
+
61
+ .xclk_freq_hz = 20000000 ;
62
+ .ledc_timer = LEDC_TIMER_0;
63
+ .ledc_channel = LEDC_CHANNEL_0;
64
+ .fb_location = CAMERA_FB_IN_PSRAM,
65
+ .pixel_format = PIXFORMAT_RGB565;
66
+ // .pixel_format = PIXFORMAT_YUV422;
67
+ // .frame_size = FRAMESIZE_VGA; // 640x480
68
+ // .frame_size = FRAMESIZE_QVGA; // 320x240
69
+ // .frame_size = FRAMESIZE_240X240, // 240x240
70
+ // .frame_size = FRAMESIZE_QQVGA; // 160x120
71
+ .jpeg_quality = 0 ,
72
+ // .fb_count = 1;
73
+ .fb_count = 2 ; // CPU Loads too much but faster
74
+ .grab_mode = CAMERA_GRAB_WHEN_EMPTY;
75
+ .sccb_i2c_port = M5.In_I2C .getPort ()
76
+ };
77
+ #else
78
+ static camera_config_t camera_config =
79
+ {
80
+ .pin_pwdn = -1 ,
81
+ .pin_reset = -1 ,
82
+ .pin_xclk = 2 ,
83
+ .pin_sscb_sda = 12 ,
84
+ .pin_sscb_scl = 11 ,
85
+ .pin_d7 = 47 ,
86
+ .pin_d6 = 48 ,
87
+ .pin_d5 = 16 ,
88
+ .pin_d4 = 15 ,
89
+ .pin_d3 = 42 ,
90
+ .pin_d2 = 41 ,
91
+ .pin_d1 = 40 ,
92
+ .pin_d0 = 39 ,
93
+ .pin_vsync = 46 ,
94
+ .pin_href = 38 ,
95
+ .pin_pclk = 45 ,
96
+ .xclk_freq_hz = 20000000 ,
97
+ .ledc_timer = LEDC_TIMER_0,
98
+ .ledc_channel = LEDC_CHANNEL_0,
99
+ .pixel_format = PIXFORMAT_RGB565,
100
+ // .frame_size = FRAMESIZE_QQVGA,
101
+ .frame_size = FRAMESIZE_QVGA,
102
+ .jpeg_quality = 0 ,
103
+ .fb_count = 2 ,
104
+ .fb_location = CAMERA_FB_IN_PSRAM,
105
+ .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
106
+ .sccb_i2c_port = -1 ,
107
+ };
108
+ #endif
35
109
36
110
void setup ()
37
111
{
38
112
// M5
39
113
M5.begin ();
40
114
M5.Log .setEnableColor (m5::log_target_serial, false );
41
115
42
- // Camera
43
- camera_config_t ccfg{};
44
- ccfg.pin_pwdn = CAM_PIN_PWDN;
45
- ccfg.pin_reset = CAM_PIN_RESET;
46
- ccfg.pin_xclk = CAM_PIN_XCLK;
47
- ccfg.pin_sccb_sda = CAM_PIN_SIOD;
48
- ccfg.pin_sccb_scl = CAM_PIN_SIOC;
49
- ccfg.pin_d7 = CAM_PIN_D7;
50
- ccfg.pin_d6 = CAM_PIN_D6;
51
- ccfg.pin_d5 = CAM_PIN_D5;
52
- ccfg.pin_d4 = CAM_PIN_D4;
53
- ccfg.pin_d3 = CAM_PIN_D3;
54
- ccfg.pin_d2 = CAM_PIN_D2;
55
- ccfg.pin_d1 = CAM_PIN_D1;
56
- ccfg.pin_d0 = CAM_PIN_D0;
57
- ccfg.pin_vsync = CAM_PIN_VSYNC;
58
- ccfg.pin_href = CAM_PIN_HREF;
59
- ccfg.pin_pclk = CAM_PIN_PCLK;
60
- ccfg.xclk_freq_hz = 20000000 ;
61
- ccfg.ledc_timer = LEDC_TIMER_0;
62
- ccfg.ledc_channel = LEDC_CHANNEL_0;
63
-
64
- ccfg.pixel_format = PIXFORMAT_RGB565;
65
- // ccfg.pixel_format = PIXFORMAT_YUV422;
66
-
67
- // //ccfg.frame_size = FRAMESIZE_VGA; // 640x480
68
- ccfg.frame_size = FRAMESIZE_QVGA; // 320x240
69
- // ccfg.frame_size = FRAMESIZE_240X240, // 240x240
70
- // ccfg.frame_size = FRAMESIZE_QQVGA; // 160x120
71
-
72
- ccfg.fb_count = 1 ;
73
- // ccfg.fb_count = 2; // CPU Loads too much but faster
74
-
75
- ccfg.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
76
- ccfg.sccb_i2c_port = M5.In_I2C .getPort (); // Using initialized I2C
77
-
116
+ M5.Display .clear (TFT_ORANGE);
117
+ #if defined(USING_EXISTING_I2C)
118
+ camera_config.sccb_i2c_port = M5.In_I2C .getPort ();
78
119
esp_err_t err = esp_camera_init (&ccfg);
120
+ #else
121
+ M5.In_I2C .release ();
122
+ esp_err_t err = esp_camera_init (&camera_config);
123
+ #endif
79
124
if (err != ESP_OK)
80
125
{
81
- M5.Display .clear (TFT_RED);
82
- M5.Display .setCursor (0 ,0 );
126
+ M5.Display .clear (TFT_BLUE);
83
127
M5_LOGE (" Failed to init camera:%d" , err);
84
- delay (1000 );
128
+ delay (1000 * 10 );
85
129
abort ();
86
130
}
87
131
if (!goblib::camera::GC0308::complementDriver ())
88
132
{
89
133
M5_LOGE (" Failed to complement GC0308" );
90
134
}
91
135
92
- M5.Display .clear (TFT_DARKGREEN);
93
136
// WiFi
94
137
WiFi.begin (); // // Connects to credential stored in the hardware.
95
138
// WiFi.begin("Your SSID", "Your password"); // or use it.
@@ -113,10 +156,9 @@ void setup()
113
156
114
157
// Server
115
158
startCameraServer ();
116
- M5.Display .clear (0 );
117
159
M5_LOGI (" Camera ready use: http;//%s to connect" , WiFi.localIP ().toString ().c_str ());
118
-
119
- M5.Log . setLogLevel (m5::log_target_display, ESP_LOG_NONE); // Disable output to display
160
+
161
+ M5.Display . clear (TFT_DARKGREEN);
120
162
}
121
163
122
164
void loop ()
0 commit comments