|
ILI9341tft屏幕的單片機(jī)驅(qū)動(dòng)給廣大網(wǎng)友做參考,由于時(shí)間寫的參促,難免有錯(cuò)希望大家指出.
單片機(jī)彩屏版萬年歷仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
單片機(jī)源程序如下(主程序):
- #include <REGX55.H>
- #include "TFT.H"
- #include "TFT_GDI.H"
- #include "DS3231.h" //如果不測(cè)試時(shí)間請(qǐng)注銷它
- void Travel_time();
- void Display_stc(void);
- void Display_dyn_time(void);//顯示需更新的界面
- void Display_dyn_rili(void);//顯示需更新的界面
- //=========================================================================
- //本程序用來學(xué)習(xí)彩屏應(yīng)用,以及時(shí)鐘寫法,學(xué)習(xí)鐘能深入了解51編程,讓你展握編輯思想.
- //時(shí)間調(diào)整程序,留給各位網(wǎng)友,發(fā)揮自己想象
- //如果有能力,可以采用GPS調(diào)時(shí).
- //=========================================================================
- void main()
- {
- //寫時(shí)間為了測(cè)試用,
- IIC_single_byte_write(0x00,0x54);
- IIC_single_byte_write(0x01,0x59);
- IIC_single_byte_write(0x02,0x23);
-
- IIC_single_byte_write(0x04,0x15);
- IIC_single_byte_write(0x05,0x02);
- IIC_single_byte_write(0x06,0x18);
- //不用測(cè)試時(shí)間請(qǐng)注銷
- LCD_Init();
- Display_stc();
- Display_dyn_time();
- Display_dyn_rili();
-
- while(1)
- {
- Travel_time();
- }
- }
復(fù)制代碼 TFT_GDI.C
- #include "TFT.H"
- #include "TFT_GDI.H"
- void LcdPutStr(RECT rect,unsigned int color,unsigned int bkcolor,unsigned char* GB_font,unsigned int font_num)
- {//四個(gè)參數(shù)分別起啟地址X與Y,字體顏色,字體背景色,要顯示數(shù)字
- unsigned char i,j;
- LCD_SetArea(rect);
- LCD_WR_REG(0x2C);//寫儲(chǔ)存器命令
- for(i=0;i<font_num;i++)
- {
- for(j=8;j>0;j--)
- {
- if(1==(GB_font[i]>>j-1&0x01))//判斷字符位置是否有像素//--有
- {
- LcdWirteColorData(color);//寫入字體顏色
- }
- else //沒有
- {
- LcdWirteColorData(bkcolor);//沒有則寫入背景色
- }
- }
-
- }
- }
- void show816(unsigned int num_X, unsigned int num_Y,unsigned char* GB_font)
- {
- RECT rect;//屏顯示范圍
- num_Y=239-num_Y-15;//屏坐標(biāo)轉(zhuǎn)換
- rect.top=num_X;
- rect.left=num_Y;
- rect.right=num_Y+15;
- rect.bottom=num_X+15;
- LcdPutStr(rect,0XF800,0XFfff,GB_font,16);
- }
- void show3216(unsigned int num_X, unsigned int num_Y,unsigned char* GB_font)
- {//調(diào)用該涵數(shù),num_X最大不要超過224,num_Y不超304
- RECT rect;//屏顯示范圍
- num_Y=239-num_Y-15;//屏坐標(biāo)轉(zhuǎn)換
- rect.top=num_X;
- rect.left=num_Y;
- rect.right=num_Y+15;
- rect.bottom=num_X+31;
- LcdPutStr(rect,0XF800,0XFfff,GB_font,32);
- }
- void show3264(unsigned int num_X, unsigned int num_Y,unsigned char* GB_font)
- {
- RECT rect;//屏顯示范圍
- num_Y=239-num_Y-63;//屏坐標(biāo)轉(zhuǎn)換
- rect.top=num_X;
- rect.left=num_Y;
- rect.right=num_Y+63;
- rect.bottom=num_X+31;
- LcdPutStr(rect,0XF800,0XFfff,GB_font,255);
- }
復(fù)制代碼
DS3231.c單片機(jī)源程序如下:
所有資料51hei提供下載:
51萬年歷彩屏版.7z
(109.57 KB, 下載次數(shù): 456)
2021-7-11 19:33 上傳
點(diǎn)擊文件名下載附件
|
評(píng)分
-
查看全部評(píng)分
|