stm32+st7920多级菜单源码的文件夹:
所有源码下载:
LCD 多级菜单.rar
(8.54 MB, 下载次数: 102)
主程序预览:
- #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)();//执行当前操作函数
- }
- }
-
复制代码
|