Skip to content

Commit

Permalink
Added support for the OV7675 and fixed bits/bytes per pixel return fo…
Browse files Browse the repository at this point in the history
…r grayscale
  • Loading branch information
ShawnHymel authored and facchinm committed Jul 31, 2023
1 parent 75024ea commit baf89d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/OV767X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ OV767X::~OV767X()
}
}

int OV767X::begin(int resolution, int format, int fps)
int OV767X::begin(int resolution, int format, int fps, int camera_name)
{
switch (resolution) {
case VGA:
Expand Down Expand Up @@ -154,8 +154,8 @@ int OV767X::begin(int resolution, int format, int fps)
return 0;
}

ov7670_configure(_ov7670, 0 /*OV7670 = 0, OV7675 = 1*/, format, resolution, 16 /* MHz */,
0 /*pll bypass*/, 1 /* pclk_hb_disable */);
ov7670_configure(_ov7670, camera_name /*OV7670 = 0, OV7675 = 1*/, format, resolution,
16 /* MHz */, 0 /*pll bypass*/, 1 /* pclk_hb_disable */);

if (ov7670_s_power(_ov7670, 1)) {
end();
Expand Down Expand Up @@ -198,12 +198,20 @@ int OV767X::height() const

int OV767X::bitsPerPixel() const
{
return _bytesPerPixel * 8;
if (_grayscale) {
return 8;
} else {
return _bytesPerPixel * 8;
}
}

int OV767X::bytesPerPixel() const
{
return _bytesPerPixel;
if (_grayscale) {
return 1;
} else {
return _bytesPerPixel;
}
}

//
Expand Down
9 changes: 8 additions & 1 deletion src/OV767X.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ enum
GRAYSCALE = 4
};

enum
{
OV7670 = 0,
OV7675 = 1
};

enum
{
VGA = 0, // 640x480
Expand All @@ -46,7 +52,8 @@ class OV767X
OV767X();
virtual ~OV767X();

int begin(int resolution, int format, int fps); // Supported FPS: 1, 5, 10, 15, 30
// Supported FPS: 1, 5, 10, 15, 30
int begin(int resolution, int format, int fps, int camera_name = OV7675);
void end();

// must be called after Camera.begin():
Expand Down

0 comments on commit baf89d5

Please sign in to comment.