Skip to content

Commit 24031d0

Browse files
facchinmpennam
authored andcommitted
OV767x: handle variants via different constructors
1 parent 35a9e18 commit 24031d0

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

libraries/OV7670/ov7670.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* GC2145 driver.
1818
*/
1919
#include "Wire.h"
20-
#include "ov7670.h"
20+
#include "ov767x.h"
2121

2222
#define GAIN 0x00 /* AGC - Gain control gain setting */
2323
#define BLUE 0x01 /* AWB - Blue channel gain setting */
@@ -537,8 +537,7 @@ static const uint8_t default_regs[][2] = {
537537
{ 0xFF, 0xFF },
538538
};
539539

540-
#if (OMV_OV7670_VERSION == 75)
541-
static const uint8_t rgb565_regs[][2] = {
540+
const uint8_t OV7675::rgb565_regs[][2] = {
542541
{ COM7, COM7_RGB_FMT }, /* Selects RGB mode */
543542
{ RGB444, 0x00 }, /* No RGB444 please */
544543
{ COM1, 0x00 }, /* CCIR601 */
@@ -553,8 +552,8 @@ static const uint8_t rgb565_regs[][2] = {
553552
{ COM13, COM13_GAMMA_EN | COM13_UVSAT_AUTO },
554553
{ 0xFF, 0xFF }
555554
};
556-
#elif (OMV_OV7670_VERSION == 70)
557-
static const uint8_t rgb565_regs[][2] = {
555+
556+
const uint8_t OV7670::rgb565_regs[][2] = {
558557
{ COM7, COM7_RGB_FMT }, /* Selects RGB mode */
559558
{ RGB444, 0 }, /* No RGB444 please */
560559
{ COM1, 0x0 }, /* CCIR601 */
@@ -570,9 +569,6 @@ static const uint8_t rgb565_regs[][2] = {
570569
{ COM13, COM13_UVSAT_AUTO },
571570
{ 0xFF, 0xFF }
572571
};
573-
#else
574-
#error "OV767x sensor is Not defined."
575-
#endif
576572

577573
// TODO: These registers probably need to be fixed too.
578574
static const uint8_t yuv422_regs[][2] = {
@@ -605,8 +601,7 @@ static const uint8_t vga_regs[][2] = {
605601
{ 0xFF, 0xFF },
606602
};
607603

608-
#if (OMV_OV7670_VERSION == 75)
609-
static const uint8_t qvga_regs[][2] = {
604+
const uint8_t OV7675::qvga_regs[][2] = {
610605
{ COM3, COM3_DCW_EN },
611606
{ COM14, 0x11 }, // Divide by 2
612607
{ 0x72, 0x22 }, // This has no effect on OV7675
@@ -619,8 +614,8 @@ static const uint8_t qvga_regs[][2] = {
619614
{ VREF, 0xF0 },
620615
{ 0xFF, 0xFF },
621616
};
622-
#else
623-
static const uint8_t qvga_regs[][2] = {
617+
618+
const uint8_t OV7670::qvga_regs[][2] = {
624619
{ COM3, COM3_DCW_EN },
625620
{ COM14, 0x19 },
626621
{ 0x72, 0x11 }, // downsample by 2
@@ -633,10 +628,8 @@ static const uint8_t qvga_regs[][2] = {
633628
{ VREF, 0x0a },
634629
{ 0XFF, 0XFF },
635630
};
636-
#endif
637631

638-
#if (OMV_OV7670_VERSION == 75)
639-
static const uint8_t qqvga_regs[][2] = {
632+
const uint8_t OV7675::qqvga_regs[][2] = {
640633
{ COM3, COM3_DCW_EN },
641634
{ COM14, 0x11 }, // Divide by 2
642635
{ 0x72, 0x22 }, // This has no effect on OV7675
@@ -649,8 +642,8 @@ static const uint8_t qqvga_regs[][2] = {
649642
{ VREF, 0xfa },
650643
{ 0xFF, 0xFF },
651644
};
652-
#else
653-
static const uint8_t qqvga_regs[][2] = {
645+
646+
const uint8_t OV7670::qqvga_regs[][2] = {
654647
{ COM3, COM3_DCW_EN },
655648
{ COM14, 0x1a},
656649
{ 0x72, 0x22 }, // downsample by 4
@@ -663,7 +656,6 @@ static const uint8_t qqvga_regs[][2] = {
663656
{ VREF, 0x0a },
664657
{ 0XFF, 0XFF },
665658
};
666-
#endif
667659

668660
OV7670::OV7670(arduino::MbedI2C &i2c) :
669661
_i2c(&i2c)

libraries/OV7670/ov7670.h renamed to libraries/OV7670/ov767x.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
#include "camera.h"
2323

24-
#ifndef OMV_OV7670_VERSION
25-
#define OMV_OV7670_VERSION (70)
26-
#endif
24+
2725
#ifndef OMV_OV7670_CLKRC
2826
#define OMV_OV7670_CLKRC (0x00)
2927
#endif
@@ -35,6 +33,9 @@ class OV7670: public ImageSensor {
3533
arduino::MbedI2C *_i2c;
3634
int regWrite(uint8_t dev_addr, uint16_t reg_addr, uint8_t reg_data, bool wide_addr = false);
3735
uint8_t regRead(uint8_t dev_addr, uint16_t reg_addr, bool wide_addr = false);
36+
static const uint8_t qqvga_regs[][2];
37+
static const uint8_t qvga_regs[][2];
38+
static const uint8_t rgb565_regs[][2];
3839

3940
public:
4041
OV7670(arduino::MbedI2C &i2c = CameraWire);
@@ -53,5 +54,12 @@ class OV7670: public ImageSensor {
5354
int motionDetected() { return 0; };
5455
void debug(Stream &stream);
5556
};
56-
57+
58+
class OV7675: public OV7670 {
59+
private:
60+
static const uint8_t qqvga_regs[][2];
61+
static const uint8_t qvga_regs[][2];
62+
static const uint8_t rgb565_regs[][2];
63+
};
64+
5765
#endif /* __GC2145_H */

0 commit comments

Comments
 (0)