📄 menu.c
字号:
/**********************************多级菜单LCD显示********************************************/
/*********作者:王胜文。QQ:95201972 email:nunk@163.com 希望与大家交流2007。08。03**********/
#include<reg51.h>
#include<drive_functions.h>
#include<get_keys.h>
#include<characters.h>
#include<menu_functions.h>
void (*current_operation_index)();//
uchar func_index=0;
uchar func_index;
typedef struct
{
uchar current;
uchar up;
uchar down;
uchar enter;
void (*current_operation)();
} key_table;
key_table code table[28]=
{
{0,24,8,1,(*fun0)}, //0//第一层,显示[贵州],四川,广东,返回
{1,7,3,2,(*fun1)},//1-0按回车,进第二层,显示[贵阳],刘盘水,黄平,返回
{2,2,2,1,(*fun2)},//2-1 >enter>guiyang is the capital of guizhou,[return]
{3,1,5,4,(*fun4)},//4-1向下,显示贵阳,[六盘水],黄平,返回
{4,4,4,3,(*fun5)},//5-4 >enter>liupanshui is a base of coal mine of southern of china
{5,3,7,6,(*fun7)},//7-4向下,显示贵阳,六盘水,[黄平],返回
{6,6,6,5,(*fun8)}, //8-7 >enter>huangping is my hometown,[return]
{7,5,1,0,(*fun10)},//10-7 >down>贵阳,六盘水,黄平,[返回][
{8,0,16,9,(*fun12)},//12-0 >down>贵州,[四川],广东,返回
{9,15,11,10,(*fun13)},//13-12 >enter>[成都],绵阳,乐山,返回
{10,10,10,9,(*fun14)},//14-13 >entern>chengdu is the capital of sichuan province,[return]
{11,9,13,12,(*fun16)},//16-13 >down>成都,[绵阳],乐山,返回
{12,12,12,11,(*fun17)},//17-16 >enter>miangyang is a technology city of western china,[return]
{13,11,15,14,(*fun19)},//19-16 >down>成都,绵阳,[乐山],返回
{14,14,14,13,(*fun20)},//20-19 >enter>leshan have leshan dafu,[return]
{15,13,9,8,(*fun22)},//22-19 >down>成都,绵阳,乐山,[返回]
{16,8,24,17,(*fun24)},//24-12 >down>贵州,四川,[广东],返回
{17,23,19,18,(*fun25)},//25-24 >enter>[深圳],广州,惠州,返回
{18,18,18,17,(*fun26)},//26-25 >enter>i'm now in shenzhen,[return]
{19,17,21,20,(*fun28)},//28-25 >down>深圳,[广州],惠州,返回
{20,20,20,19,(*fun29)}, //29-28 >enter>guangzhou is the capital of guangdong,return
{21,19,23,22,(*fun31)},//31-28 >down>深圳,广州,[惠州],返回
{22,22,22,21,(*fun32)},//32-31 >enter>i'm in huizhou in 1997,[return]
{23,21,17,16,(*fun34)},//34-31 >down>深圳,广州,惠州,[返回]
{24,16,0,25,(*fun36)},//36-24 >down>贵州,四川,广东,[返回]
{25,26,26,27,(*fun37)},//37-36 >enter>[关闭],重启
{26,25,25,0,(*fun38)}, //38-37 >up>关闭,[重启]
{27,27,27,27,(*fun39)}//shutdown
};
void main(void)
{
while(1)
{
if(CheckState()) //检查是否有键按下
{
delay(); //延时去抖动
if(CheckState())
{
key=GetKeys(); //读取键盘值
/*******************find index****************************/
switch(key)
{
case 0x14:
func_index=table[func_index].up; //向上翻
break;
case 0x24:
func_index=table[func_index].enter;//回车
break;
case 0x44:
func_index=table[func_index].down;//向下翻
break;
default:
break;
}
}
ClearLCD(); //清屏
}
current_operation_index=table[func_index].current_operation;
fun40();//显示左屏固定信息
(*current_operation_index)();//执行当前操作函数
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -