- #include "lcd12864.h"
- #include "key.h"
- #include "menu.h"
- #include "delay.h"
- static const unsigned char FunctionMiMa[] = "123456";
- static const unsigned char SuperMiMa[] = "111111";
- static PT_Menu g_pt_MenuHead = NULL;
- static PT_Menu g_pt_CurrentMenu = NULL;
- static int StrCmp(char *Source, char *Dist)
- {
- int i =0;
- if(Source == NULL || Dist == NULL)
- return -1;
- while(1){
- if (Source[i] != Dist[i]){
- break;
- }
- if(Source[i] == '\0')
- return 0;
- i++;
- }
- return 1;
- }
- static void RegisterPage(PT_Menu pt_Menu)
- {
- PT_Menu pt_Temp;
-
- pt_Menu->pt_Next = NULL;
- if(g_pt_MenuHead == NULL){
- g_pt_MenuHead = pt_Menu;
- }
- else{
- pt_Temp = g_pt_MenuHead;
-
- while(pt_Temp->pt_Next != NULL){
- pt_Temp = pt_Temp->pt_Next;
- }
-
- pt_Temp->pt_Next = pt_Menu;
- }
- }
- static PT_Menu GetMenu(char *pc_name)
- {
- PT_Menu pt_Temp;
- pt_Temp = g_pt_MenuHead;
- while(pt_Temp){
- if(StrCmp(pt_Temp->name,pc_name) == 0){
- return pt_Temp;
- }
- else{
- pt_Temp = pt_Temp->pt_Next;
- }
- }
- return NULL;
- }
- PT_Menu GetCurrentMenu(void)
- {
- return g_pt_CurrentMenu;
- }
- void SetCurrentMenu(PT_Menu pt_Menu)
- {
- g_pt_CurrentMenu = pt_Menu;
- }
- static unsigned char Verify(unsigned char *CheckMiMa){
- char MiMa[7];
- unsigned char Key = 20;
- char i=0;LCD_Clear();
- LCD_ShowString(1,1,12,"请输入密码: "); //????????LCD12864?????
- for(i=0; i<6; i++){
- delay_ms(1000);
- do{
- Key = Key_Service();
- }while(10 <= Key);
- LCD_ShowString(2,i,1,"X");
- MiMa[i] = Key + '0';
- }
- MiMa[i] = '\0';
- if(StrCmp(MiMa, CheckMiMa) == 0)
- return 1;
- return 0;
- }
- static void DrawMainMenu(void)
- {
- LCD_Clear();
- LCD_ShowString(1,0,16,"XXXXXXXXXXXXXXXX"); //????????LCD12864?????
- LCD_ShowString(2,6,4,"正\xfd常\xfd");
- LCD_ShowString(3,4,8," DC1:OUT");
- LCD_ShowString(4,0,4,"0591");
- LCD_ShowString(4,3,4,"自动");
- LCD_ShowString(4,5,6,"DC2:IN");
- }
- static PT_Menu MainMenuRun(void)
- {
- unsigned char Key = 20;
- while(1){
- do{
- Key = Key_Service();
- }while(20 == Key);
- if(11 == Key){
- delay_ms(3000);
- Key = Key_Service();
- if(11 == Key){
- if(Verify(FunctionMiMa))
- return GetMenu("Function");
- }
- }
- }
- return NULL;
- }
- static T_Menu MainMenu = {"Main", MainMenuRun, DrawMainMenu};
- static void DrawFunctionMenu(void)
- {
- LCD_Clear();
- LCD_ShowString(1,0,2,"1 ");
- LCD_ShowString(1,1,8,"?时间设置");
- LCD_ShowString(2,0,2,"2 ");
- LCD_ShowString(2,1,8,"背光设置");
- LCD_ShowString(3,0,2,"3 ");
- LCD_ShowString(3,1,8,"自动定时");
- LCD_ShowString(4,0,2,"4 ");
- LCD_ShowString(4,1,8,"查询功能");
- }
- static PT_Menu FunctionMenuRun(void)
- {
- unsigned char Flag = 0;
- unsigned char Key = 20;
- while(1){
- do{
- Key = Key_Service();
- }while(20 == Key);
- switch(Key){
- case 1:
- //SetTime
- break;
- case 2:
- //SetBlack
- break;
- case 3:
- //AutoTime
- break;
- case 4:
- return GetMenu("Query");
- case 9:
- if(Flag){
- if(Verify(SuperMiMa))
- return GetMenu("SuperFunction");
- Flag = 0;
- DrawFunctionMenu();
- }else
- Flag = 1;
- break;
- case 13:
- return GetMenu("Main");
- default:
- Flag = 0;
- break;
- }
-
- }
- return NULL;
- }
- static T_Menu FunctionMenu = {"Function", FunctionMenuRun, DrawFunctionMenu};
- static void DrawQueryMenu(void)
- {
- LCD_Clear();
- LCD_ShowString(1,0,2,"1 ");
- LCD_ShowString(1,1,8,"查询电池");
- LCD_ShowString(1,5,2,"IN");
- LCD_ShowString(1,6,4,"时长");
- LCD_ShowString(2,0,2,"2 ");
- LCD_ShowString(2,1,8,"查询电池");
- LCD_ShowString(2,5,4,"OUT ");
- LCD_ShowString(3,0,4,"时长");
-
- }
- static PT_Menu QueryMenuRun(void)
- {
- unsigned char Key = 20;
- while(1){
- do{
- Key = Key_Service();
- }while(20 == Key);
- switch(Key){
- case 1:
- //IN
- break;
- case 2:
- //OUT
- break;
- case 13:
- return GetMenu("Function");
- default:
- break;
- }
-
- }
- return NULL;
- }
- static T_Menu QueryMenu = {"Query", QueryMenuRun, DrawQueryMenu};
- static void DrawSuperFunctionMenu(void)
- {
- LCD_Clear();
- LCD_ShowString(1,0,2,"1 ");
- LCD_ShowString(1,1,10,"区域码设置");
-
- LCD_ShowString(2,0,2,"2");
- LCD_ShowString(2,2,8,"权限设置");
-
- LCD_ShowString(3,0,2,"3 ");
- LCD_ShowString(3,1,4,"预置");
- LCD_ShowString(3,3,4,"OUT ");
- LCD_ShowString(3,5,6,"时长判断");
- LCD_ShowString(4,0,2,"4 ");
- LCD_ShowString(4,1,12,"查询高级功能");
- }
- static PT_Menu SuperFunctionMenuRun(void)
- {
- unsigned char Key = 20;
- while(1){
- do{
- Key = Key_Service();
- }while(20 == Key);
- switch(Key){
- case 1:
- //区域码设置
- break;
- case 2:
- //权限设置
- break;
- case 3:
- ///预置OUT时长判定
- break;
- case 4:
- return GetMenu("SuperQuery");
- case 13:
- return GetMenu("Function");
- default:
- break;
- }
-
- }
- return NULL;
- }
- static T_Menu SuperFunctionMenu = { "SuperFunction", SuperFunctionMenuRun, DrawSuperFunctionMenu};
- static void DrawSuperQueryMenu(void)
- {
- LCD_Clear();
- LCD_ShowString(1,0,2,"1 ");
- LCD_ShowString(1,1,10,"查询电池");
- LCD_ShowString(1,5,2,"IN");
- LCD_ShowString(1,6,4,"时长");
-
- LCD_ShowString(2,0,2,"2 ");
- LCD_ShowString(2,1,10,"查询电池");
- LCD_ShowString(2,5,4,"OUT ");
- LCD_ShowString(2,7,4,"时长");
-
- LCD_ShowString(3,0,2,"3 ");
- LCD_ShowString(3,1,8,"查询电池");
- LCD_ShowString(3,5,2,"IN");
- LCD_ShowString(3,6,4,"次数\xfd");
- }
- static PT_Menu SuperQueryMenuRun(void)
- {
- unsigned char Key = 20;
- while(1){
- do{
- Key = Key_Service();
- }while(20 == Key);
- switch(Key){
- case 1:
- //查询电池IN时长
- break;
- case 2:
- //查询电池OUT时长
- break;
- case 3:
- ///查询电池IN次数
- break;
- case 13:
- return GetMenu("SuperFunction");
- default:
- break;
- }
-
- }
- return NULL;
- }
- static T_Menu SuperQueryMenu = { "SuperQuery", SuperQueryMenuRun, DrawSuperQueryMenu};
- void MenuInit(void)
- {
- RegisterPage(&MainMenu);
- RegisterPage(&FunctionMenu);
- RegisterPage(&QueryMenu);
- RegisterPage(&SuperFunctionMenu);
- RegisterPage(&SuperQueryMenu);
- SetCurrentMenu(GetMenu("Main"));
- }
- ———以上为部分源码,完整源码见下面附件中----
复制代码
多级菜单code.rar
(2.25 KB, 售价: 2 E币)
【必读】版权免责声明
1、本主题所有言论和内容纯属会员个人意见,与本论坛立场无关。2、本站对所发内容真实性、客观性、可用性不做任何保证也不负任何责任,网友之间仅出于学习目的进行交流。3、对提供的数字内容不拥有任何权利,其版权归原著者拥有。请勿将该数字内容进行商业交易、转载等行为,该内容只为学习所提供,使用后发生的一切问题与本站无关。 4、本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。 5、本网站所有软件和资料均为网友推荐收集整理而来,仅供学习用途使用,请务必下载后两小时内删除,禁止商用。6、如有侵犯你版权的,请及时联系我们(电子邮箱1370723259@qq.com)指出,本站将立即改正。
|
|