您的位置 首页 汽车

单片机4个按键菜单

#includemain.hvoidPWM_Ctrl(signedchari)//脉冲宽度设置{}voidOpenTime_Ctrl(signedchari)//开时间设置{}voidClose…

#include “main.h”

void PWM_Ctrl(signed char i) //脉冲宽度设置
{
}

void OpenTime_Ctrl(signed char i) //开时刻设置
{
}

void CloseTime_Ctrl(signed char i) //关时刻设置
{
}

void ClearData(signed char i) //铲除数据
{
}

void NullMenu(signed char i) //空操作
{
;
}

struct MenuItem
{
void (*Display)(void); //显现函数
void (*Subs)(signed char i); //节点函数
struct MenuItem *ChildrenMenus; //子菜单
struct MenuItem *ParentMenus; //母菜单
};

//本文合计2级菜单

struct MenuItem SetMenu[4]; //设置键子菜单
struct MenuItem StartMenu; //开始菜单
struct MenuItem (*MenuPoint) = &StartMenu;
struct MenuItem (*last_MenuPoint) = &StartMenu;

struct MenuItem SetMenu[4] =
{ // Display Subs ChildrenMenus ParentMenus
{ Display_S0, PWM_Ctrl, &SetMenu[1], &StartMenu},
{ Display_S1, OpenTime_Ctrl, &SetMenu[2], &StartMenu},
{ Display_S2, CloseTime_Ctrl, &SetMenu[3], &StartMenu},
{ Display_S3, ClearData, &StartMenu, &StartMenu},
};

struct MenuItem StartMenu =
{
Display_Count, NullMenu, &SetMenu[0], &StartMenu
};

void Data_manage(void)
{
;

}

void Key_Handle(void)
{
unsigned char key;
signed char i = 0;

if (key_value == 0)
{
return;
}
key = key_value;
key_value = 0;

switch (key)
{
case KEY_START:
MenuPoint = (*MenuPoint).ParentMenus;
break;
case KEY_SET:
MenuPoint = (*MenuPoint).ChildrenMenus;
pause_flag = 1; //暂停计数
break;
case KEY_UP:
i = 1;
break;
case KEY_DOWN:
i = -1;
break;
default:
break;
}

Data_manage();
(*(*MenuPoint).Subs)(i);
(*(*MenuPoint).Display)();

Refresh_flash();
}

void Display(void)
{
if (time_1s_flag == 1)
{
time_1s_flag = 0;
(*(*MenuPoint).Display)();
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/273242.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部