這是一個(gè)12864菜單程序包 12864引索法寫多級菜單, 為什么我的KIL4不能編程
源碼下載:
12864多級菜單例子 (1).zip
(55.42 KB, 下載次數(shù): 249)
2016-12-7 15:23 上傳
點(diǎn)擊文件名下載附件
12864引索法
主程序:
- /***************************************************************************
- 原創(chuàng)重慶三峽學(xué)院創(chuàng)新實(shí)驗(yàn)室唐老鴨
- ***************************************************************************/
- #include <reg52.h>
- #include "fun.h"
- #include "lcd12864.h"
- #include "delay.h"
- #define uchar unsigned char
- sbit keydown=P0^0;
- sbit keyenter=P0^1;
- sbit keyup=P0^2;
- uchar func_index=0;
- void (*current_operation_index)();
- typedef struct
- {
- uchar current;
- uchar up;//向上翻索引號
- uchar down;//向下翻索引號
- uchar enter;//確認(rèn)索引號
- void (*current_operation)();
- } key_table;
- key_table code table[30]=
- {
- {0,3,1,4,(*fun1)},//第一層,顯示 【清華大學(xué)】、北京大學(xué)、重慶三峽學(xué)院 、返回
- {1,0,2,8,(*fun2)},//第一層,顯示 清華大學(xué)、【北京大學(xué)】、重慶三峽學(xué)院 、返回
- {2,1,3,12,(*fun3)},//第一層,顯示 清華大學(xué)、北京大學(xué)、【重慶三峽學(xué)院】 、返回
- {3,2,0,25,(*fun4)},//第一層,顯示 清華大學(xué)、北京大學(xué)、重慶三峽學(xué)院 、【返回】
- {4,7,5,16,(*fun5)},//第二層,清華大學(xué)層下顯示 【地點(diǎn)】、創(chuàng)建時(shí)間、簡介、返回
- {5,4,6,17,(*fun6)},//第二層,清華大學(xué)層下顯示 地點(diǎn)、【創(chuàng)建時(shí)間】、簡介、返回
- {6,5,7,18,(*fun7)}, //第二層,清華大學(xué)層下顯示 地點(diǎn)、創(chuàng)建時(shí)間、【簡介】、返回
- {7,6,4,0,(*fun8)},//第二層,清華大學(xué)層下顯示 地點(diǎn)、創(chuàng)建時(shí)間、簡介、【返回】
- {8,11,9,19,(*fun9)},//第二層,北京大學(xué)層下顯示 【歷史】、政治、簡介、返回
- {9,8,10,20,(*fun10)},//第二層,北京大學(xué)層下顯示 歷史、【政治】、簡介、返回
- {10,9,11,21,(*fun11)}, //第二層,北京大學(xué)層下顯示 歷史、政治、【簡介】、返回
- {11,10,8,1,(*fun12)},//第二層,北京大學(xué)層下顯示 歷史、政治、簡介、【返回】
- {12,15,13,22,(*fun13)},//第二層,重慶三峽學(xué)院層下顯示 【簡介】、最佳院系、最佳實(shí)驗(yàn)室、返回
- {13,12,14,23,(*fun14)}, //第二層,重慶三峽學(xué)院層下顯示 簡介、【最佳院系】、最佳實(shí)驗(yàn)室、返回
- {14,13,15,24,(*fun15)}, //第二層,重慶三峽學(xué)院層下顯示 簡介、最佳院系、【最佳實(shí)驗(yàn)室】、返回
- {15,14,12,2,(*fun16)}, //第二層,重慶三峽學(xué)院層下顯示 簡介、最佳院系、最佳實(shí)驗(yàn)室、【返回】
- {16,16,16,4,(*fun17)}, //第三層,清華大學(xué)地點(diǎn)層
- {17,17,17,5,(*fun18)}, //第三層,清華大學(xué)創(chuàng)時(shí)間層
- {18,18,18,6,(*fun19)}, //第三層,清華大學(xué)簡介層
- {19,19,19,8,(*fun20)}, //第三層,北京大學(xué)歷史層
- {20,20,20,9,(*fun21)}, //第三層,北京大學(xué)政治層
- {21,21,21,10,(*fun22)}, //第三層,北京大學(xué)簡介層
- {22,22,22,12,(*fun23)}, //第三層,重慶三峽學(xué)院簡介層
- {23,23,23,13,(*fun24)}, //第三層,重慶三峽學(xué)院最佳院系層
- {24,24,24,14,(*fun25)}, //第三層,重慶三峽學(xué)院最佳實(shí)驗(yàn)室層
- {25,25,25,0,(*fun26)}, //第0層
-
- };
- void main()
- {
- init_lcd(); //初始化LCD模塊
- while(1)
- {
- /*******************find index****************************/
- if((keyup==0)||(keydown==0)||(keyenter==0))
- {
- delay(10);//消抖
- if(keyup==0)
- {
- func_index=table[func_index].up; //向上翻
- while(!keyup);//松手檢測
- }
- if(keydown==0)
- {
- func_index=table[func_index].down; //向下翻
- while(!keydown);
- }
- if(keyenter==0)
- {
- func_index=table[func_index].enter; //確認(rèn)
- while(!keyenter);
- }
- init_lcd();
- }
- current_operation_index=table[func_index].current_operation;
- (*current_operation_index)();//執(zhí)行當(dāng)前操作函數(shù)
- }
- }
復(fù)制代碼
|