在320X240的液晶上显示qvga,一切正常。打算让摄像头显示在窗口280X200,怎么都是错位。
void OV_HW(unsigned int hstart, unsigned int hstop, unsigned int vstart, unsigned int vstop)
{
uint8_t v;
OV7670_WriteReg(0x17, (hstart >> 3) & 0xff); //HSTART
OV7670_WriteReg(0x18, (hstop >> 3) & 0xff); //HSTOP
OV7670_ReadReg(0x32,&v);
v = (v & 0xc0) | ((hstop & 0x7) << 3) | (hstart & 0x7);
OV7670_WriteReg(0x32, v); //HREF
OV7670_WriteReg(0x19, (vstart >> 2) & 0xff); //VSTART 开始高8位
OV7670_WriteReg(0x1a, (vstop >> 2) & 0xff); //VSTOP 结束高8位
OV7670_ReadReg(0x03,&v );
v = (v & 0xf0) | ((vstop & 0x3) << 2) | (vstart & 0x3);
OV7670_WriteReg(0x03, v); //VREF
OV7670_WriteReg(0x11, 0x00);
}
- //输出窗口设置
- void OV7670_config_window(u16 startx,u16 starty,u16 width,u16 height)
- {
- u16 endx=(startx+width)%784; //QVGA输出的话改成 u16 endx=(startx+width*2)%784;
- u16 endy=(starty+height); // u16 endy=(starty+height*2);
- u8 x_reg,y_reg;
- u8 state,temp;
- state=ov7660_read_reg(0x32,&x_reg);
- x_reg&=0xC0;
- state=ov7660_read_reg(0x03,&y_reg);
- y_reg&=0xF0;
-
- //HREF
- temp=x_reg|((endx&0x7)<<3)|(startx&0x7);
- state=ov7670_write_reg(0x32,temp);
- temp=(startx&0x7F8)>>3;
- state=ov7670_write_reg(0x17,temp);
- temp=(endx&0x7F8)>>3;
- state=ov7670_write_reg(0x18,temp);
-
- //VREF
- temp=y_reg|((endy&0x3)<<2)|(starty&0x3);
- state=ov7670_write_reg(0x03,temp);
- temp=(starty&0x3FC)>>2;
- state=ov7670_write_reg(0x19,temp);
- temp=(endy&0x3FC)>>2;
- state=ov7670_write_reg(0x1A,temp);
- }
复制代码忘记说了,OV7670_config_window函数的前两个参数是固定的,比如你要设置160x120大小的画面,参数是这样的,OV7670_config_window(184,10,160,120);
还有一个就是LCD开窗的大小也要设置成160x120。
OV7670_config_window(184,10,260,220);显示切是260X110
你好,设置160X120画面,为何显示是160X60两个画面叠加,你那也会这样吗,我现在是OV7670_config_window(184,10,160,240);才能正常显示160X120,另外为和起始地址是184和10,为何不能0,?
一周热门 更多>