}
SelectedShow=False; SelectedReturn=False; Selected=False;
if (ReturnSelection==True) { }
if (TotalDistanceShow==False) { }
if (TotalDistanceShow==True) { }
WriteCmd(LCD_CLS);
DisplayString(0,0,\); DisplayDistance();
DisplayString(0x0A,1,\); ReturnSelection=True; Delay(250);
//按下了确定键,那么这个时候开启返回键的功能
//延时消除抖动
WriteCmd(LCD_CLS);
DisplayString(0,0,\); DisplayAVGSpeed();
DisplayString(0x0A,1,\); ReturnSelection=True; Delay(250);
//延时消除抖动
//表明AVGSpeed选项的内容还没有显示
ReturnMain=True;
if (ReturnSelection==False)
//按下的是返回键
if (ReturnMain==True) { }
ReturnMain=False; continue;
//按下了返回键,返回主菜单
/*------------------------------------第四次按键--------------------------------------*/
while(1) { }
31
if (Next==True)
break; break;
if (SelectedShow==True)
if (Next==True) { }
Next=False;
//所有菜单项已经显示完毕,返回主菜单
ReturnMain=False; ReturnSelection=False; { }
if (TotalDistanceShow==False)
WriteCmd(LCD_CLS);
DisplayString(0x0,0,\); DisplayString(0x0,1,\); TotalDistanceShow=True;
Delay(250);
//延时消除抖动
if (SelectedShow==True) { }
if (ReturnMain==True) { }
ReturnMain=False; continue;
//按下了返回键,返回主菜单
SelectedShow=False; SelectedReturn=False; Selected=False;
if (ReturnSelection==True) { }
if (TotalDistanceShow==True) { }
WriteCmd(LCD_CLS);
DisplayString(0,0,\); DisplayDistance();
DisplayString(0x0A,1,\);
ReturnSelection=True; //按下了确定键,那么这个时候开启返回键的功能 Delay(250);
//延时消除抖动
ReturnMain=True;
if (ReturnSelection==False)
//按下的是返回键
32
}
while(1)
33
}
}
Delay(250);
//延时消除抖动
if (SelectedShow==True) {
SelectedShow=False; SelectedReturn=False; Selected=False;
if (ReturnSelection==True) {
if (TotalDistanceShow==True) {
WriteCmd(LCD_CLS);
DisplayString(0,0,\); DisplayDistance();
DisplayString(0x0A,1,\); ReturnSelection=True;
//按下了确定键,那么这个时候开启返回键的功能
ReturnMain=True;
if (ReturnSelection==False)
//按下的是返回键
if (Next==True) { }
Next=False; ReturnMain=False; ReturnSelection=False; if (TotalDistanceShow==True) { }
ReturnMain=True;
//最后一个选项已经显示完毕,返回主菜单
//所有菜单项已经显示完毕,返回主菜单
/*------------------------------------第五次按键--------------------------------------*/
while(1) { }
if (Next==True)
break; break;
if (SelectedShow==True)
/*------------------------------------第六次按键--------------------------------------*/
}
}
{ }
if (Next==True)
break; break;
if (SelectedShow==True)
if (Next==True) { }
if (SelectedShow==True) { }
continue;
SelectedShow=False; SelectedReturn=False; Selected=False; Next=False; ReturnMain=False; ReturnSelection=False;
while(1);
/****************************************************************************************\\ **
/*--------------------------------- LCD初始化函数--------------------------------------*/
void LCDInit(void) {
//三次显示模式设置
WriteCmd(LCD_Init);
34
//初始化 //关显示
WriteCmd(LCD_CloseCtr); LCD_Data=0; LCD_E=Disable; Delay(5);
WriteCmd(LCD_Init); Delay(5);
WriteCmd(LCD_Init); Delay(5);
WriteCmd(LCD_Init);
LCD驱动模块
**
\\****************************************************************************************/
}
WriteCmd(LCD_CLS);
//清屏幕 //光标移动设置 //显示开以及光标设置
WriteCmd(LCD_EnterSet); WriteCmd(LCD_DispCtr);
/*--------------------------------- LCD模式设置函数--------------------------------------*\\
SetWriteCmd() SetReadCmd() SetWriteData()
设置LCD为写命令模式 设置LCD为读命令模式 设置LCD为写数据模式
\\*----------------------------------------------------------------------------------------*/ void SetWriteCmd(void) { }
void SetReadCmd(void) { }
void SetWriteData(void) { }
/*--------------------------------- LCD功能执行函数--------------------------------------*\\
WriteCmd()
写命令 写数据 执行命令 显示定位 显示单个字符 显示一串字符 忙标志检测
WriteData() ExecuteCmd() SetXY()
LCD_RW=Write; LCD_RS=Data; LCD_RW=Read; LCD_RS=Cmd; LCD_RW=Write; LCD_RS=Cmd;
DisplaySingleChar() DisplayString() IsBusy()
\\*----------------------------------------------------------------------------------------*/ void WriteCmd(char cmd) {
while(IsBusy()); LCD_Data=cmd;
35
基于单片机的多功能智能小车设计论文(电路+程序+论文) - 图文



