2个回答
展开全部
#define uchar unsigned char
#define uint unsigned int
/************* 12864LCD引脚定义 *************/
//#define LCD_data P0 //数据口
sbit LCD_CS=P2^0; //寄存器选择输入
sbit SID=P2^1; //液晶读/写控制
sbit SCLK=P2^2; //液晶使能控制
//sbit LCD_PSB=P1^3; //串/并方式控制 硬件强制串口模式
//sbit LCD_RST=P1^5; //液晶复位端口 复位脚NC
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
/*********************************************************/
uchar code DIS1[] = {"超声波测距中...."};
uchar code DIS3[] = {"距障碍物: . m"};
uchar code DIS4[] = {"测距情况: 安全 "};
uchar code DIS5[] = {"测距情况: 请保持"};
uchar code DIS6[] = {"测距情况: 危险!!"};
uchar code DIS8[] = {" "};
uchar code DIS9[] = {"超声波倒车测距仪"};
uchar code DIS10[]= {" V1.0 2008.12.4 "};
uchar code point4[]= {"...."};
uchar code space4[]= {" "};
/******************************************************************************/
uchar code Car[] =
{ //勤品电子
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xB8,0x70,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xB8,0xF0,0x03,0xFF,0xE0,0x00,0x38,0x00,0x3F,0xFF,0x80,0x00,
0x00,0x00,0x00,0x1F,0xFE,0xE0,0x03,0xFF,0xE0,0x00,0x70,0x00,0x3F,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x3F,0xFE,0xE0,0x07,0xFF,0xC0,0x00,0x70,0x00,0x3F,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xE0,0x07,0x01,0xC0,0x30,0x61,0xC0,0x00,0x1F,0x80,0x00,
0x00,0x00,0x00,0x06,0xE7,0xFC,0x07,0x03,0xC0,0x3F,0xFF,0xC0,0x00,0x3E,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFC,0x0F,0x03,0x80,0x70,0xE1,0xC0,0x01,0xFC,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFC,0x0F,0xFF,0x80,0x70,0xC3,0x80,0x01,0xF0,0x00,0x00,
0x00,0x00,0x00,0x3F,0x73,0xB8,0x0F,0xFF,0x00,0x61,0xC3,0x80,0x03,0xC0,0x00,0x00,
0x00,0x00,0x00,0x7F,0xF3,0xB8,0x1F,0xFF,0x00,0xFF,0xFF,0x07,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x7F,0xE7,0xF8,0x00,0x00,0x00,0xE1,0x87,0x07,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x7F,0xE7,0x71,0xFF,0xBF,0xE0,0xC3,0x87,0x0F,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0xFF,0xE7,0x71,0xFF,0x7F,0xE1,0xC3,0x86,0x00,0x07,0x80,0x00,0x00,
0x00,0x00,0x01,0xFF,0xEF,0xF1,0xFF,0x7F,0xC1,0xFF,0xFE,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x1E,0xE3,0xCF,0x71,0xC1,0xFF,0xFE,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0x9E,0xE3,0x8E,0xF3,0xC3,0x87,0x0F,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xBD,0xE3,0x8E,0xE3,0x83,0x0E,0x03,0x00,0x0E,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xF9,0xC7,0xFF,0xFF,0x80,0x0E,0x03,0x00,0x1E,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xF3,0xC7,0xFD,0xFF,0x80,0x0E,0x07,0x00,0x7E,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xEF,0xC7,0xFD,0xFF,0x00,0x0F,0xFF,0x00,0x7C,0x00,0x00,0x00,
0x00,0x00,0x07,0x01,0xCF,0x8F,0x1D,0xC7,0x00,0x0F,0xFE,0x00,0x7C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,
0x00,0x07,0xFF,0xEF,0xFC,0x00,0x1F,0xF9,0xEF,0xFC,0x00,0x07,0xF1,0xE3,0xF8,0x00,
0x00,0x0F,0xFD,0xEF,0xFC,0x00,0x1F,0xF9,0xEF,0xFC,0x00,0x0F,0xF9,0xE7,0xFC,0x00,
0x00,0x1F,0xFD,0xCF,0xFE,0x00,0x1F,0xFD,0xCF,0xFE,0x00,0x1F,0xFD,0xCF,0xFE,0x00,
0x00,0x3C,0x3F,0xDF,0x1E,0x00,0x3E,0x3F,0xDF,0x1E,0x00,0x3E,0x3F,0xDF,0x1E,0x00,
0x00,0x78,0x3B,0xDE,0x1C,0x00,0x3C,0x3F,0xDE,0x1C,0x00,0x78,0x3F,0xFC,0x1E,0x00,
0x00,0x78,0x7F,0xBC,0x3C,0x00,0x78,0x3F,0xBC,0x3C,0x00,0x7F,0xFF,0xBF,0xFE,0x00,
0x00,0xF0,0x7F,0xBC,0x3C,0x00,0x78,0x3F,0xBC,0x3C,0x00,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0x77,0xBC,0x38,0x00,0x78,0x7F,0xBC,0x38,0x00,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0xFF,0x78,0x78,0x00,0xF0,0x7F,0x78,0x78,0x00,0xF0,0x0F,0x78,0x00,0x00,
0x00,0xF1,0xFF,0x78,0x78,0x00,0xF0,0xFF,0x78,0x78,0x00,0xF0,0xFF,0x78,0x78,0x00,
0x00,0xF3,0xEF,0x78,0x70,0x00,0xF9,0xEF,0x78,0x70,0x00,0xF9,0xFF,0x7C,0xF8,0x00,
0x00,0xFF,0xFE,0xF0,0xF0,0x01,0xFF,0xFE,0xF0,0xF0,0x00,0xFF,0xFE,0x7F,0xF0,0x00,
0x00,0x7F,0xFE,0xF0,0xF0,0x01,0xFF,0x9E,0xF0,0xF0,0x00,0x7F,0xDE,0x3F,0xE0,0x00,
0x00,0x3F,0xC0,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00,0x1E,0x00,0x0F,0x00,0x00,
0x00,0x03,0xC0,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xC0,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x80,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/********************************************************
* *
* 延时t毫秒 *
* 11.0592MHz时钟,延时约1ms *
* *
********************************************************/
/*
void delay_tms(uint t)
{
uchar k;
while(t--)
{
for(k=0; k<125; k++)
{ }
}
} */
/*********************************************************
* *
* 延时函数 200us *
* *
*********************************************************/
void delay_lcd(int ms)
{
uchar t;
while(ms--)
{
for(t=0; t<20; t++) ;
}
}
/*********************************************************
* *
* 发送一个字节 *
* *
*********************************************************/
void sendbyte(uchar bbyte)
{
uchar i;
for(i=0;i<8;i++)
{
SID=bbyte&0x80; //取出最高位
SCLK=1;
_nop_();
_nop_();
SCLK=0;
bbyte<<=1; //左移
}
}
/*********************************************************
* *
* 写指令或数据函数 *
* *
*********************************************************/
void write(bit start, uchar ddata)
{
uchar start_data,Hdata,Ldata;
if(start==0) //11111,(0),(0),0
start_data=0xf8; //写指令
else //11111,(0),(1),0
start_data=0xfa; //写数据
Hdata=ddata&0xf0; //取高四位
Ldata=(ddata<<4)&0xf0; //取低四位
sendbyte(start_data); //发送起始信号
delay_lcd(1); //延时
sendbyte(Hdata); //发送高四位
delay_lcd(1); //延时
sendbyte(Ldata); //发送低四位
delay_lcd(1); //延时
}
/*********************************************************
* *
* 初始化LCD *
* *
*********************************************************/
void lcd_init()
{
delay_lcd(10); //延时等待LCM进入工作状态
//PSB=0; ; //串口驱动模式
//RESET=0;
//delay_lcd(5);
//RESET=1; //复位LCD
LCD_CS=1; //片选 高电平有效
write(0,0x30); //基本指令操作
write(0,0x0c); //显示打开,光标关,反白关
write(0,0x01); //清屏,将DDRAM的地址计数器归零
write(0,0x06);
}
/*********************************************************
函数名:void lcd_pos(uchar X,uchar Y)
功能: 设定显示位置
/*********************************************************/
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==1)
{
X=0x80;
}
else
if (X==2)
{
X=0x90;
}
else
if (X==3)
{
X=0x88;
}
else
if (X==4)
{
X=0x98;
}
pos = X+Y ;
write(0,pos); //lcd_wcmd(pos); //写位置命令
}
/*********************************************************
* *
* 图形显示 *
* *
*********************************************************/
void photodisplay(uchar *bmp)
{
uchar i,j;
write(0,0x34); //写数据时,关闭图形显示
for(i=0;i<32;i++)
{
write(0,0x80+i); //先写入水平坐标值
write(0,0x80); //写入垂直坐标值
for(j=0;j<16;j++) //再写入两个8位元的数据
write(1,*bmp++);
delay_lcd(1);
}
for(i=0;i<32;i++)
{
write(0,0x80+i);
write(0,0x88);
for(j=0;j<16;j++)
write(1,*bmp++);
delay_lcd(1);
}
write(0,0x36); //写完数据,开图形显示
}
/*********************************************************
函数名:void clr_screen()
功能: LCD清屏
*********************************************************/
void clr_screen()
{
write(0,0x34); //lcd_wcmd(0x34); //扩充指令操作
delay(5);
write(0,0x30); //lcd_wcmd(0x30); //基本指令操作
delay(5);
write(0,0x01); //lcd_wcmd(0x01); //清屏
delay(5);
}
/*********************************************************
函数名:void displayall()
功能:主显示函数
*********************************************************/
void displayall()
{
uchar i;
delay(2);
lcd_init(); //初始化LCD
lcd_pos(2,0); //设置显示位置为第二行
for(i=0;i<16;i++)
{
write(1,DIS9[i]); //lcd_wdat(DIS9[i]);
delay(30);
}
lcd_pos(3,0); //设置显示位置为第三行
for(i=0;i<16;i++)
{
write(1,DIS10[i]); //lcd_wdat(DIS10[i]);
delay(30);
}
delay(1000);
clr_screen(); //清屏
photodisplay(Car); //显示图片1
delay(500);
clr_screen();
//上电,等待稳定
lcd_pos(1,0); //设置显示位置为第一行
for(i=0;i<16;i++)
{
write(1,DIS1[i]); //lcd_wdat(DIS1[i]);
delay(2);
}
lcd_pos(3,0); //设置显示位置为第三行
for(i=0;i<16;i++)
{
write(1,DIS3[i]); //lcd_wdat(DIS3[i]);
delay(2);
}
lcd_pos(4,0); //设置显示位置为第四行
for(i=0;i<16;i++)
{
write(1,DIS8[i]); //lcd_wdat(DIS8[i]);
delay(2);
}
delay(1000);
}
#define uint unsigned int
/************* 12864LCD引脚定义 *************/
//#define LCD_data P0 //数据口
sbit LCD_CS=P2^0; //寄存器选择输入
sbit SID=P2^1; //液晶读/写控制
sbit SCLK=P2^2; //液晶使能控制
//sbit LCD_PSB=P1^3; //串/并方式控制 硬件强制串口模式
//sbit LCD_RST=P1^5; //液晶复位端口 复位脚NC
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
/*********************************************************/
uchar code DIS1[] = {"超声波测距中...."};
uchar code DIS3[] = {"距障碍物: . m"};
uchar code DIS4[] = {"测距情况: 安全 "};
uchar code DIS5[] = {"测距情况: 请保持"};
uchar code DIS6[] = {"测距情况: 危险!!"};
uchar code DIS8[] = {" "};
uchar code DIS9[] = {"超声波倒车测距仪"};
uchar code DIS10[]= {" V1.0 2008.12.4 "};
uchar code point4[]= {"...."};
uchar code space4[]= {" "};
/******************************************************************************/
uchar code Car[] =
{ //勤品电子
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xB8,0x70,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xB8,0xF0,0x03,0xFF,0xE0,0x00,0x38,0x00,0x3F,0xFF,0x80,0x00,
0x00,0x00,0x00,0x1F,0xFE,0xE0,0x03,0xFF,0xE0,0x00,0x70,0x00,0x3F,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x3F,0xFE,0xE0,0x07,0xFF,0xC0,0x00,0x70,0x00,0x3F,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xE0,0x07,0x01,0xC0,0x30,0x61,0xC0,0x00,0x1F,0x80,0x00,
0x00,0x00,0x00,0x06,0xE7,0xFC,0x07,0x03,0xC0,0x3F,0xFF,0xC0,0x00,0x3E,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFC,0x0F,0x03,0x80,0x70,0xE1,0xC0,0x01,0xFC,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFC,0x0F,0xFF,0x80,0x70,0xC3,0x80,0x01,0xF0,0x00,0x00,
0x00,0x00,0x00,0x3F,0x73,0xB8,0x0F,0xFF,0x00,0x61,0xC3,0x80,0x03,0xC0,0x00,0x00,
0x00,0x00,0x00,0x7F,0xF3,0xB8,0x1F,0xFF,0x00,0xFF,0xFF,0x07,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x7F,0xE7,0xF8,0x00,0x00,0x00,0xE1,0x87,0x07,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x7F,0xE7,0x71,0xFF,0xBF,0xE0,0xC3,0x87,0x0F,0xFF,0xFF,0xC0,0x00,
0x00,0x00,0x00,0xFF,0xE7,0x71,0xFF,0x7F,0xE1,0xC3,0x86,0x00,0x07,0x80,0x00,0x00,
0x00,0x00,0x01,0xFF,0xEF,0xF1,0xFF,0x7F,0xC1,0xFF,0xFE,0x00,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x1E,0xE3,0xCF,0x71,0xC1,0xFF,0xFE,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0x9E,0xE3,0x8E,0xF3,0xC3,0x87,0x0F,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xBD,0xE3,0x8E,0xE3,0x83,0x0E,0x03,0x00,0x0E,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xF9,0xC7,0xFF,0xFF,0x80,0x0E,0x03,0x00,0x1E,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xF3,0xC7,0xFD,0xFF,0x80,0x0E,0x07,0x00,0x7E,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xEF,0xC7,0xFD,0xFF,0x00,0x0F,0xFF,0x00,0x7C,0x00,0x00,0x00,
0x00,0x00,0x07,0x01,0xCF,0x8F,0x1D,0xC7,0x00,0x0F,0xFE,0x00,0x7C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,
0x00,0x07,0xFF,0xEF,0xFC,0x00,0x1F,0xF9,0xEF,0xFC,0x00,0x07,0xF1,0xE3,0xF8,0x00,
0x00,0x0F,0xFD,0xEF,0xFC,0x00,0x1F,0xF9,0xEF,0xFC,0x00,0x0F,0xF9,0xE7,0xFC,0x00,
0x00,0x1F,0xFD,0xCF,0xFE,0x00,0x1F,0xFD,0xCF,0xFE,0x00,0x1F,0xFD,0xCF,0xFE,0x00,
0x00,0x3C,0x3F,0xDF,0x1E,0x00,0x3E,0x3F,0xDF,0x1E,0x00,0x3E,0x3F,0xDF,0x1E,0x00,
0x00,0x78,0x3B,0xDE,0x1C,0x00,0x3C,0x3F,0xDE,0x1C,0x00,0x78,0x3F,0xFC,0x1E,0x00,
0x00,0x78,0x7F,0xBC,0x3C,0x00,0x78,0x3F,0xBC,0x3C,0x00,0x7F,0xFF,0xBF,0xFE,0x00,
0x00,0xF0,0x7F,0xBC,0x3C,0x00,0x78,0x3F,0xBC,0x3C,0x00,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0x77,0xBC,0x38,0x00,0x78,0x7F,0xBC,0x38,0x00,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0xFF,0x78,0x78,0x00,0xF0,0x7F,0x78,0x78,0x00,0xF0,0x0F,0x78,0x00,0x00,
0x00,0xF1,0xFF,0x78,0x78,0x00,0xF0,0xFF,0x78,0x78,0x00,0xF0,0xFF,0x78,0x78,0x00,
0x00,0xF3,0xEF,0x78,0x70,0x00,0xF9,0xEF,0x78,0x70,0x00,0xF9,0xFF,0x7C,0xF8,0x00,
0x00,0xFF,0xFE,0xF0,0xF0,0x01,0xFF,0xFE,0xF0,0xF0,0x00,0xFF,0xFE,0x7F,0xF0,0x00,
0x00,0x7F,0xFE,0xF0,0xF0,0x01,0xFF,0x9E,0xF0,0xF0,0x00,0x7F,0xDE,0x3F,0xE0,0x00,
0x00,0x3F,0xC0,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x00,0x1E,0x00,0x0F,0x00,0x00,
0x00,0x03,0xC0,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xC0,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x80,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x80,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/********************************************************
* *
* 延时t毫秒 *
* 11.0592MHz时钟,延时约1ms *
* *
********************************************************/
/*
void delay_tms(uint t)
{
uchar k;
while(t--)
{
for(k=0; k<125; k++)
{ }
}
} */
/*********************************************************
* *
* 延时函数 200us *
* *
*********************************************************/
void delay_lcd(int ms)
{
uchar t;
while(ms--)
{
for(t=0; t<20; t++) ;
}
}
/*********************************************************
* *
* 发送一个字节 *
* *
*********************************************************/
void sendbyte(uchar bbyte)
{
uchar i;
for(i=0;i<8;i++)
{
SID=bbyte&0x80; //取出最高位
SCLK=1;
_nop_();
_nop_();
SCLK=0;
bbyte<<=1; //左移
}
}
/*********************************************************
* *
* 写指令或数据函数 *
* *
*********************************************************/
void write(bit start, uchar ddata)
{
uchar start_data,Hdata,Ldata;
if(start==0) //11111,(0),(0),0
start_data=0xf8; //写指令
else //11111,(0),(1),0
start_data=0xfa; //写数据
Hdata=ddata&0xf0; //取高四位
Ldata=(ddata<<4)&0xf0; //取低四位
sendbyte(start_data); //发送起始信号
delay_lcd(1); //延时
sendbyte(Hdata); //发送高四位
delay_lcd(1); //延时
sendbyte(Ldata); //发送低四位
delay_lcd(1); //延时
}
/*********************************************************
* *
* 初始化LCD *
* *
*********************************************************/
void lcd_init()
{
delay_lcd(10); //延时等待LCM进入工作状态
//PSB=0; ; //串口驱动模式
//RESET=0;
//delay_lcd(5);
//RESET=1; //复位LCD
LCD_CS=1; //片选 高电平有效
write(0,0x30); //基本指令操作
write(0,0x0c); //显示打开,光标关,反白关
write(0,0x01); //清屏,将DDRAM的地址计数器归零
write(0,0x06);
}
/*********************************************************
函数名:void lcd_pos(uchar X,uchar Y)
功能: 设定显示位置
/*********************************************************/
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==1)
{
X=0x80;
}
else
if (X==2)
{
X=0x90;
}
else
if (X==3)
{
X=0x88;
}
else
if (X==4)
{
X=0x98;
}
pos = X+Y ;
write(0,pos); //lcd_wcmd(pos); //写位置命令
}
/*********************************************************
* *
* 图形显示 *
* *
*********************************************************/
void photodisplay(uchar *bmp)
{
uchar i,j;
write(0,0x34); //写数据时,关闭图形显示
for(i=0;i<32;i++)
{
write(0,0x80+i); //先写入水平坐标值
write(0,0x80); //写入垂直坐标值
for(j=0;j<16;j++) //再写入两个8位元的数据
write(1,*bmp++);
delay_lcd(1);
}
for(i=0;i<32;i++)
{
write(0,0x80+i);
write(0,0x88);
for(j=0;j<16;j++)
write(1,*bmp++);
delay_lcd(1);
}
write(0,0x36); //写完数据,开图形显示
}
/*********************************************************
函数名:void clr_screen()
功能: LCD清屏
*********************************************************/
void clr_screen()
{
write(0,0x34); //lcd_wcmd(0x34); //扩充指令操作
delay(5);
write(0,0x30); //lcd_wcmd(0x30); //基本指令操作
delay(5);
write(0,0x01); //lcd_wcmd(0x01); //清屏
delay(5);
}
/*********************************************************
函数名:void displayall()
功能:主显示函数
*********************************************************/
void displayall()
{
uchar i;
delay(2);
lcd_init(); //初始化LCD
lcd_pos(2,0); //设置显示位置为第二行
for(i=0;i<16;i++)
{
write(1,DIS9[i]); //lcd_wdat(DIS9[i]);
delay(30);
}
lcd_pos(3,0); //设置显示位置为第三行
for(i=0;i<16;i++)
{
write(1,DIS10[i]); //lcd_wdat(DIS10[i]);
delay(30);
}
delay(1000);
clr_screen(); //清屏
photodisplay(Car); //显示图片1
delay(500);
clr_screen();
//上电,等待稳定
lcd_pos(1,0); //设置显示位置为第一行
for(i=0;i<16;i++)
{
write(1,DIS1[i]); //lcd_wdat(DIS1[i]);
delay(2);
}
lcd_pos(3,0); //设置显示位置为第三行
for(i=0;i<16;i++)
{
write(1,DIS3[i]); //lcd_wdat(DIS3[i]);
delay(2);
}
lcd_pos(4,0); //设置显示位置为第四行
for(i=0;i<16;i++)
{
write(1,DIS8[i]); //lcd_wdat(DIS8[i]);
delay(2);
}
delay(1000);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询