對入門的小伙伴很有幫助噢 ~
單片機源程序如下:
- #include "stm32f10x.h"
- #include "public.h"
- #include "bsp_ili9341_lcd.h"
- #include "bsp_sdfs_app.h"
- #include "bsp_bmp.h"
- #include "bsp_SysTick.h"
- #include "bsp_touch.h"
- #include "bsp_spi_flash.h"
- #include "led.h"
- #include "even_process.h"
- /*
- 三個坐標系統的轉換:
- 觸摸屏:
- column 240
- x
- _ _ _ _ _ _
- ^ |
- | |
- | |
- | |
- | |
- | | 320
- | |
- | |
- | |
- | |
- | |
- | |
- (0,0) - - - - - -> y
-
- 液晶顯示字體及清屏等函數:
- column 240
- x
- (0,0) ----------->
- | |
- | |
- | |
- | |
- | |
- | | 320
- | |
- | |
- | |
- | |
- | |
- | |
- V- - - - - -
- y
- 液晶顯示圖像:
- column 240
- X
- -----------A
- | |
- | |
- | |
- | |
- | |
- | | 320
- | |
- | |
- | |
- | |
- | |
- | |
- Y <- - - - - -(0,0)
- 轉換關系:
- Y字 = 320 - X觸摸
- X字 = Y觸摸
- X圖像 = X觸摸
- Y圖像 = 240-Y觸摸
- Y圖像 = 240 - X字
- X圖像 = 320 - Y字
- */
- int main(void)
- {
- LCD_Init();
- LCD_Clear(0, 0, 240, 320, BLACK);//背景黑色
- Sd_fs_init();//初始化sd卡文件系統,漢字的字庫
- SysTick_Init();/* 系統定時器 1us 定時初始化 */
- LED_GPIO();/* 初始化LED */
- LED(4,0);//全部關燈
-
- SPI_FLASH_Init();/* 初始化外部FLASH */
- Touch_Init();/* 觸摸屏IO和中斷初始化 */
- SPI_FLASH_BufferRead(&cal_flag, 0, 1);
- if( cal_flag == 0x55 )
- {
- SPI_FLASH_BufferRead((void*)cal_p, 1, sizeof(cal_p));
- SPI_FLASH_CS_HIGH();
- }
- //右下角是0,0。豎立是x,橫向是y
- Lcd_show_bmp(60, 0,"/button/bg1.bmp");//背景的圖片是260*240,因此320-260=60
- Lcd_show_bmp(0, 177,"/button/4.bmp");//左邊紅
- Lcd_show_bmp(0, 116,"/button/1a.bmp");//左邊紅
- Lcd_show_bmp(0, 58,"/button/2a.bmp");//中間綠
- Lcd_show_bmp(0, 0,"/button/3a.bmp");//右邊黃
- while(1)even_process();
- }
- /******************* end of file**************************/
復制代碼
所有資料51hei提供下載:
圖片按鈕控制LED開關.7z
(516.69 KB, 下載次數: 61)
2019-6-13 06:43 上傳
點擊文件名下載附件
基于STM32F系列
|