stm32OLED多级菜单
作者:互联网
今天实现了OLED多级菜单的显示。我用的是stm32f103ve,和四脚的OLED屏幕,用了三个按键。
话不多说,直接上代码。
点击查看代码
//先定义按键功能结构体
typedef struct
{
char current_menu;
char up_menu;
char down_menu;
char Enter_menu;
void (* operate)();
}Menu_Button;
//菜单
Menu_Button const table[9]=
{
{0,0,1,3,(*Menu1)},//1
{1,0,2,5,(*Menu2)},
{2,1,2,7,(*Menu3)},
{3,0,4,8,(*Menu4)},//1.1
{4,3,4,4,(*Menu5)},
{5,1,6,5,(*Menu4)},//1.2
{6,5,6,6,(*Menu5)},
{7,2,7,7,(*Show2)},//1.3
{8,3,8,8,(*Fun1)}//1.1.1
};
点击查看代码
//按键处理函数
void Key_pro()
{
static char flag = 1;
if(flag &&(keyup == 1 || keydown == 1 || keyenter == 1 || keyenter == 0 ))
{
flag = 0;
if(keyup == 1)
{
func_index = table[func_index].up_menu;
OLED_Clear();
return;
}
if(keydown == 1)
{
func_index = table[func_index].down_menu;
OLED_Clear();
return;
}
if(keyenter == 0)
{
func_index = table[func_index].Enter_menu;
OLED_Clear();
return;
}
}
else if(keyup == 0 && keydown == 0)
{
flag = 1;
}
}
标签:index,菜单,menu,多级,char,OLED,func,stm32OLED 来源: https://www.cnblogs.com/loremmoqi/p/16244690.html