test
Fork of ov7670 by
Diff: ov7670.cpp
- Revision:
- 4:119b4c04a4ed
- Parent:
- 3:b40a945dd672
diff -r b40a945dd672 -r 119b4c04a4ed ov7670.cpp --- a/ov7670.cpp Sat Feb 15 15:00:37 2014 +0000 +++ b/ov7670.cpp Sat Apr 05 14:01:37 2014 +0000 @@ -19,6 +19,7 @@ OV7670::~OV7670() { + } @@ -110,6 +111,21 @@ int OV7670::Init(char c, int n) { + if(c == 'b' || c == 'y') // YUV + { + format_temp = "BAW"; + } + else + if(c == 'r') // RGB565 + { + format_temp = "RGB"; + } + return Init(format_temp, n); +} + + +int OV7670::Init(char *format, int n) +{ if (ReadReg(REG_PID) != 0x76) // check id camera { @@ -120,7 +136,7 @@ Reset(); // Resets all registers to default values WriteReg(REG_RGB444, 0x00); // Disable RGB444 - WriteReg(REG_COM10, 0x02); // 0x02 VSYNC negative (http://thinksmallthings.wordpress.com/2012/03/10/cf7670c-vs-cf7670c-v2/) + WriteReg(REG_COM10, 0x02); // 0x02 VSYNC negative (http://nasulica.homelinux.org/?p=959) WriteReg(REG_MVFP, 0x27); // mirror image WriteReg(REG_CLKRC, 0x80); // prescaler x1 @@ -131,7 +147,7 @@ WriteReg(REG_COM13, 0x88); // connect to REG_TSLB - if(c == 'b' || c == 'y') // YUV + if((strcmp("BAW", format) == 0) || (strcmp("YUV", format) == 0)|| (strcmp("RAW", format) == 0)) // YUV { WriteReg(REG_COM7, 0x00); // YUV WriteReg(REG_COM17, 0x00); // color bar disable @@ -139,7 +155,7 @@ WriteReg(REG_COM15, 0xC0); // Set normal rgb with Full range }else - if(c == 'r') // RGB565 + if((strcmp("RGB", format) == 0)) // RGB565 { WriteReg(REG_COM7, 0x04); // RGB + color bar disable WriteReg(REG_RGB444, 0x00); // Disable RGB444 @@ -260,7 +276,7 @@ WriteReg(0x01, 0x40); WriteReg(0x02, 0x40); WriteReg(0x13, 0xe7); - //WriteReg(0x15, 0x02); + WriteReg(0x15, 0x02); WriteReg(0x4f, 0x80); WriteReg(0x50, 0x80); @@ -429,7 +445,7 @@ WriteReg(0x01, 0x40); WriteReg(0x02, 0x40); WriteReg(0x13, 0xe7); - //WriteReg(0x15, 0x02); + WriteReg(0x15, 0x02); WriteReg(0x4f, 0x80); WriteReg(0x50, 0x80); WriteReg(0x51, 0x00);