📄 lcd_key_1.lst
字号:
174 2 return;
175 2 }
176 1 if (key==10) { //调整交通灯切换时间
177 2
178 2 manage=1;
179 2 cnt1++;
C51 COMPILER V8.15 LCD_KEY_1 08/10/2008 20:26:24 PAGE 4
180 2 if (cnt1>=6) cnt1=1;
181 2 discnt();
182 2 return;
183 2 }
184 1 if (key==11) {
185 2 manage=2; //紧急状态
186 2 cnt2++;
187 2 if (cnt2>=4) cnt2=1;
188 2 discnt();
189 2
190 2 return;
191 2 }
192 1 if (key==12) { //清零
193 2 manage=3;
194 2 discnt();
195 2 return;
196 2 }
197 1
198 1 if (key==13) {return;} //预留
199 1
200 1
201 1 if (key==14) { //确定键
202 2 switch (manage){
203 3 case 0:{return;}
204 3 case 1:{manage=0;
205 4 i=insed[0]*100+insed[1]*10+insed[2];
206 4 if (i>255) i=255;
207 4 ctime[cnt1-1]=i;
208 4 Send_Command_LCM(0x0c);
209 4 Send_Command_LCM(0x01);
210 4 cnt1=0;
211 4 break;
212 4 }
213 3 case 2:{
214 4 execute=1;
215 4 upled=1;
216 4 break;
217 4 }
218 3
219 3 case 3:{
220 4 execute=1;
221 4 upled=1;
222 4 break;
223 4 }
224 3
225 3 } //switch
226 2 } //if
227 1 if (key==15) {
228 2 Send_Command_LCM(0x0c);
229 2 Send_Command_LCM(0x01);
230 2 execute=0;
231 2 manage=0;
232 2 upled=0;
233 2 ctime[0]=8;
234 2 ctime[1]=2;
235 2 ctime[2]=5;
236 2 ctime[3]=2;
237 2 ctime[4]=5;
238 2 //ctime[5]={8,2,5,2,5}; //恢复正常工作
239 2 return;
240 2 } //恢复键,取消键
241 1 }
C51 COMPILER V8.15 LCD_KEY_1 08/10/2008 20:26:24 PAGE 5
242 //-----------------------------------------------------------------------------------
243 void distime(){
244 1 if (sedpre!=sed) {
245 2 Set_LCM_XY(0,1);
246 2 Send_Num_LCM(min/10);
247 2 Send_Num_LCM(min%10);
248 2 Send_String_LCM(":");
249 2 //Send_String_LCM(sed);
250 2 Send_Num_LCM(sed/10);
251 2 Send_Num_LCM(sed%10);
252 2 sedpre=sed;
253 2 Set_LCM_XY(13,0);
254 2 Send_Num_LCM(ledsed/100);
255 2 Send_Num_LCM((ledsed%100)/10);
256 2 Send_Num_LCM(ledsed%10);
257 2 }
258 1 }
259 //-----------------------------------------------------------------------------------
260 dis_emergency(){
261 1 Send_Command_LCM(0x01);
262 1 Set_LCM_XY(0,0);
263 1 Send_String_LCM("Now Emergency:");
264 1 Set_LCM_XY(0,1);
265 1 switch (cnt2){
266 2 case 1:{Send_String_LCM("All Red ");break;}
267 2 case 2:{Send_String_LCM("EW Stopped");break;}
268 2 case 3:{Send_String_LCM("NS Stopped");break;}
269 2 }
270 1
271 1 }
272 //-----------------------------------------------------------------------------------
273 dis_pause(){
274 1 if (upled) {
275 2 Send_Command_LCM(0x01);
276 2 Set_LCM_XY(0,0);
277 2 Send_String_LCM("Now Pause");
278 2 upled=0;
279 2 }
280 1
281 1 }
282 //-----------------------------------------------------------------------------------
283 void emergency(){
284 1 if (manage==0) {execute=0;return;}
285 1 if (!upled) return;
286 1
287 1 dis_emergency();
288 1 upled=0;
289 1 if (cnt2==1) {ns=0xfe;ew=0xfe;return;}
290 1 if (cnt2==2) {ns=0xdd;ew=0xfe;return;}
291 1 if (cnt2==1) {ns=0xfe;ew=0xdd;return;}
292 1
293 1
294 1 }
295 //------------------------------------------------------------------------------------
296 void pause(){
297 1 if (!execute) return;
298 1 discount++;
299 1 if (discount>=80) {d_pause=!d_pause;discount=0;}
300 1 if (d_pause) {ns=0xfb;ew=0xfb;}
301 1 else {ns=0xff;ew=0xff;}
302 1
303 1 }
C51 COMPILER V8.15 LCD_KEY_1 08/10/2008 20:26:24 PAGE 6
304 //------------------------------------------------------------------------------------
305 main(){
306 1 Init_LCM();
307 1 P1=0xf0;
308 1 Set_LCM_XY(0,0);
309 1 Send_String_LCM("Initing.");
310 1 //Set_LCM_XY(0,1);
311 1 TMOD=0x01;
312 1 TH0=0x3c;
313 1 TL0=0xb0;
314 1 ET0=1;
315 1 EA=1;
316 1 P2=0x00;
317 1 P3=0x00;
318 1 TR0=1;
319 1 while (1){
320 2 if (!getkey()) P1=0xf0;
321 2 chkkey(); //判断是否有键按下
322 2 if (getkey()) { //若有键按下
323 3 findkey(); //求键值
324 3 keyfun();
325 3 }
326 2 while (getkey()) {};
327 2 if (!execute) trafficlamp();
328 2
329 2 if (manage==0) distime();
330 2 if (manage==2) emergency();
331 2 if (manage==3) {pause();dis_pause();}
332 2
333 2 } //while(1)
334 1
335 1
336 1
337 1
338 1 } //main()
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1339 ----
CONSTANT SIZE = 294 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 28 3
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -