找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4160|回复: 4
打印 上一主题 下一主题
收起左侧

stm32+st7920多级菜单源码

[复制链接]
跳转到指定楼层
楼主
stm32+st7920多级菜单源码的文件夹:


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


主程序预览:
  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.        
复制代码


评分

参与人数 1黑币 +18 收起 理由
songhetai + 18

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:166519 发表于 2017-2-24 23:49 | 只看该作者
我是初学者
回复

使用道具 举报

板凳
ID:152322 发表于 2017-7-16 01:26 | 只看该作者
多循环出现的多级菜单。这个要是菜单比较多,就比较麻烦了。
回复

使用道具 举报

地板
ID:660797 发表于 2019-12-10 17:11 | 只看该作者
不知道  工程  能不能直接通过编译,没有错误。
回复

使用道具 举报

5#
ID:412814 发表于 2020-1-15 17:20 | 只看该作者
谢谢楼主分享,学习了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表