打印
[文档下载]

菜单列表和模拟时钟

[复制链接]
637|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
仙女山|  楼主 | 2015-12-22 19:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
菜单按照结构体指针的方式实现,首先得有个结构体
struct MenuItem
{
    unsigned char menuCount;        //?????÷
    unsigned char *displayString;   //????×?·???
    void  (*subs)();                //????
    struct MenuItem *childernMenus; //??????
    struct MenuItem *parentMenus;   //×?????
}   MENU_NULL;


沙发
仙女山|  楼主 | 2015-12-22 19:54 | 只看该作者
然后定义一堆结构体数组
struct MenuItem MainMenu[4] =   
{        
    {4,(unsigned char *)"1.获取CPU频率   ",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"2.获取时间  ",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"3.波特率设置  ",&NULL_Function,Baudrate,&MENU_NULL},
    {4,(unsigned char *)"4.系统设置    ",&NULL_Function,&MENU_NULL,&MENU_NULL},
};
struct MenuItem MailMenu[4] =   
{        
    {4,(unsigned char *)"1.收件箱",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"2.发件箱",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"3.写新邮件",&NULL_Function,Baudrate,&MENU_NULL},
    {4,(unsigned char *)"4.邮箱设置",&NULL_Function,&MENU_NULL,&MENU_NULL},
};

使用特权

评论回复
板凳
仙女山|  楼主 | 2015-12-22 19:55 | 只看该作者
struct MenuItem CameraMenu[4] =   
{        
    {4,(unsigned char *)"1.拍照   ",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"2.摄像  ",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {4,(unsigned char *)"3.曝光设置  ",&NULL_Function,Baudrate,&MENU_NULL},
    {4,(unsigned char *)"4.存储设置    ",&NULL_Function,&MENU_NULL,&MENU_NULL},
};
struct MenuItem TimeMenu[3] =   
{        
    {3,(unsigned char *)"1.设置日期和时间",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"2.设置闹钟",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"3.设置日期格式",&NULL_Function,&MENU_NULL,&MENU_NULL},
};

使用特权

评论回复
地板
仙女山|  楼主 | 2015-12-22 19:55 | 只看该作者
struct MenuItem MusicMenu[3] =   
{        
    {3,(unsigned char *)"1.播放",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"2.暂停",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"3.歌曲列表",&NULL_Function,&MENU_NULL,&MENU_NULL},
};
struct MenuItem GameMenu[3] =   
{        
    {3,(unsigned char *)"1.俄罗斯方块",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"2.打砖块",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"3.贪吃蛇",&NULL_Function,&MENU_NULL,&MENU_NULL},               
};

使用特权

评论回复
5
仙女山|  楼主 | 2015-12-22 19:56 | 只看该作者
struct MenuItem SleepMenu[2] =   
{        
    {2,(unsigned char *)"1.进入休眠模式",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {2,(unsigned char *)"2.休眠设置",&NULL_Function,&MENU_NULL,&MENU_NULL},
};
struct MenuItem RadioMenu[3] =   
{        
    {3,(unsigned char *)"1.频道搜索",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"2.上一频道",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {3,(unsigned char *)"3.下一频道",&NULL_Function,&MENU_NULL,&MENU_NULL},
};

使用特权

评论回复
6
仙女山|  楼主 | 2015-12-22 19:57 | 只看该作者
struct MenuItem IapMenu[2] =   
{        
    {2,(unsigned char *)"1.开始IAP ",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {2,(unsigned char *)"2.结束IAP   ",&NULL_Function,&MENU_NULL,&MENU_NULL},        
};
struct MenuItem AboutMenu[2] =   
{        
    {2,(unsigned char *)"1.我是Shower.xu",&NULL_Function,&MENU_NULL,&MENU_NULL},
    {2,(unsigned char *)"2.谢谢大家",&NULL_Function,&MENU_NULL,&MENU_NULL},        
};
struct MenuItem *pMenuItem[10]={MainMenu,TimeMenu,MusicMenu,GameMenu,SleepMenu,RadioMenu,IapMenu,MainMenu,AboutMenu};

使用特权

评论回复
7
仙女山|  楼主 | 2015-12-22 19:57 | 只看该作者
void Menu2Process(void)
{
    if (key_status)
    {
        switch (key_status)
        {
            case KEY_UP_SHORT:
                UserChoose --;
                if (UserChoose < 0 )
                {
                    UserChoose = MaxItems - 1;
                }
                break;
            case KEY_DOWN_SHORT:
                UserChoose ++;
                if (UserChoose == MaxItems )
                {
                    UserChoose = 0;
                }
                break;
            case KEY_OK_SHORT:
                if ((MenuPoint[UserChoose].subs) != NULL_Function)
                {
                            (*MenuPoint[UserChoose].subs)();
                }

使用特权

评论回复
8
仙女山|  楼主 | 2015-12-22 19:58 | 只看该作者
if (MenuPoint[UserChoose].childernMenus != &MENU_NULL)
                {
                    MenuPoint          = MenuPoint[UserChoose].childernMenus;  
                    Option                 = UserChoose;
                    UserChoose          = 0;
                    DisplayStart = 0;
                }
                break;
             case KEY_CAL_SHORT:
                if (MenuPoint[0].parentMenus != &MENU_NULL )
                {                                 
                    MenuPoint          = MenuPoint[0].parentMenus;                        
                    DisplayStart = 0;
                    UserChoose   = Option;        
                }
                                else {Menu2Exit();return;}
                break;
        }

使用特权

评论回复
9
仙女山|  楼主 | 2015-12-22 19:59 | 只看该作者
/* 菜单选择显示样式1 */               
//        if ((UserChoose < DisplayStart) || (UserChoose >= (DisplayStart + 1 )))
//        {
//                           DisplayStart = UserChoose;
//        }
/*   end  */        
                                GUI_WinFromClr(&demow);
        Menu2Show();
                                /*  滚动条显示  */                                
                                GUI_ScorllBar(UserChoose,MenuPoint[0].menuCount);

    }
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

36

主题

340

帖子

2

粉丝