zoukankan      html  css  js  c++  java
  • 12864显示菜单处理编程

    最近费了一些时间,终于会用结构体写一些多级菜单了。

    void (*current_operation_index)();
    uchar func_index=0;

     这是我定义的结构体:

    typedef struct
    {
    uchar current;        //当前状态
    uchar up;          //这是向上翻页
    uchar down;         //向下翻页

    uchar enter;         //选中确定

    uchar cancel;        //后退
    void (*current_operation)(); //要执行的函数
    }key_table;

    接下的各层数字要自己根据所写的函数自己排序,分清逻辑就很好弄的。

    key_table code table[10]=
    {
    {0,1,0,1,0,(*display0)}, //current up down enter cancel
    {1,3,2,1,0,(*display1)},
    {2,1,3,2,0,(*display2)},
    {3,2,4,3,0,(*display3)},
    {4,3,5,4,0,(*display4)},
    {5,4,1,6,0,(*display5)},
    {6,6,6,6,5,(*display6)},

    ..........
    };

    主函数里:

    keynum=newkeyscan();
    switch(keynum)
    {
    case 0: func_index=table[func_index].enter;lcd_fill(); break; //回车
    case 1: func_index=table[func_index].cancel;lcd_fill(); break;//后退
    case 2: func_index=table[func_index].down;lcd_fill(); break; //向下翻
    case 3: func_index=table[func_index].up;lcd_fill(); break; //向上翻
    case 4:
    case 5:
    case 6:
    case 7:
    default: break;
    }

    current_operation_index=table[func_index].current_operation;
    (*current_operation_index)(); //执行当前操作函数

    好了,有了这些基本的其他的就很好写了。

  • 相关阅读:
    Mysql常见索引介绍
    Mysql字段修饰符(约束)
    使用select和show命令查看mysql数据库系统信息
    Mysql5.7数据库介绍
    对Mysql数据表本身进行操作
    各种修改Mysql字符集
    Mysql的安全配置向导命令mysql_secure_installation
    firewalld介绍
    CentOS7使用yum安装mysql5.7
    利用ASP.NET一般处理程序动态生成Web图像(转)
  • 原文地址:https://www.cnblogs.com/ht-beyond/p/3801725.html
Copyright © 2011-2022 走看看