标题: stm32+st7920多级菜单源码 [打印本页]

作者: wufeng555    时间: 2016-12-10 13:56
标题: stm32+st7920多级菜单源码
stm32+st7920多级菜单源码的文件夹:


所有源码下载:
LCD 多级菜单.rar (8.54 MB, 下载次数: 103)


主程序预览:
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "usart.h"
  4. #include "led.h"
  5. #include "key.h"
  6. #include "LCD12864.h"
  7. #include "fun.h"

  8. u8  func_index=3;//默认初始画面为fun15;
  9. //定义各个数据
  10. u16 UDC,IDC,Uab,Ubc,Uca,Ia,Ib,Ic,PowerHigh,PowerLow,ReactivePowerHigh,ReactivePowerLow,State,
  11.                 OutMode,Frequency,PF,CodeHigh,CodeLow,TEMP,TempA,
  12.     TempB,TempC,Version,DailyEnergyHigh,DailyEnergyLow,Reg27,Reg28,Reg29,Reg30,Reg31,
  13.     Reg32,Reg33,Reg34,Reg35,Reg36,Reg37,Reg38,Reg39,Reg40,Reg42,Reg43,Reg44,Reg45,Reg46,Reg47,Reg48,\
  14.     Reg49;
  15. u32 Power,ReactivePower,DailyEnergy;


  16. void (*current_operation_index)(); //执行当前显示函数
  17. typedef struct
  18.    {
  19.         u8 current;        //当前状态号
  20.         u8  up;//向上翻索引号
  21.         u8 down;//向下翻索引号
  22.         u8 enter;//确认索引号
  23.         u8 num_ent;//编码器确认键
  24.         void (*current_operation)(); //要执行的函数
  25.         } key_table;


  26.          key_table table[21]=
  27. {
  28.   {0,3,1,4,15,(*fun1)},//运行状态
  29.         {1,0,2,6,1,(*fun2)}, //历史记录
  30.         {2,1,3,10,2,(*fun3)},//版本信息
  31.         {3,2,0,11,3,(*fun4)},//功能设置
  32.         {4,5,5,15,4,(*fun5)},//运行参数
  33.         {5,4,4,0,5,(*fun6)}, //运行时间
  34.         {6,9,7,0,1,(*fun7)},//故障记录
  35.         {7,6,8,0,1,(*fun8)},//7天记录
  36.         {8,7,9,0,1,(*fun9)},//今年记录
  37.         {9,8,6,0,1,(*fun10)}, //往年记录
  38.         {10,0,0,0,2,(*fun11)},//版本信息
  39.         {11,14,12,19,3,(*fun12)},//设置通讯地址
  40.         {12,11,13,0,3,(*fun13)},//设置语言
  41.         {13,12,14,0,3,(*fun14)}, //设置时间
  42.         {14,13,11,0,3,(*fun15)},//更多
  43.         {15,18,16,0,15,(*fun16)},//主画面
  44.         {16,15,17,0,15,(*fun17)},//输入数据
  45.         {17,16,18,0,15,(*fun18)}, //输出数据
  46.         {18,17,15,0,15,(*fun19)},//功率参数
  47.         {19,17,15,0,11,(*fun20)},//通讯地址
  48. };
  49.        








  50. int main(void)
  51. {
  52.         u8 Key_num;
  53.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
  54.         delay_init(168);    //初始化延时函数
  55.         uart_init(115200);        //初始化串口波特率为115200
  56.        
  57.         LED_Init();                                        //初始化LED
  58.         KEY_Init();                                 //按键初始化
  59.        
  60.         LCD12864_InitPort();
  61.         LCD12864_Init();

  62. while(1)
  63. {       

  64. //        LED1=!LED1;

  65.                 Key_num=KEY_Scan(0);
  66.                 if(Key_num)
  67.                 {
  68.                         switch(Key_num)
  69.                         {
  70.                                 case 1:
  71.                                         func_index=table[func_index].up;        break;//向上翻
  72.                                 case 2:
  73.                                         func_index=table[func_index].down;        break;//向下翻
  74.                                 case 3:
  75.                                         func_index=table[func_index].enter;        break;//确定
  76.                                 case 4:
  77.                                         func_index=table[func_index].num_ent;        break;                       
  78.                         }
  79.                 LCD12864_Clr();//清屏
  80.                 }
  81.                 current_operation_index=table[func_index].current_operation;
  82.                 (*current_operation_index)();//执行当前操作函数
  83. }



  84. }
  85.        
复制代码



作者: nanhaisunxc    时间: 2017-2-24 23:49
我是初学者
作者: xiaoquan888    时间: 2017-7-16 01:26
多循环出现的多级菜单。这个要是菜单比较多,就比较麻烦了。
作者: wuzhenchuang    时间: 2019-12-10 17:11
不知道  工程  能不能直接通过编译,没有错误。
作者: jifengjianwu    时间: 2020-1-15 17:20
谢谢楼主分享,学习了。




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1