Skip to content

Commit 8345456

Browse files
committed
fixed camera init i2c bus conflict issues
1 parent ceefd2d commit 8345456

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

examples/Basic/camera/camera.ino

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
// #define CONVERT_TO_JPEG
2727

28-
void setup() {
28+
void setup()
29+
{
2930
auto cfg = M5.config();
3031
CoreS3.begin(cfg);
3132
CoreS3.Display.setTextColor(GREEN);
@@ -34,28 +35,22 @@ void setup() {
3435
CoreS3.Display.setTextSize(1);
3536

3637
if (!CoreS3.Camera.begin()) {
37-
CoreS3.Display.drawString("Camera Init Fail",
38-
CoreS3.Display.width() / 2,
39-
CoreS3.Display.height() / 2);
38+
CoreS3.Display.drawString("Camera Init Fail", CoreS3.Display.width() / 2, CoreS3.Display.height() / 2);
4039
}
41-
CoreS3.Display.drawString("Camera Init Success", CoreS3.Display.width() / 2,
42-
CoreS3.Display.height() / 2);
43-
44-
CoreS3.Camera.sensor->set_framesize(CoreS3.Camera.sensor, FRAMESIZE_QVGA);
40+
CoreS3.Display.drawString("Camera Init Success", CoreS3.Display.width() / 2, CoreS3.Display.height() / 2);
4541
}
4642

47-
void loop() {
43+
void loop()
44+
{
4845
if (CoreS3.Camera.get()) {
4946
#ifdef CONVERT_TO_JPEG
5047
uint8_t *out_jpg = NULL;
5148
size_t out_jpg_len = 0;
5249
frame2jpg(CoreS3.Camera.fb, 255, &out_jpg, &out_jpg_len);
53-
CoreS3.Display.drawJpg(out_jpg, out_jpg_len, 0, 0,
54-
CoreS3.Display.width(), CoreS3.Display.height());
50+
CoreS3.Display.drawJpg(out_jpg, out_jpg_len, 0, 0, CoreS3.Display.width(), CoreS3.Display.height());
5551
free(out_jpg);
5652
#else
57-
CoreS3.Display.pushImage(0, 0, CoreS3.Display.width(),
58-
CoreS3.Display.height(),
53+
CoreS3.Display.pushImage(0, 0, CoreS3.Display.width(), CoreS3.Display.height(),
5954
(uint16_t *)CoreS3.Camera.fb->buf);
6055
#endif
6156

src/utility/GC0308.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ static camera_config_t camera_config = {
2929
.fb_count = 2,
3030
.fb_location = CAMERA_FB_IN_PSRAM,
3131
.grab_mode = CAMERA_GRAB_WHEN_EMPTY,
32-
.sccb_i2c_port = M5.In_I2C.getPort(),
32+
.sccb_i2c_port = -1,
3333
};
3434

35-
bool GC0308::begin() {
35+
bool GC0308::begin()
36+
{
3637
M5.In_I2C.release();
3738
esp_err_t err = esp_camera_init(&camera_config);
3839
if (err != ESP_OK) {
@@ -42,15 +43,17 @@ bool GC0308::begin() {
4243
return true;
4344
}
4445

45-
bool GC0308::get() {
46+
bool GC0308::get()
47+
{
4648
fb = esp_camera_fb_get();
4749
if (!fb) {
4850
return false;
4951
}
5052
return true;
5153
}
5254

53-
bool GC0308::free() {
55+
bool GC0308::free()
56+
{
5457
if (fb) {
5558
esp_camera_fb_return(fb);
5659
return true;

0 commit comments

Comments
 (0)