本人弄得 多級(jí)菜單 無(wú)限擴(kuò)展
單片機(jī)源程序如下:
- #include "delay.h"
- #include "12864.h"
- #include "fun.h"
- #include "key.h"
- #include "wakeup.h"
- u8 func_index=0;
- void (*current_operation_index)(); //執(zhí)行當(dāng)前顯示函數(shù)
- typedef struct
- {
- u8 current; //當(dāng)前狀態(tài)號(hào)
- u8 up;//向上翻索引號(hào)
- u8 down;//向下翻索引號(hào)
- u8 enter;//確認(rèn)索引號(hào)
- u8 num_ent;//編碼器確認(rèn)鍵
- void (*current_operation)(); //要執(zhí)行的函數(shù)
- } key_table;
- key_table table[21]=
- {
- {0,3,1,4,15,(*fun1)},//運(yùn)行狀態(tài)
- {1,0,2,6,1,(*fun2)}, //歷史記錄
- {2,1,3,10,2,(*fun3)},//版本信息
- {3,2,0,11,3,(*fun4)},//功能設(shè)置
- {4,5,5,15,4,(*fun5)},//運(yùn)行參數(shù)
- {5,4,4,0,5,(*fun6)}, //運(yùn)行時(shí)間
- {6,9,7,0,1,(*fun7)},//故障記錄
- {7,6,8,0,1,(*fun8)},//7天記錄
- {8,7,9,0,1,(*fun9)},//今年記錄
- {9,8,6,0,1,(*fun10)}, //往年記錄
- {10,0,0,0,2,(*fun11)},//版本信息
- {11,14,12,19,3,(*fun12)},//設(shè)置通訊地址
- {12,11,13,0,3,(*fun13)},//設(shè)置語(yǔ)言
- {13,12,14,0,3,(*fun14)}, //設(shè)置時(shí)間
- {14,13,11,0,3,(*fun15)},//更多
- {15,18,16,0,15,(*fun16)},//主畫面
- {16,15,17,0,15,(*fun17)},//輸入數(shù)據(jù)
- {17,16,18,0,15,(*fun18)}, //輸出數(shù)據(jù)
- {18,17,15,0,15,(*fun19)},//功率參數(shù)
- {19,17,15,0,11,(*fun20)},//通訊地址
- };
-
- int main(void)
- {
- u8 num;
- SystemInit(); //系統(tǒng)初始化
- delay_init(72); //延時(shí)初始化
- LCD12864_InitPort(); //端口初始化
- LCD12864_Init(); //液晶初始化
- Key_Init();//按鍵初始化
-
-
- // LCD12864_Pos(3,5);
- LCD12684_Wdat(0x35);
- while(1)
- {
- num=KEY_Scan();//得到鍵值
- if(num==3)
- // {
- // switch(num)
- // {
- // case 1:
- // func_index=table[func_index].up; break; //向上翻
- // case 2:
- // func_index=table[func_index].down; break; //向下翻
- // case 3:
- // func_index=table[func_index].enter; break; //確認(rèn)
- // case 4:
- // func_index=table[func_index].num_ent; break;
- // }
- // LCD12864_Clr(); //clear all dots
- // }
- // current_operation_index=table[func_index].current_operation;
- // (*current_operation_index)();//執(zhí)行當(dāng)前操作函數(shù)
- // }
- {
- delay_ms(500);
- Sys_Enter_Standby();
- }
-
- // if(KEY_Scan()==1)
- // {
- // RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
- //
- //
- //
- //
- //
- // }
- }
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
DIS12864 - 副本.rar
(289.68 KB, 下載次數(shù): 328)
2018-4-25 17:56 上傳
點(diǎn)擊文件名下載附件
好 下載積分: 黑幣 -5
|