stm32+st7920多級菜單源碼的文件夾:
0.png (63.71 KB, 下載次數: 86)
下載附件
2017-1-7 17:01 上傳
所有源碼下載:
LCD 多級菜單.rar
(8.54 MB, 下載次數: 103)
2016-12-10 13:56 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
主程序預覽:
- #include "sys.h"
- #include "delay.h"
- #include "usart.h"
- #include "led.h"
- #include "key.h"
- #include "LCD12864.h"
- #include "fun.h"
- u8 func_index=3;//默認初始畫面為fun15;
- //定義各個數據
- u16 UDC,IDC,Uab,Ubc,Uca,Ia,Ib,Ic,PowerHigh,PowerLow,ReactivePowerHigh,ReactivePowerLow,State,
- OutMode,Frequency,PF,CodeHigh,CodeLow,TEMP,TempA,
- TempB,TempC,Version,DailyEnergyHigh,DailyEnergyLow,Reg27,Reg28,Reg29,Reg30,Reg31,
- Reg32,Reg33,Reg34,Reg35,Reg36,Reg37,Reg38,Reg39,Reg40,Reg42,Reg43,Reg44,Reg45,Reg46,Reg47,Reg48,\
- Reg49;
- u32 Power,ReactivePower,DailyEnergy;
- 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 Key_num;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設置系統中斷優先級分組2
- delay_init(168); //初始化延時函數
- uart_init(115200); //初始化串口波特率為115200
-
- LED_Init(); //初始化LED
- KEY_Init(); //按鍵初始化
-
- LCD12864_InitPort();
- LCD12864_Init();
- while(1)
- {
- // LED1=!LED1;
- Key_num=KEY_Scan(0);
- if(Key_num)
- {
- switch(Key_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();//清屏
- }
- current_operation_index=table[func_index].current_operation;
- (*current_operation_index)();//執行當前操作函數
- }
- }
-
復制代碼
|