|
【LPC54100】第六周-菜单列表和模拟时钟
[复制链接]
本帖最后由 shower.xu 于 2015-5-20 16:27 编辑
先把所有帖子做个汇总:
【LPC54100】第一周-分享部分原理图和blink跑起
第一周2-添加一个小显示屏并驱动成功
【LPC54100】第二周-添加按键处理程序并在LCD上显示
【LPC54100】第三周-彩屏驱动并移植GUI
【LPC54100】第三周2-彩屏驱动并移植GUI
【LPC54100】第四周-状态机多任务实现
【LPC54100】第五周-串口下载中文字库到flash
【LPC54100】第六周-菜单列表和模拟时钟
搞了这么久,总算有个结局了。这是最后一篇,主要加入了列表式菜单和模拟时钟动画,抛砖引玉。
先上个效果图,模拟时钟
菜单按照结构体指针的方式实现,首先得有个结构体
- struct MenuItem
- {
- unsigned char menuCount; //?????÷
- unsigned char *displayString; //????×?·???
- void (*subs)(); //????
- struct MenuItem *childernMenus; //??????
- struct MenuItem *parentMenus; //×?????
- } MENU_NULL;
复制代码然后定义一堆结构体数组
- 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},
- };
- 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},
- };
- 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},
- };
- 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},
- };
- 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};
复制代码
菜单显示效果
下一步就是切换了
- 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)();
- }
- 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;
- }
- /* 菜单选择显示样式1 */
- // if ((UserChoose < DisplayStart) || (UserChoose >= (DisplayStart + 1 )))
- // {
- // DisplayStart = UserChoose;
- // }
- /* end */
- GUI_WinFromClr(&demow);
- Menu2Show();
- /* 滚动条显示 */
- GUI_ScorllBar(UserChoose,MenuPoint[0].menuCount);
- }
- }
复制代码这些就是根本,其它的包括初始化,退出和显示的函数见代码
效果
视频
代码
MenuList.rar
(802.81 KB, 下载次数: 95, 售价: 1 分芯积分)
|
|