📄 main.lst
字号:
216
217 void LcdInit(void)
218 {
219 1 delay_num=0;
220 1 while(delay_num<15) //15ms
221 1 {;}
222 1
223 1 /* 写指令0x38连续3次, 不检测忙信号*/
224 1 LcdWriteCmd( 0x38 ); //1
225 1 delay_num=0;
226 1 while(delay_num<5) //5ms
227 1 {;}
228 1 LcdWriteCmd( 0x38 ); //2
229 1 delay_num=0;
230 1 while(delay_num<5) //5ms
231 1 {;}
232 1 LcdWriteCmd( 0x38 ); //3
233 1
234 1 /* 以后的读写操作均要判断忙信号 */
235 1 DetectBusy();
236 1 LcdWriteCmd( 0x38 );
237 1
238 1 /* 先设置关屏 */
239 1 DetectBusy();
240 1 LcdWriteCmd( 0x08 );
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 5
241 1
242 1 /* 清屏 */
243 1 DetectBusy();
244 1 LcdWriteCmd( 0x01 );
245 1
246 1 /* 设置光标显示模式 */
247 1 DetectBusy();
248 1 LcdWriteCmd( 0x06 );
249 1
250 1 /* 开屏并显示光标 */
251 1 DetectBusy();
252 1 LcdWriteCmd( 0x0F );
253 1 }
254
255 void LocateXY(char x , char y)
256 {
257 1 unsigned char temp;
258 1 temp = x & 0x0f;
259 1 y &= 0x01;
260 1 if ( y ) temp |= 0x40;
261 1 temp |= 0x80;
262 1 DetectBusy();
263 1 LcdWriteCmd(temp);
264 1
265 1 }
266
267 void PutChar(char x , char y , char value)
268 {
269 1 LocateXY(x,y);
270 1 delay_num=0;
271 1 while(delay_num<5)
272 1 {;}
273 1 DetectBusy();
274 1 LcdWriteData(value);
275 1 }
276
277 void PutStr(char x , char y , char* str)
278 {
279 1 unsigned char i,len=0;
280 1 // 计算字符串长度
281 1 while (str[len] >31)
282 1 len++;
283 1 //显示字符串
284 1 for (i=0;i<len;i++)
285 1 {
286 2 PutChar(x++,y,str[i]);
287 2 if ( x == 16 )
288 2 {
289 3 x = 0; y = 1;
290 3 }
291 2 }
292 1 }
293
294 void SelectedKeyShow(unsigned char keynum, unsigned char showid)
295 {
296 1 switch(keynum)
297 1 {
298 2 case 1:
299 2 if (showid==0)
300 2 {
301 3 PutStr(0,0,"Boil Water Order");
302 3 PutStr(0,1," Wait For Reply ");
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 6
303 3 }
304 2 else if(showid==1)
305 2 {
306 3 PutStr(0,0,"Boiling Water...");
307 3 PutStr(0,1,"Wait For Working");
308 3 }
309 2 else if(showid==2)
310 2 {
311 3 PutStr(0,0,"Boil Water is OK");
312 3 PutStr(0,1," Wait For Press ");
313 3 }
314 2 break;
315 2 case 2:
316 2 if (showid==0)
317 2 {
318 3 PutStr(0,0,"Now Coffee Order");
319 3 PutStr(0,1," Wait For Reply ");
320 3 }
321 2 else if(showid==1)
322 2 {
323 3 PutStr(0,0,"Making Coffee...");
324 3 PutStr(0,1,"Wait For Working");
325 3 }
326 2 else if(showid==2)
327 2 {
328 3 PutStr(0,0,"Now Coffee is OK");
329 3 PutStr(0,1," Wait For Press ");
330 3 }
331 2 break;
332 2 case 3:
333 2 if (showid==0)
334 2 {
335 3 PutStr(0,0,"Make Clean Order");
336 3 PutStr(0,1," Wait For Reply ");
337 3 }
338 2 else if(showid==1)
339 2 {
340 3 PutStr(0,0,"Making Clean....");
341 3 PutStr(0,1,"Wait For Working");
342 3 }
343 2 else if(showid==2)
344 2 {
345 3 PutStr(0,0,"Make Clean is OK");
346 3 PutStr(0,1," Wait For Press ");
347 3 }
348 2 break;
349 2 case 4:
350 2 if (showid==0)
351 2 {
352 3 PutStr(0,0,"Make Dirty Order");
353 3 PutStr(0,1," Wait For Reply ");
354 3 }
355 2 else if(showid==1)
356 2 {
357 3 PutStr(0,0,"Making Dirty....");
358 3 PutStr(0,1,"Wait For Working");
359 3 }
360 2 else if(showid==2)
361 2 {
362 3 PutStr(0,0,"Make Dirty is OK");
363 3 PutStr(0,1," Wait For Press ");
364 3 }
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 7
365 2 break;
366 2 case 5:
367 2 if (showid==0)
368 2 {
369 3 PutStr(0,0,"Make Steam Order");
370 3 PutStr(0,1," Wait For Reply ");
371 3 }
372 2 else if(showid==1)
373 2 {
374 3 PutStr(0,0,"Making Steam....");
375 3 PutStr(0,1,"Wait For Working");
376 3 }
377 2 else if(showid==2)
378 2 {
379 3 PutStr(0,0,"Make Steam is OK");
380 3 PutStr(0,1," Wait For Press ");
381 3 }
382 2 break;
383 2 case 6:
384 2 if (showid==0)
385 2 {
386 3 PutStr(0,0,"Make Reset Order");
387 3 PutStr(0,1," Wait For Reply ");
388 3 }
389 2 else if(showid==1)
390 2 {
391 3 PutStr(0,0,"Making Reset....");
392 3 PutStr(0,1,"Wait For Working");
393 3 }
394 2 else if(showid==2)
395 2 {
396 3 PutStr(0,0,"Make Reset is OK");
397 3 PutStr(0,1," Wait For Press ");
398 3 }
399 2 break;
400 2 default:
401 2 break;
402 2 }
403 1 }
404
405
406 unsigned char Key_Scan(void)
407 {
408 1 P3MDOUT|=0x0e;
409 1 P0MDOUT|=0x03;
410 1 Key1=1;
411 1 Key2=1;
412 1 Key3=1;
413 1 Key4=1;
414 1 Key5=1;
415 1
416 1 Key1=0;
417 1 Key2=0;
418 1
419 1 P3MDOUT&=0xf1;
420 1 P0MDOUT&=0xfc;
421 1 if (!(Key3&Key4&Key5)) //全部扫描
422 1 {
423 2 delay_num=0; //防抖
424 2 while(delay_num<100)
425 2 {;}
426 2
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 8
427 2 if(!(Key3&Key4&Key5)) //再次全部扫描
428 2 {
429 3
430 3 P3MDOUT|=0x0e;
431 3 P0MDOUT|=0x03;
432 3 Key1=1; //第一行
433 3 Key2=0;
434 3 Key3=1;
435 3 Key4=1;
436 3 Key5=1;
437 3 P3MDOUT&=0xf1;
438 3 P0MDOUT&=0xfc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -