新聞中心

單片機4個按鍵菜單

作者: 時間:2016-11-13 來源:網(wǎng)絡(luò) 收藏
#include "main.h"

void PWM_Ctrl(signed char i) //脈沖寬度設(shè)置
{
}

本文引用地址:http://m.butianyuan.cn/article/201611/316565.htm

void OpenTime_Ctrl(signed char i) //開時間設(shè)置
{
}

void CloseTime_Ctrl(signed char i) //關(guān)時間設(shè)置
{
}

void ClearData(signed char i) //清除數(shù)據(jù)
{
}


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

struct MenuItem
{
void (*Display)(void); //顯示函數(shù)
void (*Subs)(signed char i); //節(jié)點函數(shù)
struct MenuItem *ChildrenMenus; //子菜單
struct MenuItem *ParentMenus; //母菜單
};

//本文共計2級菜單

struct MenuItem SetMenu[4]; //設(shè)置鍵子菜單
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; //暫停計數(shù)
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)();
}
}



關(guān)鍵詞: 單片機按鍵菜

評論


技術(shù)專區(qū)

關(guān)閉