资源描述:
《TFT液晶显示时钟程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、TFT液晶显示时钟程序说明:该程序文件中包含三个.c文件和三个.h文件,方便读者理解程序的层次性和关联性。该程序的功能是利用51单片机实现逻辑控制,在液晶显示屏上显示动态时钟。1.shizhong.c(实际上是主程序):#include"REG51.H"#include"gui.h"unsignedcharcount;#definekeyP1sbitK=P2^0;unsignedchara;unsignedcharb;unsignedcharc;unsignedchard;unsignedchare;unsignedcharf;unsignedch
2、arg;unsignedcharsw;unsignedcharh1=0;unsignedcharh2=0;unsignedcharh3=0;unsignedintq;voidKeyboard(){unsignedintk;key=0xf0;if(key!=0xf0){for(q=0;q<800;q++);if(key!=0xf0){key=0x0f;switch(key){case(0x0e):k=0;break;case(0x0d):k=4;break;case(0x0b):k=8;break;case(0x07):k=12;break;}key
3、=0xf0;switch(key){case(0xe0):k=k;break;case(0xd0):k=k+1;break;case(0xb0):k=k+2;break;case(0x70):k=k+3;break;}while(key!=0xf0);switch(k){case0:f++;P0=0x01;if(f==3){f=0;}break;case1:e++;P0=0x02;if(f<2){if(e==10){e=0;}}if(f==2){if(e==4){e=0;}}break;case2:d++;P0=0x04;if(d==6){d=0;
4、}break;case3:c++;P0=0x08;if(c==10){c=0;}break;case4:b++;P0=0x10;if(b==6){b=0;}break;case5:a++;P0=0x20;if(a==10){a=0;}break;case6:sw=0;break;case7:sw=1;break;}}}}voidjishu(){K=1;if(K==0){for(q=0;q<800;q++);if(K==0){h1++;if(h1==10){h1=0;h2++;if(h2==10){h2=0;h3++;}}while(K==0);}}
5、GUI_WriteASCII(0,50,h3,RED,WHITE);GUI_WriteASCII(16,50,h2,RED,WHITE);GUI_WriteASCII(32,50,h1,RED,WHITE);}voidmain(void){TFT_Init();TFT_ClearScreen(BLACK);EA=1;ET1=1;TMOD=0x10;TH1=15536/256;TL1=15536%256;TR1=1;a=0;b=0;c=0;d=0;e=0;f=0;g=10;count=0;sw=1;GUI_WriteASCII(0,50,0,RED,
6、WHITE);GUI_WriteASCII(16,50,0,RED,WHITE);GUI_WriteASCII(32,50,0,RED,WHITE);while(1){while(sw){TR1=1;jishu();if(count>=20){count=0;a++;if(a==10){a=0;b++;if(b==6){b=0;c++;if(c==10){c=0;d++;if(d==6){d=0;e++;if(f<2&&e==10){e=0;f++;}if(f==2&&e==4){f=0;e=0;}}}}}GUI_WriteASCII(0,0,f,
7、RED,WHITE);GUI_WriteASCII(16,0,e,RED,WHITE);GUI_WriteASCII(32,0,g,RED,WHITE);GUI_WriteASCII(48,0,d,RED,WHITE);GUI_WriteASCII(64,0,c,RED,WHITE);GUI_WriteASCII(80,0,g,RED,WHITE);GUI_WriteASCII(96,0,b,RED,WHITE);GUI_WriteASCII(112,0,a,RED,WHITE);}Keyboard();}Keyboard();GUI_WriteA
8、SCII(0,0,f,RED,WHITE);GUI_WriteASCII(16,0,e,RED,WHITE);GUI_Wr