使用的原工程是野火資料提供的,在此基礎上 我將FIFO中發往LCD的RGB565數據通過usart串口輸送到上位機,再利用山外調試助手顯示出來。
捕獲.PNG (720.94 KB, 下載次數: 59)
下載附件
2020-11-20 16:57 上傳
單片機源程序如下:- #include "stm32f10x.h"
- #include "./ov7725/bsp_ov7725.h"
- #include "./lcd/bsp_ili9341_lcd.h"
- #include "./led/bsp_led.h"
- #include "./usart/bsp_usart.h"
- #include "./key/bsp_key.h"
- #include "./systick/bsp_SysTick.h"
- extern uint8_t Ov7725_vsync;
- unsigned int Task_Delay[NumOfTask];
- extern OV7725_MODE_PARAM cam_mode;
- /**
- * @brief 主函數
- * @param 無
- * @retval 無
- */
- int main(void)
- {
- float frame_count = 0;
- uint8_t retry = 0;
- /* 液晶初始化 */
- ILI9341_Init();
- ILI9341_GramScan ( 3 );
-
- LCD_SetFont(&Font8x16);
- LCD_SetColors(RED,BLACK);
- ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH); /* 清屏,顯示全黑 */
-
- /********顯示字符串示例*******/
- ILI9341_DispStringLine_EN(LINE(0),"BH OV7725 Test Demo");
- USART_Config();
- LED_GPIO_Config();
- Key_GPIO_Config();
- SysTick_Init();
- // printf("\r\n ** OV7725攝像頭實時液晶顯示例程** \r\n");
-
- /* ov7725 gpio 初始化 */
- OV7725_GPIO_Config();
-
- LED_BLUE;
- /* ov7725 寄存器默認配置初始化 */
- while(OV7725_Init() != SUCCESS)
- {
- retry++;
- if(retry>5)
- {
- printf("\r\n沒有檢測到OV7725攝像頭\r\n");
- ILI9341_DispStringLine_EN(LINE(2),"No OV7725 module detected!");
- while(1);
- }
- }
- /*根據攝像頭參數組配置模式*/
- OV7725_Special_Effect(cam_mode.effect);
- /*光照模式*/
- OV7725_Light_Mode(cam_mode.light_mode);
- /*飽和度*/
- OV7725_Color_Saturation(cam_mode.saturation);
- /*光照度*/
- OV7725_Brightness(cam_mode.brightness);
- /*對比度*/
- OV7725_Contrast(cam_mode.contrast);
- /*特殊效果*/
- OV7725_Special_Effect(cam_mode.effect);
-
- /*設置圖像采樣及模式大小*/
- OV7725_Window_Set(cam_mode.cam_sx,
- cam_mode.cam_sy,
- cam_mode.cam_width,
- cam_mode.cam_height,
- cam_mode.QVGA_VGA);
- /* 設置液晶掃描模式 */
- // ILI9341_GramScan( cam_mode.lcd_scan );
-
-
-
- // ILI9341_DispStringLine_EN(LINE(2),"OV7725 initialize success!");
- // printf("\r\nOV7725攝像頭初始化完成\r\n");
-
- Ov7725_vsync = 0;
-
-
- while(1){
- /*接收到新圖像進行顯示*/
- if( Ov7725_vsync == 2 )
- {
- USART_SendBits(DEBUG_USARTx,0x01);
- USART_SendBits(DEBUG_USARTx,0xFE);
- frame_count++;
- FIFO_PREPARE; /*FIFO準備*/
- ImagDisp(cam_mode.lcd_sx,
- cam_mode.lcd_sy,
- cam_mode.cam_width,
- cam_mode.cam_height); /*采集并顯示*/
- USART_SendBits(DEBUG_USARTx,0xFE);
- USART_SendBits(DEBUG_USARTx,0x01);
-
- Ov7725_vsync = 0;
- LED1_TOGGLE;
- }
-
- /*檢測按鍵*/
- if( Key_Scan(KEY1_GPIO_PORT,KEY1_GPIO_PIN) == KEY_ON )
- {
- /*LED反轉*/
- LED2_TOGGLE;
- }
- /*檢測按鍵*/
- if( Key_Scan(KEY2_GPIO_PORT,KEY2_GPIO_PIN) == KEY_ON )
- {
- /*LED反轉*/
- LED3_TOGGLE;
-
- /*動態配置攝像頭的模式,
- 有需要可以添加使用串口、用戶界面下拉選擇框等方式修改這些變量,
- 達到程序運行時更改攝像頭模式的目的*/
-
- cam_mode.QVGA_VGA = 0, //QVGA模式
- cam_mode.cam_sx = 0,
- cam_mode.cam_sy = 0,
- cam_mode.cam_width = 320,
- cam_mode.cam_height = 240,
- cam_mode.lcd_sx = 0,
- cam_mode.lcd_sy = 0,
- cam_mode.lcd_scan = 3, //LCD掃描模式,本橫屏配置可用1、3、5、7模式
- //以下可根據自己的需要調整,參數范圍見結構體類型定義
- cam_mode.light_mode = 0,//自動光照模式
- cam_mode.saturation = 0,
- cam_mode.brightness = 0,
- cam_mode.contrast = 0,
- cam_mode.effect = 1, //黑白模式
-
- /*根據攝像頭參數寫入配置*/
- OV7725_Special_Effect(cam_mode.effect);
- /*光照模式*/
- OV7725_Light_Mode(cam_mode.light_mode);
- /*飽和度*/
- OV7725_Color_Saturation(cam_mode.saturation);
- /*光照度*/
- OV7725_Brightness(cam_mode.brightness);
- /*對比度*/
- OV7725_Contrast(cam_mode.contrast);
- /*特殊效果*/
- OV7725_Special_Effect(cam_mode.effect);
-
- /*設置圖像采樣及模式大小*/
- OV7725_Window_Set(cam_mode.cam_sx,
- cam_mode.cam_sy,
- cam_mode.cam_width,
- cam_mode.cam_height,
- cam_mode.QVGA_VGA);
- /* 設置液晶掃描模式 */
- ILI9341_GramScan( cam_mode.lcd_scan );
- }
-
- /*每隔一段時間計算一次幀率*/
- if(Task_Delay[0] == 0)
- {
- // printf("\r\nframe_ate = %.2f fps\r\n",frame_count/10);
- frame_count = 0;
- Task_Delay[0] = 10000;
- }
- }
-
- }
- /*********************************************END OF FILE**********************/
復制代碼
提供源碼參考:
液晶實時顯示.7z
(762.76 KB, 下載次數: 90)
2020-11-20 17:43 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|