我給你來個類似程序參考
tftlcd.h
- #ifndef _tftlcd_H
- #define _tftlcd_H
- #include "public.h"
- //定義LCD彩屏的驅動類型 可根據自己手上的彩屏背面型號來選擇打開哪種驅動
- //#define TFT22_ILI9225B
- //#define TFT22_ILI9340
- //#define TFT24_ST7781R
- //#define TFT26_R61509V
- //#define TFT26_ILI9325D
- //#define TFT22_R61503B
- //#define TFT20_HX8309
- //#define TFT24_ST7789S
- //#define TFT24_SSD1297
- //#define TFT20_ILI9225
- //#define TFT20_ILI9341
- //#define TFT20_ST7775R
- #define TFT20_ST7775RV
- //#define TFT20_ILI9225C
- //TFTLCD顯示方向控制
- #define TFTLCD_DIR 0 //0:豎屏 1:橫屏 默認豎屏
- //分辨率
- #ifdef TFT20_HX8309
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT22_R61503B
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT22_ILI9225B
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT24_ST7781R
- #define WIDTH 240
- #define HEIGHT 320
- #endif
- #ifdef TFT26_R61509V
- #define WIDTH 240
- #define HEIGHT 400
- #endif
- #ifdef TFT26_ILI9325D
- #define WIDTH 240
- #define HEIGHT 320
- #endif
- #ifdef TFT24_ST7789S
- #define WIDTH 240
- #define HEIGHT 320
- #endif
- #ifdef TFT24_SSD1297
- #define WIDTH 240
- #define HEIGHT 320
- #endif
- #ifdef TFT20_ILI9225
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT20_ILI9341
- #define WIDTH 240
- #define HEIGHT 320
- #endif
- #ifdef TFT20_ST7775R
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT20_ST7775RV
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- #ifdef TFT20_ILI9225C
- #define WIDTH 176
- #define HEIGHT 220
- #endif
- //TFTLCD彩屏數據控制端口定義
- #define TFT_DATAPORTH P1
- #define TFT_DATAPORTL P0
- sbit TFT_CS = P2^7;
- sbit TFT_RST = P3^3;
- sbit TFT_RS = P2^6;
- sbit TFT_WR = P2^5;
- sbit TFT_RD = P3^2;
- //TFTLCD重要參數集
- typedef struct
- {
- u16 width; //LCD 寬度
- u16 height; //LCD 高度
- u16 id; //LCD ID
- u8 dir; //LCD 方向
- }_tftlcd_data;
- //LCD參數
- extern _tftlcd_data tftlcd_data; //管理LCD重要參數
- //LCD的前端顏色和背景色
- extern u16 FRONT_COLOR;//前端顏色 默認紅色
- extern u16 BACK_COLOR; //背景顏色.默認為白色
- //畫筆顏色
- #define WHITE 0xFFFF
- #define BLACK 0x0000
- #define BLUE 0x001F
- #define BRED 0XF81F
- #define GRED 0XFFE0
- #define GBLUE 0X07FF
- #define RED 0xF800
- #define MAGENTA 0xF81F
- #define GREEN 0x07E0
- #define CYAN 0x7FFF
- #define YELLOW 0xFFE0
- #define BROWN 0XBC40 //棕色
- #define BRRED 0XFC07 //棕紅色
- #define GRAY 0X8430 //灰色
- void LCD_WriteCmd(u16 cmd);
- void LCD_WriteData(u16 dat);
- void LCD_WriteCmdData(u16 cmd,u16 dat);
- void LCD_WriteData_Color(u16 color);
- void TFTLCD_Init(void);//初始化
- void LCD_Set_Window(u16 sx,u16 sy,u16 width,u16 height);//設置窗口
- void LCD_Clear(u16 Color); //清屏
- void LCD_Fill(u16 xState,u16 yState,u16 xEnd,u16 yEnd,u16 color);//填充單色
- void LCD_Color_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 *color);//在指定區域內填充指定顏色塊
- void LCD_DrawPoint(u16 x,u16 y);//畫點
- void LCD_DrawFRONT_COLOR(u16 x,u16 y,u16 color);//指定顏色畫點
- void LCD_DrawBigPoint(u16 x,u16 y,u16 color);
- u16 LCD_ReadPoint(u16 x,u16 y);//讀點
- void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);//畫線
- void LCD_DrawLine_Color(u16 x1, u16 y1, u16 x2, u16 y2,u16 color);//指定顏色畫線
- void LCD_DrowSign(u16 x, u16 y, u16 color);//畫十字標記
- void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);//畫矩形
- void LCD_Draw_Circle(u16 x0,u16 y0,u8 r);//畫圓
- void LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode);//顯示一個字符
- void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size);//顯示一個數字
- void LCD_ShowxNum(u16 x,u16 y,u32 num,u8 len,u8 size,u8 mode);//顯示數字
- void LCD_ShowString(u16 x,u16 y,u16 width,u16 height,u8 size,u8 *p);//顯示字符串
- void LCD_ShowFontHZ(u16 x, u16 y, u8 *cn);//顯示漢字
- void LCD_ShowPicture(u16 x, u16 y, u16 wide, u16 high,u8 *pic);//顯示圖片
- #endif
復制代碼
|