1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/ #include <reg52.h> #include <string.h> #define uchar unsigned char #define uint unsigned int void Initialize\_LCD(); void ShowString(uchar,uchar,uchar \*); sbit K1 = P3^0; sbit K2 = P3^1; sbit K3 = P3^2;
uchar code Prompt[]="PRESS K1--K3 TO START DEMO PROG"; uchar const Line_Count = 6; uchar code Msg[][80]= { "Many CAD users dismiss", "process of creating PCB", "of view.with PCB layout", "placement and track routing,", "can often be the most time", "And if you use circuit simulation", "you are going to spend even more" }; uchar Disp_Buffer[32]; void Delayxms(uint ms) { uchar i; while(ms--) { for(i=0;i<120;i++); } }
void V\_Scroll\_Display() { uchar i,j,k = 0; uchar \*p = Msg[0]; uchar \*q = Msg[Line_Count] + strlen(Msg[Line_Count]); while(p<q) { for(i=0;(i<16)&&(p<q);i++) { if(((i==0)||(i==15))&& \*p == ' ') p++; if(\*p != '\0') { Disp_Buffer[i] = \*p++; } else { if(++k>Line_Count) break; p = Msg[k]; Disp_Buffer[i] = \*p++; } } for(j=i;j<16;j++) Disp_Buffer[j]=' '; while(F0) Delayxms(5); ShowString(0,0," "); Delayxms(150); while(F0) Delayxms(5); ShowString(0,1,Disp_Buffer); Delayxms(150); while(F0) Delayxms(5); ShowString(0,0,Disp_Buffer); ShowString(0,1," "); Delayxms(150); } ShowString(0,0," "); ShowString(0,1," "); }
void H\_Scroll\_Display() { uchar m,n,t = 0,L=0; uchar \*p = Msg[0]; uchar \*q = Msg[Line_Count] + strlen(Msg[Line_Count]); for(m=0;m<16;m++) Disp_Buffer[m]=' '; while(p<q) { if((m=16||m==31)&& \*p == ' ') p++; for(m=16;m<32&&p<q;m++) { if(\*p != '\0') { Disp_Buffer[m] = \*p++; } else { if(++t>Line_Count) break; p = Msg[t]; Disp_Buffer[m] = \*p++; } } for(n=m;n<32;n++) Disp_Buffer[n]=' '; for(m=0;m<=16;m++) { while(F0) Delayxms(5); ShowString(0,L,Disp_Buffer+1); while(F0) Delayxms(5); Delayxms(20); } L = (L==0)? 1:0; Delayxms(200); } if(L==1) ShowString(0,1," "); }
void EX\_INT0() interrupt 0 { F0 = !F0; }
void main()`在这里插入代码片` { uint Count = 0; IE = 0x81; IT0 = 1; F0 = 0; Initialize\_LCD(); ShowString(0,0,Prompt); ShowString(0,1,Prompt+16); while(1) { if(K1 == 0) { V\_Scroll\_Display(); Delayxms(200); } else if(K2 == 0) { H\_Scroll\_Display(); Delayxms(200); } } }
|