ov7670拍照时,将拍照框移动后,就再也存不到sd卡图片了
TIM6_Int_Init(10000,7199); //10Khz计数频率,1秒钟中断
EXTI8_Init(); //使能定时器捕获
OV7670_Window_Set(12,176,240 ,320); //设置窗口 12 176 LCD_Set_Window((lcddev.width-320)/16,lcddev.height-260
OV7670_CS=0;
LCD_Clear(RED);
r=lcddev.width;
t=lcddev.height;
printf("r=%d",r);
printf("t=%d",t);
while(1)
{
key=KEY_Scan(0);//不支持连按
if(key==KEY0_PRES)
{
if(sd_ok)
{
LED1=0; //点亮DS1,提示正在拍照
camera_new_pathname(pname);//得到文件名
if(bmp_encode(pname,(lcddev.width-320)/16,lcddev.height-260,240,320,0))//拍照有误
{
Show_Str(40,130,240,12,"写入文件错误!",12,0);
}else
{
Show_Str(40,130,240,12,"拍照成功!",12,0);
Show_Str(40,150,240,12,"保存为:",12,0);
Show_Str(40+42,150,240,12,pname,12,0);
BEEP=1; //蜂鸣器短叫,提示拍照完成
delay_ms(100);
}
}else //提示SD卡错误
{
Show_Str(40,130,240,12,"SD卡错误!",12,0);
Show_Str(40,150,240,12,"拍照功能不可用!",12,0);
}
BEEP=0;//关闭蜂鸣器
LED1=1;//关闭DS1
delay_ms(1800);//等待1.8秒钟
LCD_Clear(BLACK);
}else delay_ms(5);
camera_refresh();//更新显示
void camera_refresh(void)
{
u32 j;
u16 color;
if(ov_sta)//有帧中断更新?
{
LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右
if(lcddev.id==0X1963)LCD_Set_Window((lcddev.width-240)/2,(lcddev.height-320)/2,240,320);//将显示区域设置到屏幕中央
else if(lcddev.id==0X5510||lcddev.id==0X5310)LCD_Set_Window((lcddev.width-320)/16,lcddev.height-260,320,240);//将显示区域设置到屏幕 左上角 lcddev.height-240
LCD_WriteRAM_Prepare(); //开始写入GRAM
OV7670_RRST=0; //开始复位读指针
OV7670_RCK_L;
OV7670_RCK_H;
OV7670_RCK_L;
OV7670_RRST=1; //复位读指针结束
OV7670_RCK_H;
for(j=0;j<76800;j++)
{
OV7670_RCK_L;
color=GPIOC->IDR&0XFF; //读数据
OV7670_RCK_H;
color<<=8;
OV7670_RCK_L;
color|=GPIOC->IDR&0XFF; //读数据
OV7670_RCK_H;
LCD->LCD_RAM=color;
}
一周热门 更多>