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)(); //执行当前操作函数

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

  • 相关阅读:
    要学习的东西~!~
    Concrete5官网
    PHP免费源码下载
    PHP源码下载1
    PHP源码下载
    PHP框架之ThinkPHP项目CMS内容管理系统源码及开发手册视频
    SELINUX导致数据修改权限不成功
    mysql参数安全设置
    大话存储(1-5)
    存储知识(4)
  • 原文地址:https://www.cnblogs.com/ht-beyond/p/3801725.html
Copyright © 2011-2022 走看看