#include "bsp.h"
#define SIZEOFMENU 5
unsigned char CurMenuIndex =0; //指向當前菜單編號
unsigned char FirstLine[16]=" 123";
unsigned char SecondLine[16]=" 123";
unsigned char lcdflashflag =1;//菜單刷新命令
//unsigned char IRFLAG =0; //紅外操作的健值
typedef struct keymenu
{
unsigned char curindex;//當前的菜單編號
unsigned char keyDNindex;//按下向下按鍵 進入的編號
unsigned char keyUPindex;//按下向上按鍵 進入的編號
unsigned char keyENTERindex;//按下回車按鍵 進入的編號
unsigned char keyCANCELindex;//按下返回按鍵 進入的編號
void (*operation)();
} MYMENU;
MYMENU code keytab[SIZEOFMENU] =
{
//當前,下,上,回車,返回
{0,1,0,2,0,dispmenu0},
{1,1,0,3,1,dispmenu1},
{2,2,2,2,0,dispmenu2},
{3,3,3,3,1,dispmenu3},
};
//根據(jù)紅外按鍵進行 菜單切換
void switch_menu(void)
{
switch(IRKEY)
{
case UPFLAG : //向上
CurMenuIndex = keytab[CurMenuIndex].keyUPindex;
lcdflashflag = 1;
bsp_LcdClr();
IRKEY = 0x99;
break;
case DNFLAG :
CurMenuIndex = keytab[CurMenuIndex].keyDNindex;
lcdflashflag = 1;
bsp_LcdClr();
IRKEY = 0x99;
break;
case ENTERFLAG :
CurMenuIndex = keytab[CurMenuIndex].keyENTERindex;
lcdflashflag = 1;
bsp_LcdClr();
IRKEY = 0x99;
break;
case CANCELFLAG :
CurMenuIndex = keytab[CurMenuIndex].keyCANCELindex;
lcdflashflag = 1;
bsp_LcdClr();
IRKEY = 0x99;
break;
}
keytab[CurMenuIndex].operation();
}
void dispmenu0(void) //0號界面
{
strcpy(FirstLine , " TIMER ");
strcpy(SecondLine ," TEMPERATURE ");
// 光標閃爍函數(shù)
// setcursorlocation(15,1); //第一行
}
void dispmenu1(void)
{
strcpy(FirstLine , " TIMER ");
strcpy(SecondLine ," TEMPERATURE ");
// 光標閃爍函數(shù)
//setcursorlocation(15,2); //第二行
}
void dispmenu2(void)
{
strcpy(FirstLine , " CURRENT TIME");
strcpy(SecondLine ," 14 : 51 : 11");
// 光標閃爍函數(shù)
//setcursorlocation(15,1); //第一行
}
void dispmenu3(void)
{
strcpy(FirstLine , " CURRENT TEMP");
strcpy(SecondLine ," T = 28 C ");
// 光標閃爍函數(shù)
//setcursorlocation(15,1); //第一行
}
void fresh(void) //刷新函數(shù)
{
if(lcdflashflag ==1)
{
bsp_LCDDispStr(0,1, FirstLine);
bsp_LCDDispStr(0,2, SecondLine);
lcdflashflag =0;
switch( CurMenuIndex)
{
case 0 :
setcursorlocation(15,1); //第一行
break;
case 1:
setcursorlocation(15,2); //第一行
break;
}
}
}
|