想写一个LCD液晶菜单,按键只有一个旋转按键,可以上下旋转和确认/退出功能的
定义了一个结构体
typedef struct
{
u8 current;
u8 up;
u8 down;
u8 enter;
void (*current_operation)(void);
}Menu_table;
void Menu_key_set(void);
void main1(void);
void main2(void);
void main3(void);
void fun3(void);
void fun4(void);
void fun5(void);
void fun6(void);
Menu_table table[56] =
{
//current
// zheng
// fan
// enter
{0,1,6,0,(*main1)},//主界面
{1,2,0,1,(*main2)},// 第二级
{2,3,1,2,(*main3)},// 第三级 功能界面
{3,4,2,3,(*fun3)},// 第三级
{4,5,3,4,(*fun4)},// 第三级
{5,6,4,5,(*fun5)},//
{6,0,5,6,(*fun6)}, //
};
while(1)里面循环读取按键
while(1)
{
num =KEY_Scan();
if(num)
{
switch(num )
{
case 1:
func_index = table[func_index].up;
break;
case 2:
func_index = table[func_index].down;
break;
case 3:
func_index = table[func_index].enter;
break;
}
LCD_Clear(GRAY);
}
current_operation_index = table[func_index].current_operation;
(*current_operation_index)();
}
只能进行页面切换,不知道怎么在功能函数里面添加其它功能.
现在需要实现的功能是:左旋右旋可以实现界面切换,确认键进入界面中,
左旋右旋可以进行菜单行的选择,确认键进行修改参数等等,不知道怎么实现它,
在线等~谢谢
|