51单片机+lcd12864液晶屏菜单程序
}
/*------------------------------------
Menu1设置日期子菜单处理
------------------------------------*/
void Menu1_Pro()
{
UINT8 temp;
if(!Again)
{
LCD_ClearGDRAM();
Set_Date=0;
Again=1;
Refresh_SetTime=1;
LCD_WriteCommand(0x30);
LCD_WriteCommand(0x80);
LCD_SendString("设置日期:");
LCD_WriteCommand(0x98);
LCD_SendString("ENTER 键保存修改");
DS1302_ReadDate();
}
if(Menu1_Flag)//每次Menu1下最少轮询5个if条件,最7多个if.实验证明,能带得了,效果还行
{
Menu1_Flag=0;
//Refresh_SetTime=1;
Set_Date++;
}
if(Set_Date>2)
Set_Date=0;
if(Refresh_SetTime)//当调节了刷新显示
{
Refresh_SetTime=0;
Display_SetDate();
}
if(!KEY_UP)
{
DelayMs(10);
if(!KEY_UP)
{
TR1=1;
while(!KEY_UP);
TR1=0;
if(Set_Date==0)
{
temp=Year/16;
Year=Year%16+temp*10;
if(Year<99)
Year++;
else Year=0;
temp=Year/10;
Year=Year%10+temp*16;
}
else if(Set_Date==1)
{
temp=Month/16;
Month=Month%16+temp*10;
if(Month<12)
Month++;
else Month=1;
temp=Month/10;
Month=Month%10+temp*16;
}
else if(Set_Date==2)
{
temp=Date/16;
Date=Date%16+temp*10;
if(Date<31)
Date++;
else Date=1;
temp=Date/10;
Date=Date%10+temp*16;
}
Refresh_SetTime=1;
}
}
else if(!KEY_DOWN)
{
DelayMs(10);
if(!KEY_DOWN)
{
TR1=1;
while(!KEY_DOWN);
TR1=0;
if(!Set_Date)
{
temp=Year/16;
Year=Year%16+temp*10;
if(Year>0)
Year--;
else Year=99;
temp=Year/10;
Year=Year%10+temp*16;
}
else if(Set_Date==1)
{
temp=Month/16;
Month=Month%16+temp*10;
if(Month>1)
Month--;
else Month=12;
temp=Month/10;
Month=Month%10+temp*16;
}
else if(Set_Date==2)
{
temp=Date/16;
Date=Date%16+temp*10;
if(Date>1)
Date--;
else Date=31;
temp=Date/10;
Date=Date%10+temp*16;
}
Refresh_SetTime=1;
}
}
else if(!KEY_ENTER)
{
DelayMs(10);
if(!KEY_ENTER)
{
TR1=1;
while(!KEY_ENTER);
TR1=0;
Enter_Menu=0;
Menu1=0;
guide_old++;
Again=0;
//guide=0;
//Set_Hour=0;
//Set_Minute=0;
DS1302_WriteDate();
LCD_ClearGDRAM();
}
}
}
/*------------------------------------
Menu2闹铃功能
------------------------------------*/
void Menu2_Pro()
{
UINT8 temp;
if(!Again)
{
LCD_ClearGDRAM();
Set_Bell=0;
//Set_Hour=1;//第一次进入时候直接显示调小时位
Again=1;//执行一次的标置置高,表明运行到该if条件下不执行下面语句
Refresh_SetTime=1;
LCD_WriteCommand(0x30);
LCD_WriteCommand(0x80);
LCD_SendString("设置闹铃:");
LCD_WriteCommand(0x98);
LCD_SendString(" 开启 关闭");
}
if(Menu2_Flag)
{
Menu2_Flag=0;
Set_Bell++;
Refresh_SetTime=1;
}
if(Set_Bell>3)
Set_Bell=0;
if(Refresh_SetTime)//当调节了刷新显示
{
Refresh_SetTime=0;
Display_Bell();
LCD_WriteCommand(0x30);
LCD_WriteCommand(0x98);
LCD_SendString(" ");
LCD_WriteCommand(0x9d);
LCD_SendString(" ");
if(Set_Bell>1)
{
if(Set_Bell==2)
LCD_WriteCommand(0x98);
else
LCD_WriteCommand(0x9d);
LCD_DisplayCGRAM(1);
}
}
if(!KEY_UP)
{
DelayMs(10);
if(!KEY_UP)
{
TR1=1;
while(!KEY_UP);
TR1=0;
if(Set_Bell==0)
{
if(Bell_Hour<23)
Bell_Hour++;
else Bell_Hour=0;
}
else if(Set_Bell==1)
{
if(Bell_Minute<59)
Bell_Minute++;
else Bell_Minute=0;
}
Refresh_SetTime=1;
}
}
else if(!KEY_DOWN)
{
DelayMs(10);
if(!KEY_DOWN)
{
TR1=1;
while(!KEY_DOWN);
TR1=0;
if(Set_Bell==0)
{
if(Bell_Hour>0)
Bell_Hour--;
else Bell_Hour=23;
}
else if(Set_Bell==1)
{
if(Bell_Minute>0)
Bell_Minute--;
else Bell_Minute=59;
}
Refresh_SetTime=1;
}
}
else if(!KEY_ENTER)
{
DelayMs(10);
if(!KEY_ENTER)
{
TR1=1;
while(!KEY_ENTER);
TR1=0;
Enter_Menu=0;
Menu2=0;
guide_old++;
Again=0;
//将闹钟时转换BCD以方便和ds1302读出的数据比较
temp=Bell_Hour/10; Bell_Hour=Bell_Hour%10+temp*16;
temp=Bell_Minute/10; Bell_Minute=Bell_Minute%10+temp*16;
if(Set_Bell==2)
Bell_Flag=1;
else Bell_Flag=0;
LCD_ClearGDRAM();
}
}
}
/*------------------------------------
Menu3背光功能
------------------------------------*/
void Menu3_Pro()
{
if(!Again)
{
LCD_ClearGDRAM();//LCD清屏幕
Again=1;//表明这个分支每次进入者只执行一次
//Set_Bright=0;
Refresh_SetTime=1;
LCD_WriteCommand(0x30);
LCD_WriteCommand(0x80);
LCD_SendString("背景光开关设置:");
LCD_WriteCommand(0x90);
LCD_SendString(" 开 关");
LCD_WriteCommand(0x98);
LCD_SendString("ENTER 键保存修改");
}
if(Refresh_SetTime)//当调节了刷新显示
{
Refresh_SetTime=0;
if(Set_Bright)
{
LCD_WriteCommand(0x94);
LCD_DisplayCGRAM(1);
LCD_WriteCommand(0x90);
LCD_SendString(" ");
}
else
{
LCD_WriteCommand(0x90);
LCD_DisplayCGRAM(1);
LCD_WriteCommand(0x94);
LCD_SendString(" ");
}
}
if(!KEY_ENTER)
{
DelayMs(10);
if(!KEY_ENTER)
{
TR1=1;
while(!KEY_ENTER);
TR1=0;
if(Set_Bright) BRIGHT=0;
else BRIGHT=1;
Enter_Menu=0;
Menu3=0;
guide_old++;
Again=0;
LCD_ClearGDRAM();
}
}
}
51单片机lcd12864液晶屏菜 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)