本人弄得 多級菜單 無限擴展
單片機源程序如下:
- #include "delay.h"
- #include "12864.h"
- #include "fun.h"
- #include "key.h"
- #include "wakeup.h"
- u8 func_index=0;
- void (*current_operation_index)(); //執行當前顯示函數
- typedef struct
- {
- u8 current; //當前狀態號
- u8 up;//向上翻索引號
- u8 down;//向下翻索引號
- u8 enter;//確認索引號
- u8 num_ent;//編碼器確認鍵
- void (*current_operation)(); //要執行的函數
- } key_table;
- key_table table[21]=
- {
- {0,3,1,4,15,(*fun1)},//運行狀態
- {1,0,2,6,1,(*fun2)}, //歷史記錄
- {2,1,3,10,2,(*fun3)},//版本信息
- {3,2,0,11,3,(*fun4)},//功能設置
- {4,5,5,15,4,(*fun5)},//運行參數
- {5,4,4,0,5,(*fun6)}, //運行時間
- {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)},//設置通訊地址
- {12,11,13,0,3,(*fun13)},//設置語言
- {13,12,14,0,3,(*fun14)}, //設置時間
- {14,13,11,0,3,(*fun15)},//更多
- {15,18,16,0,15,(*fun16)},//主畫面
- {16,15,17,0,15,(*fun17)},//輸入數據
- {17,16,18,0,15,(*fun18)}, //輸出數據
- {18,17,15,0,15,(*fun19)},//功率參數
- {19,17,15,0,11,(*fun20)},//通訊地址
- };
-
- int main(void)
- {
- u8 num;
- SystemInit(); //系統初始化
- delay_init(72); //延時初始化
- 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; //確認
- // 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)();//執行當前操作函數
- // }
- {
- delay_ms(500);
- Sys_Enter_Standby();
- }
-
- // if(KEY_Scan()==1)
- // {
- // RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
- //
- //
- //
- //
- //
- // }
- }
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
DIS12864 - 副本.rar
(289.68 KB, 下載次數: 328)
2018-4-25 17:56 上傳
點擊文件名下載附件
好 下載積分: 黑幣 -5
|