找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6047|回复: 7
打印 上一主题 下一主题
收起左侧

STM32F407 LCD+OV7670摄像头修改例程 小球

[复制链接]
跳转到指定楼层
楼主
ID:224922 发表于 2017-8-5 11:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32F407 LCD+ OV7670 摄像头修改例程
本人进行引脚了修改,具体请查看源代码: OV7670摄像头实验.rar (214.21 KB, 下载次数: 130)

  1. //////////////////////////////////////////////////////////////////////////////////         
  2. //STM32F407VET6 OV7670摄像头实验
  3. //BY--践行工作室        
  4. //修改日期:2016/9/14                                                                                                                                 
  5. //////////////////////////////////////////////////////////////////////////////////        
  6. #include "sys.h"
  7. #include "delay.h"  
  8. #include "usart.h"  
  9. #include "led.h"
  10. #include "lcd.h"
  11. #include "key.h"
  12. #include "ov7670.h"
  13. //#include "ov7670cfg.h"
  14. #include "timer.h"                           
  15. #include "sccb.h"        
  16. #include "exti.h"
  17. const u8*LMODE_TBL[5]={"Auto","Sunny","Cloudy","Office","Home"};                                                        //5种光照模式            
  18. const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"};        //7种特效
  19. extern u8 ov_sta;        //在exit.c里面定义
  20. extern u8 ov_frame;        //在timer.c里面定义               
  21. //更新LCD显示
  22. void camera_refresh(void)
  23. {
  24.         u32 j;
  25.          u16 color;         
  26.         if(ov_sta==2)
  27.         {
  28.                 LCD_Scan_Dir(U2D_L2R);                //从上到下,从左到右
  29.                 LCD_SetCursor(0x00,0x0000);        //设置光标位置
  30.                 LCD_WriteRAM_Prepare();     //开始写入GRAM        
  31.                 OV7670_RRST=0;                                //开始复位读指针
  32.                 OV7670_RCK=0;
  33.                 OV7670_RCK=1;
  34.                 OV7670_RCK=0;
  35.                 OV7670_RRST=1;                                //复位读指针结束
  36.                 OV7670_RCK=1;  
  37.                 for(j=0;j<76800;j++)
  38.                 {
  39.                         OV7670_RCK=0;
  40.                         color=(GPIOC->IDR&0XFF0)>>4;        //读数据
  41.                         OV7670_RCK=1;
  42.                         color<<=8;  
  43.                         OV7670_RCK=0;
  44.                         color|=(GPIOC->IDR&0XFF0)>>4;        //读数据
  45.                         OV7670_RCK=1;  
  46.                         LCD->LCD_RAM=color;  
  47.         //                printf("%x, ",color);
  48. //                                LCD->LCD_RAM=0xffffff;
  49.                 }                                                            
  50.                 EXTI->PR=1<<8;                             //清除LINE8上的中断标志位
  51.                 ov_sta=0;                                        //开始下一次采集
  52.          //        ov_frame++;
  53.                 LCD_Scan_Dir(DFT_SCAN_DIR);        //恢复默认扫描方向
  54.         }
  55. }        
  56. int main(void)
  57. {   
  58.         u8 lightmode=0,saturation=2,brightness=2,contrast=2;
  59.         u8 effect=0;        
  60. //        u8 msgbuf[15];//消息缓存区
  61.         Stm32_Clock_Init(336,8,2,7);//设置时钟,168Mhz
  62.         delay_init(168);                        //延时初始化  
  63.         uart_init(84,115200);                //初始化串口波特率为115200
  64. //        LED_Init();                                        //初始化LED
  65.          LCD_Init();
  66.         KEY_Init();
  67.   OV7670_Init();
  68.         POINT_COLOR=RED;//设置字体为红色
  69.         LCD_ShowString(60,50,200,16,16,"WarShip STM32");        
  70.         LCD_ShowString(60,70,200,16,16,"OV7670 TEST");        
  71.         LCD_ShowString(60,90,200,16,16,"JX-Stdio");
  72.         LCD_ShowString(60,110,200,16,16,"2016/9/14");  
  73.         LCD_ShowString(60,130,200,16,16,"KEY0:Light Mode");
  74.         LCD_ShowString(60,150,200,16,16,"KEY1:Saturation");
  75.         LCD_ShowString(60,170,200,16,16,"KEY2:Brightness");
  76.         LCD_ShowString(60,190,200,16,16,"KEY3:Contrast");
  77.         LCD_ShowString(60,210,200,16,16,"TPAD:Effects");         
  78.   LCD_ShowString(60,230,200,16,16,"OV7670 Init...");         
  79.         while(OV7670_Init())//初始化OV7670
  80.         {
  81.                 LCD_ShowString(60,230,200,16,16,"OV7670 Error!!");
  82.                 delay_ms(200);
  83.             LCD_Fill(60,230,239,246,WHITE);
  84.                 delay_ms(200);
  85.         }
  86.          LCD_ShowString(60,230,200,16,16,"OV7670 Init OK");
  87.         delay_ms(1500);         
  88.         OV7670_Light_Mode(lightmode);
  89.         OV7670_Color_Saturation(saturation);
  90.         OV7670_Brightness(brightness);
  91.         OV7670_Contrast(contrast);
  92.          OV7670_Special_Effects(effect);         
  93. //        TIM3_Int_Init(10000-1,8399);                        //10Khz计数频率,1秒钟中断               
  94.         EXTI9_Init();                                                //使能定时器捕获
  95.         OV7670_Window_Set(10,174,240,320);        //设置窗口         
  96.   OV7670_CS=0;        
  97.   while(1)
  98.         {                 
  99.          camera_refresh();//更新显示
  100.          if(!KEY0)                  
  101.                 {               
  102.                         while(!KEY0);//灯光模式Light Mode
  103.                         lightmode++;
  104.                         if(lightmode>4)lightmode=0;
  105.                         OV7670_Light_Mode(lightmode);
  106.                         LCD_ShowString(60,190,200,16,16,"Light Mode");
  107.                         //sprintf((char*)msgbuf,"%s",LMODE_TBL[lightmode]);
  108.                 }
  109.                 if(!KEY1)                  
  110.                 {               
  111.                         while(!KEY1);//饱和度Saturation
  112.                         saturation++;
  113.                         if(saturation>4)saturation=0;
  114.                         OV7670_Color_Saturation(saturation);
  115.                         LCD_ShowString(60,190,200,16,16,"Saturation");
  116.                         //sprintf((char*)msgbuf,"Saturation:%d",(signed char)saturation-2);
  117.                 }
  118.                 if(!KEY2)                  
  119.                 {               
  120.                         while(!KEY2);//亮度Brightness                        
  121.                         brightness++;
  122.                         if(brightness>4)brightness=0;
  123.                         OV7670_Brightness(brightness);
  124.                         LCD_ShowString(60,190,200,16,16,"Brightness        ");
  125.                         //sprintf((char*)msgbuf,"Brightness:%d",(signed char)brightness-2);
  126.                 }
  127.                 if(!KEY3)                  
  128.                 {               
  129.                         while(!KEY3);//对比度Contrast                                 
  130. //                        contrast++;
  131. //                        if(contrast>4)contrast=0;
  132. //                        OV7670_Contrast(contrast);
  133.                         effect++;
  134.                         if(effect>6)effect=0;
  135.                         OV7670_Special_Effects(effect);//设置特效
  136.                          //sprintf((char*)msgbuf,"%s",EFFECTS_TBL[effect]);
  137.                         LCD_ShowString(60,190,200,16,16,"Contrast        ");
  138.                         //sprintf((char*)msgbuf,"Contrast:%d",(signed char)contrast-2);
  139.                 }
  140.                
  141.         }
  142. }

复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩1
回复

使用道具 举报

沙发
ID:163642 发表于 2018-4-15 20:35 | 只看该作者
谢谢分享
回复

使用道具 举报

板凳
ID:329571 发表于 2018-6-11 10:27 | 只看该作者
谢谢分享
回复

使用道具 举报

地板
ID:225110 发表于 2018-6-14 20:08 | 只看该作者
这个的功能是什么,能实现摄像头定位小球的坐标么
回复

使用道具 举报

5#
ID:368501 发表于 2018-7-10 11:14 | 只看该作者
多谢分享
回复

使用道具 举报

6#
ID:155960 发表于 2018-10-24 19:23 | 只看该作者
多谢分享
回复

使用道具 举报

7#
ID:504821 发表于 2019-4-13 14:11 | 只看该作者
请问能不能分享下ov7670封装
回复

使用道具 举报

8#
ID:138247 发表于 2019-5-2 15:23 | 只看该作者

谢谢楼主分享。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表