stm32圖片顯示
本擴展實驗是應廣大用戶需求而精心制作.實現讀取內部flash的圖像數據,并顯示在LCD上.本實驗的圖像數據由image2lcd V2.9生成.(僅支持16位真彩色圖片的顯示,其他的情況請大家參考本例程,自行設計即可.)
本代碼可以SWD下載仿真.
單片機源程序如下:
- #include <stm32f10x_lib.h>
- #include "sys.h"
- #include "usart.h"
- #include "delay.h"
- #include "led.h"
- #include "key.h"
- #include "exti.h"
- #include "wdg.h"
- #include "timer.h"
- #include "lcd.h"
- #include "usmart.h"
- #include "image2lcd.h"
- #include "stdlib.h"
- extern const u8 gImage_image1[];//圖片數據(包含信息頭),存儲在image1.c里面.
- //Mini STM32開發板擴展實驗13
- //內部FLASH圖片顯示 實驗
- //正點原子@ALIENTEK
-
- int main(void)
- {
- u8 i=0;
- HEADCOLOR *imginfo;
- u16 x=0,y=0;
- u16 x0,y0;
- imginfo=(HEADCOLOR*)gImage_image1; //得到文件信息
- Stm32_Clock_Init(9);//系統時鐘設置
- delay_init(72); //延時初始化
- uart_init(72,9600); //串口1初始化
- usmart_dev.init(72);//初始化USMART
- LED_Init();
- LCD_Init();
- POINT_COLOR=RED;
- LCD_ShowString(30,50,"Mini STM32 ^_^");
- LCD_ShowString(30,70,"FLASH PICTURE TEST");
- LCD_ShowString(30,90,"ATOM@ALIENTEK");
- LCD_ShowString(30,110,"2011/10/09");
- delay_ms(1500);//等待1.5秒
- srand(imginfo->h*imginfo->w);
- while(1)
- {
- if(i==0)
- {
- LCD_Clear(0X0000);//黑屏
- if(imginfo->w>=240||imginfo->h>=320)
- {
- POINT_COLOR=RED;
- LCD_ShowString(10,70,"The Picture is too large");
- continue;
- }
- x0=x;y0=y;
- while((x+imginfo->w)>240||x==x0)//超過屏幕尺寸了
- {
- x=rand();//獲得隨機的x值
- }
- while((y+imginfo->h)>320||y==y0)//超過屏幕尺寸了
- {
- y=rand();//獲得隨機的y值
- }
- image_display(x,y,(u8*)gImage_image1);//在指定地址顯示圖片
- }
- i++;
- if(i>10)i=0;
- LED0=!LED0;
- delay_ms(200);
- }
- }
復制代碼
所有資料51hei提供下載:
ALIENTEK MINISTM32 擴展實驗13 內部FLASH圖片顯示實驗.rar
(221.31 KB, 下載次數: 140)
2018-3-15 23:17 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|