📄 z12864.lst
字号:
258
259
260
261 //=====================================================================//
262 //函数:void UpDate_Menu(unsigned char First_Index,unsigned char Menu_Index, unsigned char ** Menu_List)
263 //描述:刷新整屏菜单显示函数
264 //参数:First_Index 当面显示页的第一条菜单号
265 // Menu_Index 当前处于选用的菜单项
266 // Menu_List 菜单资源链表指针
267 //返回:无
268 //注意:无
269 //=====================================================================//
270 void UpDate_Menu(unsigned char First_Index,unsigned char Menu_Index,unsigned char** Menu_List)
271 {
272 1 unsigned int y_width,y_Index;
273 1 unsigned char List_Num,i,x;
274 1 List_Num = (unsigned int)**Menu_List;
275 1 y_width = Y_WIDTH_MENU;
276 1 y_Index = 0;
277 1 while(First_Index>List_Num) First_Index = List_Num;
278 1 if(List_Num>Dis_Menu_Num) List_Num = Dis_Menu_Num;
279 1 if(First_Index_old!=First_Index)
280 1 {
281 2 lcdfill(WHITE); //清屏
282 2 if(y_Index_old==0xff)
283 2 {
284 3 rectfill(0,0,Dis_X_MAX, y_width-1,MENU_SELE_COLOR);
285 3 i=First_Index+1;
286 3 put_str_xy(x,y_Index,(unsigned char *)Menu_List[i++],MENU_FONT_COLOR);
287 3 y_Index = y_Index+Y_WIDTH_MENU;
288 3 for(;i<List_Num+1;i++)
289 3 {
290 4 put_str_xy(x,y_Index,(unsigned char *)Menu_List[i],MENU_SELF_COLOR) ;
291 4 y_Index = y_Index+Y_WIDTH_MENU;
292 4 }
293 3 }
294 2 else
295 2 {
296 3 y_Index_old = Menu_Index-First_Index;
297 3 rectfill(0,y_Index_old*Y_WIDTH_MENU,Dis_X_MAX,
298 3 y_Index_old*Y_WIDTH_MENU+Y_WIDTH_MENU-1,WHITE);
299 3 i=First_Index+1;
300 3 while(List_Num)
301 3 {
302 4 if((i-1)==Menu_Index) put_str_xy(x,y_Index,(unsigned char *)Menu_List[i],MENU_FONT_COLOR);
303 4 else put_str_xy(x,y_Index,(unsigned char *)Menu_List[i],MENU_SELF_COLOR);
C51 COMPILER V8.08 Z12864 12/07/2007 16:07:50 PAGE 6
304 4 y_Index = y_Index+Y_WIDTH_MENU;
305 4 i++;
306 4 List_Num--;
307 4 }
308 3 }
309 2 First_Index_old = First_Index;
310 2 }
311 1 else
312 1 {
313 2 y_Index = y_Index_old-First_Index_old;
314 2 y_Index = y_Index*Y_WIDTH_MENU;
315 2
316 2 rectfill(0,y_Index,Dis_X_MAX, y_Index+Y_WIDTH_MENU-1,MENU_BACK_COLOR);
317 2 put_str_xy(x,y_Index,(unsigned char *)Menu_List[y_Index_old+1],MENU_SELF_COLOR);
318 2 y_Index = Menu_Index-First_Index;
319 2 y_Index = y_Index*Y_WIDTH_MENU;
320 2 rectfill(0, y_Index,Dis_X_MAX, y_Index+Y_WIDTH_MENU-1,MENU_SELE_COLOR);
321 2 put_str_xy(x,y_Index,(unsigned char *)Menu_List[Menu_Index+1],MENU_FONT_COLOR);
322 2 }
323 1
324 1 y_Index_old = Menu_Index;
325 1 }
326
327
328 //=====================================================================//
329 void Redraw_Menu(unsigned char First_Index,unsigned char Menu_Index,unsigned char** Menu_List)
330 {
331 1 // unsigned char *Menu_Config;
332 1 //First_Index_old=0xff;
333 1 UpDate_Menu(First_Index,Menu_Index,Menu_List);
334 1 }
335 //=====================================================================//
336
337
338 //初始化
339 void lcdreset()
340 { lcdwc1(LCD_CMD_ON);
341 1 lcdwc2(LCD_CMD_ON); //开显示
342 1 lcdwc1(LCD_CMD_STARTLINE);
343 1 lcdwc2(LCD_CMD_STARTLINE); //设置显示初始行
344 1 }
345
346
347
348
349
350
351
352 //初始化菜单
353 void Init_Menu (unsigned char* Menu_List)
354 {
355 1
356 1 UpDate_Menu(0,0,Menu_List);
*** WARNING C182 IN LINE 356 OF Z12864.C: pointer to different objects
357 1
358 1 }
359
360 //=====================================================================//
361 //函数:unsigned char GetMLNum(unsigned char ** Menu_List)
362 //描述:获取菜单资源的菜单项个数函数
363 //参数: Menu_List 菜单资源链表指针
364 //返回:菜单项个数
C51 COMPILER V8.08 Z12864 12/07/2007 16:07:50 PAGE 7
365 //注意:无
366 //=====================================================================//
367
368 unsigned char GetMLNum(unsigned char **Menu_List)
369 {
370 1 unsigned char uiTemp;
371 1 uiTemp = (unsigned char)**Menu_List;
372 1 return uiTemp-1;
373 1 }
374
375 //=====================================================================//
376 //函数:unsigned char GetMLiNum_Page(unsigned char ** Menu_List)
377 //描述:获取菜单资源在一屏可以显示的菜单项个数函数
378 //参数: Menu_List 菜单资源链表指针
379 //返回:菜单项个数
380 //注意:无
381 //===================================================== //
382 unsigned char GetMLiNum_Page(unsigned char** Menu_List)
383 {
384 1 unsigned char uiTemp;
385 1 unsigned char *Menu_Config;
386 1 Menu_Config = (unsigned char *)(Menu_List[0]);
387 1 uiTemp = *(Menu_Config+3);
388 1 uiTemp = (Dis_Y_MAX+1)/uiTemp; //
389 1 return uiTemp;
390 1 }
391
392
393 void Show_DotTest()
394 {
395 1 unsigned char i;
396 1 lcdfill(WHITE);
397 1 for(i=0;i<100;i++)
398 1 {
399 2 pointxy(i*3,i*i,1);
400 2 }
401 1 }
402
403 void Show_LineTest()
404 {
405 1
406 1 unsigned char uikey,key_flag;
407 1 lcdfill(WHITE);
408 1 for(i=1;i<10;i++)
*** ERROR C202 IN LINE 408 OF Z12864.C: 'i': undefined identifier
409 1 {
410 2 linexy(0,0,100,11*i,1);
*** ERROR C202 IN LINE 410 OF Z12864.C: 'i': undefined identifier
411 2 }
412 1 }
413 void Show_RectangleTest()
414 {
415 1 unsigned char i;
416 1 lcdfill(WHITE);
417 1 for(i=1;i<40;i++)
418 1 {
419 2 rect(i,i,i*2,i*2,1);
420 2 }
421 1
422 1 }
423 /* void Show_HelpTest();
424 {
C51 COMPILER V8.08 Z12864 12/07/2007 16:07:50 PAGE 8
425 put_str_xy(0,0,)
426 }
427 */
428
429
430 main()
431
432 {
433 1 unsigned char uiKey=0;
434 1 unsigned char Item_Num,Update_Flag,Enter_Flag=0;
435 1 unsigned char PageItem_Num;
436 1 unsigned char First_Index=0,Active_Index=0,Temp_Index=0;
437 1
438 1 // Key_Initial(); //键盘扫描初始化(端口)
439 1 // LCD_Init(); //初始化LCD
440 1 Item_Num = GetMLNum(Menu_List01); //获取要显示的菜单的菜单项个数
441 1 PageItem_Num = GetMLiNum_Page((unsigned char **)Menu_List01);//获取显示的菜单的页数
442 1 Init_Menu((unsigned char**)Menu_List01);
443 1 while(1)
444 1 {
445 2 uiKey = Key; //获取键值
446 2 if(uiKey) //如有键按下则响应
447 2 {
448 3 switch(uiKey) //判断键值进行分支控制界面
449 3 {
450 4 case ENTER: //确定键按下
451 4 Enter_Flag=1; //enter flag set
452 4 break;
453 4 case DOWN: //down 向下键按下
454 4 if(Active_Index<Item_Num)
455 4 {
456 5 Active_Index++;
457 5 if(Temp_Index<PageItem_Num-1) Temp_Index++;
458 5 else if(First_Index<Item_Num) First_Index++;
459 5 Update_Flag = 1;
460 5 }
461 4 break;
462 4 case UP: //up 向上键按下
463 4 if(Active_Index>0)
464 4 {
465 5 Active_Index--;
466 5 if(Temp_Index>0) Temp_Index--;
467 5 else if(First_Index>0) First_Index--;
468 5 Update_Flag = 1;
469 5 }
470 4 break;
471 4 default:break;
472 4 }
473 3 }
474 2 if(Update_Flag) //Update_Flag 为1时刷新菜单
475 2 {
476 3 UpDate_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
477 3 Update_Flag=0;
478 3 }
479 2 if(Enter_Flag) //有确定键按下时,则进入相应的功能函数
480 2 {
481 3 Enter_Flag = 0;
482 3 switch(Active_Index)
483 3 {
484 4 case 0: //”绘点”菜单项
485 4 Show_DotTest();
486 4 Redraw_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
C51 COMPILER V8.08 Z12864 12/07/2007 16:07:50 PAGE 9
487 4 Update_Flag = 1;
488 4 break;
489 4 case 1: //”绘直线”菜单项
490 4 Show_LineTest();
491 4 Redraw_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
492 4 Update_Flag = 1;
493 4 break;
494 4 case 2: //”绘矩形”菜单项
495 4 Show_RectangleTest();
496 4 Redraw_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
497 4 Update_Flag = 1;
498 4 break;
499 4 case 3: //进入二级菜单
500 4 // CharTest_Menu();
501 4 Redraw_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
502 4 Update_Flag = 1;
503 4 break;
504 4 case 4: //”帮助”菜单项
505 4 Show_HelpTest();
506 4 Redraw_Menu(First_Index,Active_Index,(unsigned char**)Menu_List01);
507 4 Update_Flag = 1;
508 4 break;
509 4 default:break;
510 4 }
511 3 }
512 2 // KeyScan_Service(); //键盘扫描的服务程序,最好在1KHz的定时/时基中断调用
513 2 }
514 1 }
515
516
C51 COMPILATION COMPLETE. 1 WARNING(S), 2 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -