标题:
STM32F407 LCD+OV7670摄像头修改例程 小球
[打印本页]
作者:
XWG
时间:
2017-8-5 11:10
标题:
STM32F407 LCD+OV7670摄像头修改例程 小球
STM32F407 LCD+ OV7670 摄像头修改例程
本人进行引脚了修改,具体请查看源代码:
OV7670摄像头实验.rar
(214.21 KB, 下载次数: 130)
2017-8-6 03:55 上传
点击文件名下载附件
下载积分: 黑币 -5
//////////////////////////////////////////////////////////////////////////////////
//STM32F407VET6 OV7670摄像头实验
//BY--践行工作室
//修改日期:2016/9/14
//////////////////////////////////////////////////////////////////////////////////
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"
#include "ov7670.h"
//#include "ov7670cfg.h"
#include "timer.h"
#include "sccb.h"
#include "exti.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里面定义
//更新LCD显示
void camera_refresh(void)
{
u32 j;
u16 color;
if(ov_sta==2)
{
LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右
LCD_SetCursor(0x00,0x0000); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
OV7670_RRST=0; //开始复位读指针
OV7670_RCK=0;
OV7670_RCK=1;
OV7670_RCK=0;
OV7670_RRST=1; //复位读指针结束
OV7670_RCK=1;
for(j=0;j<76800;j++)
{
OV7670_RCK=0;
color=(GPIOC->IDR&0XFF0)>>4; //读数据
OV7670_RCK=1;
color<<=8;
OV7670_RCK=0;
color|=(GPIOC->IDR&0XFF0)>>4; //读数据
OV7670_RCK=1;
LCD->LCD_RAM=color;
// printf("%x, ",color);
// LCD->LCD_RAM=0xffffff;
}
EXTI->PR=1<<8; //清除LINE8上的中断标志位
ov_sta=0; //开始下一次采集
// ov_frame++;
LCD_Scan_Dir(DFT_SCAN_DIR); //恢复默认扫描方向
}
}
int main(void)
{
u8 lightmode=0,saturation=2,brightness=2,contrast=2;
u8 effect=0;
// u8 msgbuf[15];//消息缓存区
Stm32_Clock_Init(336,8,2,7);//设置时钟,168Mhz
delay_init(168); //延时初始化
uart_init(84,115200); //初始化串口波特率为115200
// LED_Init(); //初始化LED
LCD_Init();
KEY_Init();
OV7670_Init();
POINT_COLOR=RED;//设置字体为红色
LCD_ShowString(60,50,200,16,16,"WarShip STM32");
LCD_ShowString(60,70,200,16,16,"OV7670 TEST");
LCD_ShowString(60,90,200,16,16,"JX-Stdio");
LCD_ShowString(60,110,200,16,16,"2016/9/14");
LCD_ShowString(60,130,200,16,16,"KEY0:Light Mode");
LCD_ShowString(60,150,200,16,16,"KEY1:Saturation");
LCD_ShowString(60,170,200,16,16,"KEY2:Brightness");
LCD_ShowString(60,190,200,16,16,"KEY3:Contrast");
LCD_ShowString(60,210,200,16,16,"TPAD:Effects");
LCD_ShowString(60,230,200,16,16,"OV7670 Init...");
while(OV7670_Init())//初始化OV7670
{
LCD_ShowString(60,230,200,16,16,"OV7670 Error!!");
delay_ms(200);
LCD_Fill(60,230,239,246,WHITE);
delay_ms(200);
}
LCD_ShowString(60,230,200,16,16,"OV7670 Init OK");
delay_ms(1500);
OV7670_Light_Mode(lightmode);
OV7670_Color_Saturation(saturation);
OV7670_Brightness(brightness);
OV7670_Contrast(contrast);
OV7670_Special_Effects(effect);
// TIM3_Int_Init(10000-1,8399); //10Khz计数频率,1秒钟中断
EXTI9_Init(); //使能定时器捕获
OV7670_Window_Set(10,174,240,320); //设置窗口
OV7670_CS=0;
while(1)
{
camera_refresh();//更新显示
if(!KEY0)
{
while(!KEY0);//灯光模式Light Mode
lightmode++;
if(lightmode>4)lightmode=0;
OV7670_Light_Mode(lightmode);
LCD_ShowString(60,190,200,16,16,"Light Mode");
//sprintf((char*)msgbuf,"%s",LMODE_TBL[lightmode]);
}
if(!KEY1)
{
while(!KEY1);//饱和度Saturation
saturation++;
if(saturation>4)saturation=0;
OV7670_Color_Saturation(saturation);
LCD_ShowString(60,190,200,16,16,"Saturation");
//sprintf((char*)msgbuf,"Saturation:%d",(signed char)saturation-2);
}
if(!KEY2)
{
while(!KEY2);//亮度Brightness
brightness++;
if(brightness>4)brightness=0;
OV7670_Brightness(brightness);
LCD_ShowString(60,190,200,16,16,"Brightness ");
//sprintf((char*)msgbuf,"Brightness:%d",(signed char)brightness-2);
}
if(!KEY3)
{
while(!KEY3);//对比度Contrast
// contrast++;
// if(contrast>4)contrast=0;
// OV7670_Contrast(contrast);
effect++;
if(effect>6)effect=0;
OV7670_Special_Effects(effect);//设置特效
//sprintf((char*)msgbuf,"%s",EFFECTS_TBL[effect]);
LCD_ShowString(60,190,200,16,16,"Contrast ");
//sprintf((char*)msgbuf,"Contrast:%d",(signed char)contrast-2);
}
}
}
复制代码
作者:
zerox
时间:
2018-4-15 20:35
谢谢分享
作者:
1757897801
时间:
2018-6-11 10:27
谢谢分享
作者:
liu666666
时间:
2018-6-14 20:08
这个的功能是什么,能实现摄像头定位小球的坐标么
作者:
jklfdjsf
时间:
2018-7-10 11:14
多谢分享
作者:
机制的黎
时间:
2018-10-24 19:23
多谢分享
作者:
liuzhixuan
时间:
2019-4-13 14:11
请问能不能分享下ov7670封装
作者:
plj213
时间:
2019-5-2 15:23
谢谢楼主分享。。。。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1