求液晶12232并口c程序,带字库的
发布网友
发布时间:2022-08-25 16:31
我来回答
共3个回答
热心网友
时间:2024-11-23 15:20
到的是一些并口的汇编程序.并且也没有对应于12232F的并口程序,串口的C51程序极少见,为了方便大家使用.本程序在AT89S52单片机上已经调试成功,有什么问题,大家多多交流指教.使用这款LCD应该要注意的问题<br>一定要在VO与VDD及VSS这三个脚间接一个20K的电位器<br>电位器的中间脚接VO,其它二脚接VDD和VSS<br>然后调节电位器的大小,直到有显示为止。欢迎大家提出意见
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define x1 0x80
#define x2 0x88
#define y 0x80
#define comm 0
#define dat 1
sbit cs = P3^3;
sbit std = P3^1;
sbit sclk = P3^0;
void wr_lcd (uchar dat_comm,uchar content);
void delay (uint us);
uchar code tab1[]={
"天行健君子以自强不息"
"地势坤君子以厚德载物"
};
uchar code tab31[]={
"北京欢迎你WelcometoBeijing"
};
uchar code tab32[]={
/*-- 调入了一幅图像:F:\梁\画图\HOCO12832.bmp --*/
/*-- 宽度x高度=128x32 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03,0xFE,0x00,
0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F,0xFF,0xC0,
0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C,0x01,0xE0,
0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF,0xFC,0x60,
0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE,0x0F,0x30,
0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF,0xF1,0x90,
0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF,0xFC,0x90,
0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF,0xFC,0xD0,
0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF,0xFE,0x50,
0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF,0xFE,0x90,
0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF,0xFE,0x80,
0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,
0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,
0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF,0xBA,0x00,
0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF,0xB8,0x00,
0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF,0xB0,0x00,
0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF,0xA0,0x00,
0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B,0x00,0x00,
0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6,0x00,0x00,
0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20,0x00,0x00,
0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00,0x00,0x00,
0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00,0x00,0x00,
0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00,0x00,0x00,
0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00,0x00,0x00,
0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar code tab5[]={
/*-- 调入了一幅图像:F:\梁\画图\COCK.bmp --*/
/*-- 宽度x高度=128x64 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/*----初始化-----*/
void init_lcd (void)
{
wr_lcd (comm,0x30); /*30---基本指令动作*/
wr_lcd (comm,0x01); /*清屏,地址指针指向00H*/
delay (100);
wr_lcd (comm,0x06); /*光标的移动方向*/
wr_lcd (comm,0x0c); /*开显示,关游标*/
}
/*----上半屏显示汉字或字符----*/
void chn_dispup (uchar code *chn)
{
uchar i,j;
wr_lcd (comm,0x30); //30---基本指令动作
wr_lcd (comm,0x80); //把显示地址设为0X80,即为第一行的首位--第一页
j=0;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
}
/*----下半屏显示汉字或字符---*/
void chn_dispdown (uchar code *chn)
{
uchar i,j;
wr_lcd (comm,0x30); /*30---基本指令动作*/
wr_lcd (comm,0x90); //把显示地址设为0X90,即为第二行的首位--第二页
j=0;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
}
/*---上下半屏顺序显示汉字或字符----*/
void chn_disp1 (uchar code *chn)
{
uchar i,j;
wr_lcd (comm,0x30); /*30---基本指令动作*/
wr_lcd (comm,0x80); //把显示地址设为0X80,即为第一行的首位--第一页
j=0;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
wr_lcd (comm,0x90); //把显示地址设为0X90,即为第二行的首位--第二页
j=1;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
}
/*----显示图形----*/
void img_disp (uchar code *img)
{
uchar i,j;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34); //扩充指令操作
wr_lcd (comm,y+j); //先将垂直的字节坐标(Y)写入绘图RAM 地址
wr_lcd (comm,x1+i); //再将水平的字节坐标(X)写入绘图RAM 地址。
wr_lcd (comm,0x30); //基本指令动作
wr_lcd (dat,img[j*16+i*2]); //写入第一个Bytes
wr_lcd (dat,img[j*16+i*2+1]); //写入第二个Bytes
}
}
for(j=32;j<64;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34); //扩充指令操作
wr_lcd (comm,y+j-32); //先将垂直的字节坐标(Y)写入绘图RAM 地址
wr_lcd (comm,x2+i); //再将水平的字节坐标(X)写入绘图RAM 地址
wr_lcd (comm,0x30); //基本指令动作
wr_lcd (dat,img[j*16+i*2]); //写入第一个Bytes
wr_lcd (dat,img[j*16+i*2+1]); //写入第二个Bytes
}
}
wr_lcd (comm,0x36);
}
/*--------显示点阵-----------*/
void lat_disp (uchar data1,uchar data2)//data1,data2是要显示的数据
{
uchar i,j,k,x;
x=x1;
for(k=0;k<2;k++)
{
for(j=0;j<16;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34); //扩充指令操作
wr_lcd (comm,y+j*2); //先将垂直的字节坐标(Y)写入绘图RAM 地址
wr_lcd (comm,x+i); //再将水平的字节坐标(X)写入绘图RAM 地址
wr_lcd (comm,0x30); //功能设置:一次送8位数据,基本指令集
wr_lcd (dat,data1); //写入第一个Bytes
wr_lcd (dat,data1); //写入第二个Bytes
}
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34); //扩充指令操作
wr_lcd (comm,y+j*2+1); //先将垂直的字节坐标(Y)写入绘图RAM 地址
wr_lcd (comm,x+i); //再将水平的字节坐标(X)写入绘图RAM 地址
wr_lcd (comm,0x30); //基本指令操作
wr_lcd (dat,data2); //写入第一个Bytes
wr_lcd (dat,data2); //写入第二个Bytes
}
}
x=x2;
}
wr_lcd (comm,0x36);
}
/*--------------清DDRAM------------------*/
void clrram (void)
{
wr_lcd (comm,0x30);
wr_lcd (comm,0x01);
delay (180);
}
/*---------------------------------------*/
void wr_lcd (uchar dat_comm,uchar content)
{
uchar a,i,j;
delay (50);
a=content;
cs=1;
sclk=0;
std=1;
for(i=0;i<5;i++)
{
sclk=1;
sclk=0;
}
std=0;
sclk=1;
sclk=0;
if(dat_comm)
std=1; //data
else
std=0; //command
sclk=1;
sclk=0;
std=0;
sclk=1;
sclk=0;
for(j=0;j<2;j++)
{
for(i=0;i<4;i++)
{
a=a<<1;
std=CY;
sclk=1;
sclk=0;
}
std=0;
for(i=0;i<4;i++)
{
sclk=1;
sclk=0;
}
}
}
/*-----------------------------------*/
void delay (uint us) //delay time
{
while(us--);
}
void delay1 (uint ms)
{
uint i,j;
for(i=0;i<ms;i++)
for(j=0;j<15;j++)
delay(1);
}
/*------------------主程序--------------------*/
void main ()
{
SP=0x5f;
init_lcd ();
while (1)
{
clrram();
lat_disp (0x00,0x00); //显示点阵
delay1 (8000);
clrram();
lat_disp (0xcc,0xcc); //显示点阵
delay1 (8000);
clrram();
chn_disp1 (tab1); //上下半屏顺序显示汉字或字符
delay1 (8000);
clrram();
lat_disp (0xff,0x00); //显示点阵
delay1 (8000);
img_disp (tab5); //显示图形
delay1 (8000);
clrram();
chn_dispup (tab31); //上半屏顺序显示汉字或字符
delay1 (8000);
clrram();
chn_dispdown (tab31); //下半屏顺序显示汉字或字符
delay1 (8000);
}
}
热心网友
时间:2024-11-23 15:21
12232液晶汉字图形显示程序
字体大小: 小 中 大 作者: 来源: 日期:2006-08-08 点击:1809
硬件:TG12232B (122*32)模拟口线接线方式
连接线图:
--------------------------------------------------|
|DB0-----P0.0 | DB4-----P0.4 | RW-------P1.1 | A0--------P1.0 |
|DB1-----P0.1 | DB5-----P0.5 | RS-------P2.1 | V0接1K电阻到GND |
|DB2-----P0.2 | DB6-----P0.6 | E1-------P1.3 |
|DB3-----P0.3 | DB7-----P0.7 | E2-------P1.2 |
---------------------------------------------------
[注:AT89x52使用22.1184M或11.0592M晶振,实测使用22.1184M或11.0592都可以]
编译平台:Keil uV2 7.08
//可能看起来有点乱,不过效果还是不错的,显示图形总的来说比显示汉字要简单,当然显示汉字也不难。
希望此程序能给你一些帮助。
=============================================================*/
#include <AT89X52.H>
#define uchar unsigned char
#define uint unsigned int
#define E1 P1_3 //块1 左边
#define E2 P1_2 //块2 右边
#define RW P1_1
#define A0 P1_0 //A0为1时是数据,0时为指令数据
#define DATA P0 //数据
extern unsigned char code Bmpt1[];
extern unsigned char code Bmpt2[];
extern unsigned char code Bmpt3[];
extern unsigned char code Bmpt4[];
extern unsigned char code Bmpt5[];
extern unsigned char code Bmpt6[];
extern unsigned char code Bmpt7[];
extern unsigned char code Bmptc[];
extern unsigned char code bmp001[];
extern unsigned char code Bmp08[];
extern unsigned char code Bmp07[];
extern unsigned char code Bmp06[];
extern unsigned char code Bmp05[];
extern unsigned char code Bmp04[];
extern unsigned char code Bmp03[];
extern unsigned char code Bmp02[];
extern unsigned char code Bmp01[];
extern unsigned char code Bmp012[];
extern unsigned char code Bmp003[];
extern unsigned char code Bmp002[];
//延时
void delay(unsigned int i)
{
unsigned char k=200;
while(i>0)
{
i--;
}
while(k>1)k--;
}
//左页
//发送数据
void OU*(unsigned char i)
{
A0=1; //写数据
//delay(5);
E1=1;
//delay(10);
DATA=i;
//delay(5);
E1=0;
}
//左页
//发送命令
void OUTMI(unsigned char i)
{
A0=0; //写指令
//delay(5);
E1=1;
//delay(10);
DATA=i;
//delay(5);
E1=0;
}
//右页
//发送数据
void OUTSD(unsigned char i)
{
A0=1; //写数据
//delay(5);
E2=1;
//delay(10);
DATA=i;
//delay(5);
E2=0;
}
//右页
//发送命令
void OUTSI(unsigned char i)
{
A0=0; //写指令
//delay(5);
E2=1;
//delay(10);
DATA=i;
//delay(5);
E2=0;
}
//初始化
void lcdini(void)
{
RW=0;
OUTMI(0XE2);
OUTSI(0XE2);//复位
OUTMI(0XAE);
OUTSI(0XAE);//POWER SAVE
OUTMI(0XA4);
OUTSI(0XA4);//动态驱动
OUTMI(0XA9);
OUTSI(0XA9);//1/32占空比
OUTMI(0XA0);
OUTSI(0XA0);//时钟线输出
OUTMI(0XEE);
OUTSI(0XEE);//写模式
OUTMI(0X00);
OUTMI(0XC0);
OUTSI(0X00);
OUTSI(0XC0);
OUTMI(0XAF);
OUTSI(0XAF);
}
/*
函数说明:同时设置主从显示页为0-3页。(内函数,私有,用户不直接调用)
------------------------------------------------------------------------
*/
void SetPage(uchar page0,uchar page1)
{
OUTMI(0xB8|page1);OUTSI(0xB8|page0);
}
/*
--------------------------------------------------------------------------------
函数说明:同时设置主从列地址为0-121。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
*/
void SetAddress(uchar address0,uchar address1)
{
OUTMI(address1);OUTSI(address0);
}
/*
--------------------------------------------------------------------------------
调用方式:void PutChar0(uchar ch)
函数说明:在右页当前地址画一个字节8个点。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
-*/
void PutCharR(uchar ch)
{
OUTSD(ch);
}
/*
--------------------------------------------------------------------------------
调用方式:void PutChar1(uchar ch)
函数说明:在左页当前地址画一个字节8个点。(内函数,私有,用户不直接调用)
--------------------------------------------------------------------------------
-*/
void PutCharL(uchar ch)
{
OU*(ch);
}
/*
--------------------------------------------------------------------------------
调用方式:void DrawBmp(bit layer,uchar width,uchar *bmp)
函数说明:画一个图,layer表示上下层,width是图形的宽,高都是16,bmp是
图形指针
使用zimo3软件,纵向取模,字节倒序/240字节
--------------------------------------------------------------------------------
-*/
void DrawBmp(bit layer,uchar width,uchar *bmp)
{
uchar x,address,i=0; //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0; //window表示左右两页
//putcharR //右边
//putcharL //左边
for (x=width;x>1;x--)
{
if (i>60) {window=1;address=i%61;}
else address=i;
if(layer==0) //显示一行八个字
{
SetPage(0,0);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i]);
else PutCharL(bmp[i]);
SetPage(1,1);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i+width]);
else PutCharL(bmp[i+width]);
}
else
{ //显示第二行八个汉字
SetPage(2,2);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i]);
else PutCharL(bmp[i]);
SetPage(3,3);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i+width]);
else PutCharL(bmp[i+width]);
}
i++;
}
}
/*
--------------------------------------------------------------------------------
调用方式:void clrscr(void)
函数说明:清屏
--------------------------------------------------------------------------------
-*/
void clrscr(void)
{
uchar i;
uchar page;
for (page=0;page<4;page++)
{
SetPage(page,page);
SetAddress(0,0);
for (i=0;i<61;i++){PutCharR(0);PutCharL(0);}
}
}
//-----------------------------------------------------------
//图片显示
//采用字模2生成或字模3生成的都可以.
//-----------------------------------------------------------
void DrawBmp1(uint x_add, uchar width,uchar *bmp)
{
uchar x,address,i=0; //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0; //window表示左右两页
//putcharR //右边
//putcharL //左边
for (x=width;x>1;x--)
{
if (x_add>60) {window=1;address=x_add%61;}
else address=x_add;
SetPage(0,0);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i]);
else PutCharL(bmp[i]);
SetPage(1,1);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i+width]);
else PutCharL(bmp[i+width]);
SetPage(2,2);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i+width+width]);
else PutCharL(bmp[i+width+width]);
SetPage(3,3);
SetAddress(address,address);
if(window==1)PutCharR(bmp[i+width+width+width]);
else PutCharL(bmp[i+width+width+width]);
i++;
x_add++;
}
}
//---------------------------------------------------------------
//---------------------------------------------------------------
//采用zimo2 显示汉字,以汉字的显示方式
//void Draw_word(uchar d_where,uint x_add,bit layer,uchar width)
//d_where表示在码表中第几个汉字,x_add横坐标位置,layer显示的层, width显示的宽度。
//---------------------------------------------------------------
void Draw_word(uchar d_where,uint x_add,bit layer,uchar width)
{
uchar x,i=0,address; //address表示显存的物理地址
uchar page=0; //page表示上下两页
bit window=0; //window表示左右两页
//putcharR //右边
//putcharL //左边
d_where=d_where*32;
for (x=width;x>1;x--)
{
if (x_add>60) {window=1;address=x_add%61;}
else address=x_add;
if(layer==0) //显示一行八个字
{
SetPage(0,0);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[d_where]);//右边
else PutCharL(bmp001[d_where]);//左边
SetPage(1,1);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[d_where+width]);
else PutCharL(bmp001[d_where+width]);
}
else
{ //显示第二行八个汉字
SetPage(2,2);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[d_where]);//右边
else PutCharL(bmp001[d_where]);//左边
SetPage(3,3);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[d_where+width]);
else PutCharL(bmp001[d_where+width]);
}
x_add++;
d_where++;
}
}
/*
//------------------------------------------------------------------
//字模2显示一个汉字
//纵向取模,字节倒序
void disp_one(bit top_low,bit widows,uchar address,uchar width,uchar*bmp)
{
if(top_low==0)
{
SetPage(0,0);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[next][i]);
else PutCharL(bmp001[next][i]);
SetPage(1,1);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[next][i+width]);
else PutCharL(bmp001[next][i+width]);
}
else
{
SetPage(0,0);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[next][i]);
else PutCharL(bmp001[next][i]);
SetPage(1,1);
SetAddress(address,address);
if(window==1)PutCharR(bmp001[next][i+width]);
else PutCharL(bmp001[next][i+width]);
}
}
*/
//液晶显示规则
// M(左) S(右)
// page page
// 0 | 0
// 1 | 1
// 2 | 2
// 3 | 3
void delay1s(unsigned char i)
{
while(i>1)
{
i--;
delay(65530);
}
}
//显示动态的等待图标
void wait1(unsigned char i)
{
for(;i>1;i--)
{delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt1); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt2); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt3); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt4); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt5); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt6); //
delay1s(2);
clrscr(); //
DrawBmp1(0,60,Bmptc); //
DrawBmp1(76,19,Bmpt7); //
}
}
//演示程序
void main()
{
lcdini(); //reset
clrscr(); //clr
Draw_word(0,0,0,16); //
Draw_word(1,16,0,16); //
Draw_word(2,32,0,16); //
Draw_word(3,48,0,16); //
Draw_word(0,64,0,16); //
Draw_word(1,80,0,16); //
Draw_word(2,96,0,16); //
DrawBmp(1,120,Bmp002); //
clrscr(); //
delay1s(3);
DrawBmp1(0,122,Bmp012); //LOGO
while(1)
{
delay1s(3);
clrscr(); //
DrawBmp1(10,101,Bmp07); //
delay1s(8);
clrscr(); //
wait1(3);
DrawBmp1(0,122,Bmp04); //
delay1s(8);
clrscr(); //
wait1(3);
DrawBmp1(0,122,Bmp03); //超前科技
delay1s(8);
clrscr(); //
wait1(3);
clrscr(); //
DrawBmp1(10,101,Bmp05); //
delay1s(8);
clrscr(); //
wait1(3);
clrscr(); //
DrawBmp1(10,101,Bmp06); //
delay1s(8);
clrscr(); //
wait1(3);
clrscr(); //
DrawBmp1(10,101,Bmp08); //
delay1s(8);
clrscr(); //
wait1(3);
clrscr(); //
DrawBmp1(0,122,Bmp01); //这仿真器真不错,用过都说好.
wait1(8);
}
}
热心网友
时间:2024-11-23 15:21
话说,说话注意!有野不给你!!