智能停车场管理系统程序:
12864液晶显示程序: #ifndef __LCD12864_H #define __LCD12864_H
//---包含头文件---// #include\
//---重定义关键词---// #ifndef uchar
#define uchar unsigned char #endif
#ifndef uint
#define uint unsigned int #endif
//---如果使用画图模式定义这个---//
//#define LCD12864_PICTURE
//---定义使用的IO口---//
#define LCD12864_DATAPORT P1
sbit LCD12864_RS = P0^7; //(数据命令)寄存器选择输入 sbit LCD12864_RW = P0^6; //液晶读/写控制 sbit LCD12864_EN = P0^5; //液晶使能控制 sbit LCD12864_PSB = P3^5; //串/并方式控制 sbit LCD12864_RST = P3^4;
//---声明全局函数---//
void LCD12864_Delay1ms(uint c); uchar LCD12864_Busy(void);
void LCD12864_WriteCmd(uchar cmd); void LCD12864_WriteData(uchar dat); void LCD12864_Init();
void LCD12864_ClearScreen(void);
void LCD12864_SetWindow(uchar x, uchar y); #endif
//复位端
//数据IO口
8
#include\
/******************************************************************************* * 函 数 名 : LCD12864_Delay1ms * 函数功能
* 输 入 : c * 输 出 : 无
*******************************************************************************/
void LCD12864_Delay1ms(uint c) {
uchar a,b; }
/******************************************************************************* * 函 数 名 : LCD12864_Busy * 函数功能
* 输 入 : 无
* 输 出 : 1或0(1表示不忙,0表示忙)
*******************************************************************************/
uchar LCD12864_Busy(void) {
while((LCD12864_DATAPORT & 0x80) == 0x80) {
i++; if(i > 100) {
LCD12864_EN = 0;
return 0; //超过等待时间返回0表示//检测读取到的值
LCD12864_EN = 1; LCD12864_Delay1ms(1); LCD12864_RS = 0; LCD12864_RW = 1;
//选择命令 //选择读取
uchar i = 0;
: 检测LCD是否忙
for(; c>0; c--) {
for(b=199; b>0; b--)
for(a=1; a>0; a--); }
} {
: 延时1MS
9
失败 }
/******************************************************************************* * 函 数 名 : LCD12864_WriteCmd * 函数功能
* 输 入 : cmd * 输 出 : 无
*******************************************************************************/
void LCD12864_WriteCmd(uchar cmd) { }
/******************************************************************************* * 函 数 名 : LCD12864_WriteData * 函数功能
* 输 入 : dat
: 写数据
LCD12864_EN = 1; LCD12864_Delay1ms(5); LCD12864_EN = 0;
//写时序
LCD12864_DATAPORT = cmd; //放置数据 uchar i; i = 0;
while( LCD12864_Busy() == 0) { }
LCD12864_RS = 0; //选择命令 LCD12864_RW = 0; //选择写入 LCD12864_EN = 0; //初始化使能端
LCD12864_Delay1ms(1); i++; if( i>100) {
return; //超过等待退出 }
: 写命令
return 1; LCD12864_EN = 0; }
}
10
* 输 出 : 无
*******************************************************************************/
void LCD12864_WriteData(uchar dat) { }
/******************************************************************************* * 函 数 名 : LCD12864_ReadData * 函数功能
* 输 入 : 无
* 输 出 : 读取到的8位数据
*******************************************************************************/ #ifdef LCD12864_PICTURE
uchar LCD12864_ReadData(void) {
i = 0;
while( LCD12864_Busy() == 0) {
LCD12864_Delay1ms(1); i++;
uchar i, readValue;
: 读取数据
LCD12864_EN = 1; LCD12864_Delay1ms(5); LCD12864_EN = 0;
//写时序
LCD12864_DATAPORT = dat; //放置数据 LCD12864_RS = 1; //选择数据 LCD12864_RW = 0; //选择写入 LCD12864_EN = 0; //初始化使能端 uchar i; i = 0;
while( LCD12864_Busy() == 0) { }
LCD12864_Delay1ms(1); i++; if( i>100) {
return; //超过等待退出 }
11
} #endif
/******************************************************************************* * 函 数 名 : LCD12864_Init * 函数功能
* 输 入 : 无 * 输 出 : 无
*******************************************************************************/
void LCD12864_Init() { }
/******************************************************************************* * 函 数 名 : LCD12864_SetWindow * 函数功能
标。注意:x是设置行,y是设置列 * 输 入 : x, y * 输 出 : 无
: 设置在基本指令模式下设置显示坐
LCD12864_WriteCmd(0x30); //选择基本指令操作 LCD12864_WriteCmd(0x0c); //显示开,关光标
LCD12864_WriteCmd(0x01); //清除LCD12864的显示内容 LCD12864_PSB = 1; LCD12864_RST = 1;
//选择并行输入 //复位
: 初始化LCD12864
return readValue; LCD12864_EN = 1; LCD12864_Delay1ms(1);
readValue = LCD12864_DATAPORT; LCD12864_EN = 0;
LCD12864_RS = 1; //选择命令 LCD12864_RW = 1; LCD12864_EN = 0;
LCD12864_Delay1ms(1); //等待 }
if( i>100) {
return 0; //超过等待退出 }
12
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库智能停车场设计 - 图文(3)在线全文阅读。
相关推荐: