2020-01-20 18:57发布
zhouyan 发表于 2013-4-16 21:12 弱问一下,楼上下载的程序编译通过,但移植到MDK STM32里就 编译没通过;问题就在于结构体赋值里的“&Null ...
10xjzheng 发表于 2014-7-12 11:08 他的那个结构体里面一个空结构体,一个是空函数,他结构体定义的时候把这两个搞混了,对应修改就好了。 ...
最多设置5个标签!
他的那个结构体里面一个空结构体,一个是空函数,他结构体定义的时候把这两个搞混了,对应修改就好了。
感谢斧正。
- #include "MENU.h"
- #include "LCD1602.h"
- #include "UArTTEST.h"
- #define LCDMAX_LINE 2
- #define UP 0xf8
- #define LEFT 0xd8
- #define RIGHT 0xa8
- #define DOEN 0x68
- #define ENTER 0x88
- #define ESC 0x98
- struct MenuItem MainMenu[4];
- struct MenuItem Baudrate[6];
- struct MenuItem
- {
- unsigned char menuCount; //Ŀ¼Ê÷
- unsigned char *displayString; //ÏÔʾ×Ö·û´®
- void (*subs)(); //º¯Êý
- struct MenuItem *childernMenus; //¸¸²Ëµ¥
- struct MenuItem *parentMenus; //×ֲ˵¥
- } MENU_NULL;
- void NULL_Function(void) //¿Õº¯Êý
- {
- ;
- }
- struct MenuItem MainMenu[4] =
- {
- {4,(unsigned char *)"1.get cpu temp ",&NULL_Function,&MENU_NULL,&MENU_NULL},
- {4,(unsigned char *)"2.get time ",&NULL_Function,&MENU_NULL,&MENU_NULL},
- {4,(unsigned char *)"3.baudrate ",&NULL_Function,Baudrate,&MENU_NULL},
- {4,(unsigned char *)"4.system info ",&NULL_Function,&MENU_NULL,&MENU_NULL},
- };
- struct MenuItem Baudrate[6] =
- {
- {6,(unsigned char *)"1.2400 ",&NULL_Function,&MENU_NULL,MainMenu},
- {6,(unsigned char *)"2.4800 ",&NULL_Function,&MENU_NULL,MainMenu},
- {6,(unsigned char *)"3.9600 ",&NULL_Function,&MENU_NULL,MainMenu},
- {6,(unsigned char *)"4.19200 ",&NULL_Function,&MENU_NULL,MainMenu},
- {6,(unsigned char *)"5.38400 ",&NULL_Function,&MENU_NULL,MainMenu},
- {6,(unsigned char *)"6.57500 ",&NULL_Function,&MENU_NULL,MainMenu},
- };
- struct MenuItem (*MenuPoint) = MainMenu;
- signed char DisplayStart = 0;
- signed char UserChoose = 0;
- signed char DisplayPoint = 0;
- signed char MaxItems = 0;
- signed char Option = 0;
- void MenuShow(void)
- {
- unsigned char iCount = 0;
-
- MaxItems = MenuPoint[0].menuCount; //»ñÈ¡µ±Ç°²Ëµ¥µÄÌõÄ¿
- DisplayPoint = DisplayStart;
-
- if (MaxItems > LCDMAX_LINE)
- {
- for (iCount = 0;iCount < LCDMAX_LINE;iCount++)
- {
- LCD1602WriteString(iCount,1,MenuPoint[DisplayPoint].displayString);
-
- if (DisplayPoint == UserChoose)
- {
- LCD1602WriteOneChar(0,0,0x7e);
- }
- else
- {
- LCD1602WriteOneChar(iCount,0,' ');
- }
- DisplayPoint += 1;
-
- if (DisplayPoint == MaxItems)
- {
- DisplayPoint = 0;
- }
- }
- }
- else
- {
- for (iCount = 0;iCount < LCDMAX_LINE;iCount++)
- {
- LCD1602WriteString(iCount,1,MenuPoint[DisplayPoint].displayString);
-
- if (DisplayPoint == UserChoose)
- {
- LCD1602WriteOneChar(0,0,0x7e);
- }
- else
- {
- LCD1602WriteOneChar(iCount,0,' ');
- }
- DisplayPoint += 1;
-
- if (DisplayPoint == MaxItems)
- {
- DisplayPoint = 0;
- }
- }
- }
- }
- void MenuProcess(unsigned char GetKeyNumber)
- {
- if (GetKeyNumber != 0xff)
- {
- switch (GetKeyNumber)
- {
- case UP:
- UserChoose --;
- if (UserChoose < 0 )
- {
- UserChoose = MaxItems - 1;
- }
- break;
- case DOEN:
- UserChoose ++;
- if (UserChoose == MaxItems )
- {
- UserChoose = 0;
- }
- break;
- case ENTER:
- 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 ESC:
- if (MenuPoint[0].parentMenus != &MENU_NULL )
- {
- MenuPoint = MenuPoint[0].parentMenus;
- DisplayStart = 0;
- UserChoose = Option;
- }
- break;
- }
- if ((UserChoose < DisplayStart) || (UserChoose >= (DisplayStart + 1 )))
- {
- DisplayStart = UserChoose;
- }
- LCD1602DISPLAY_CLR();
- MenuShow();
- }
- }
复制代码这个MDK上面没有问题的了
一周热门 更多>