新手入门
- 积分
- 10
- 金钱
- 10
- 注册时间
- 2022-3-9
- 在线时间
- 3 小时
|
楼主 |
发表于 2022-3-23 13:07:54
|
显示全部楼层
#include "delay.h"
#include "sys.h"
#include "lcd.h"
#include "touch.h"
#include "gui.h"
#include "test.h"
#include "ov7670.h"
#include "exti.h"
#include "timer.h"
#include "sccb.h"
#include "usart.h"
#include "usmart_str.h"
#include "key.h"
const u8*LMODE_TBL[5]={"Auto","Sunny","Cloudy","Office","Home"}; //5种光照模式
const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"}; //7种特效
extern u8 ov_sta; //在exit.c里 面定义
extern u8 ov_frame; //在timer.c里面定义
void camera_refresh(void)
{
u32 j;
u16 color;
if(ov_sta)//有帧中断更新?
{
LCD_direction(90);
// LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右
if(lcddev.id==0X1963)LCD_SetWindows((lcddev.width-240)/2,(lcddev.height-320)/2,240,320);//将显示区域设置到屏幕中央
else if(lcddev.id==0X5510||lcddev.id==0X5310)LCD_SetWindows((lcddev.width-320)/2,(lcddev.height-240)/2,320,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_WriteData_16Bit(color);
}
ov_sta=0; //清零帧中断标记
ov_frame++;
// LCD_Scan_Dir(DFT_SCAN_DIR); //恢复默认扫描方向
}
}
int main(void)
{
u8 key;
u8 lightmode=0,saturation=2,brightness=2,contrast=2;
u8 effect=0;
u8 i=0;
u8 msgbuf[15]; //消息缓存区
u8 tm=0;
SystemInit();//初始化RCC 设置系统主频为72MHZ
delay_init(72); //延时初始化
LCD_Init(); //液晶屏初始化
uart_init(115200); //串口初始化为 115200
//usmart_dev.init(72); //初始化USMART
//KEY_Init(); //初始化按键
POINT_COLOR=RED; //设置字体为红色
Gui_StrCenter(0,0,RED,BLUE,"WarShip STM32",16,1);
Gui_StrCenter(0,20,RED,BLUE,"OV7670 TEST",16,1);
Gui_StrCenter(0,40,RED,BLUE,"2020/3/22",16,1);
Gui_StrCenter(0,60,RED,BLUE,"KEY0ight Mode",16,1);
Gui_StrCenter(0,80,RED,BLUE,"KEY1:Saturation",16,1);
Gui_StrCenter(0,100,RED,BLUE,"KEY2:Brightness",16,1);
Gui_StrCenter(0,120,RED,BLUE,"KEY_UP:Contrast",16,1);
Gui_StrCenter(0,140,RED,BLUE,"TPAD:Effects",16,1);
Gui_StrCenter(0,160,RED,BLUE,"OV7670 Init...",16,1);
// delay_ms(1500);
while(OV7670_Init())//初始化OV7670
{
Gui_StrCenter(0,180,RED,BLUE,"OV7670 Error!!",16,1);
delay_ms(200);
LCD_Fill(30,230,239,246,WHITE);
delay_ms(200);
}
Gui_StrCenter(0,180,RED,BLUE,"OV7670 Init OK",16,1);
OV7670_Light_Mode(lightmode);
OV7670_Color_Saturation(saturation);
OV7670_Brightness(brightness);
OV7670_Contrast(contrast);
OV7670_Special_Effects(effect);
TIM6_Int_Init(10000,7199); //10Khz计数频率,1秒钟中断
EXTI8_Init(); //使能定时器捕获
OV7670_Window_Set(12,176,240,320); //设置窗口
OV7670_CS=0;
LCD_Clear(WHITE);
while(1){
// key=KEY_Scan(0);//不支持连按
// if(key)
// if(key)
// {
// tm=20;
// switch(key)
// {
// case KEY0_PRES: //灯光模式Light Mode
// lightmode++;
// if(lightmode>4)lightmode=0;
// OV7670_Light_Mode(lightmode);
// sprintf((char*)msgbuf,"%s",LMODE_TBL[lightmode]);
// break;
// case KEY1_PRES: //饱和度Saturation
// saturation++;
// if(saturation>4)saturation=0;
// OV7670_Color_Saturation(saturation);
// sprintf((char*)msgbuf,"Saturation:%d",(signed char)saturation-2);
// break;
// case KEY2_PRES: //亮度Brightness
// brightness++;
// if(brightness>4)brightness=0;
// OV7670_Brightness(brightness);
// sprintf((char*)msgbuf,"Brightness:%d",(signed char)brightness-2);
// break;
// case WKUP_PRES: //对比度Contrast
// contrast++;
// if(contrast>4)contrast=0;
// OV7670_Contrast(contrast);
// sprintf((char*)msgbuf,"Contrast:%d",(signed char)contrast-2);
// break;
// }
// }
camera_refresh();
}
这是main程序
|
|