12864专题Word文件下载.docx
- 文档编号:22318736
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:20
- 大小:66.20KB
12864专题Word文件下载.docx
《12864专题Word文件下载.docx》由会员分享,可在线阅读,更多相关《12864专题Word文件下载.docx(20页珍藏版)》请在冰豆网上搜索。
lcden=1;
temp=P0;
//读数据须在下降沿读出,读时,要在使能端为高电平时间
lcden=0;
while(temp&
0x80);
写指令函数,看时序写
voidwrite_com(ucharcom)//写指令
{rs=0;
rw=0;
P0=com;
delay_us
(1);
read_lcdbf();
这条指令一定要,否则会出错
写数据函数
voidwrite_date(uchardate)//写数据,都是并口的
{rs=1;
P0=date;
对照资料写初始化,8位初始化
voidinit()//八位软件初始化
{delay(100);
RST=1;
PSB=1;
//选择并行接口
write_com(0x30);
//基本指令操作
delay_us(4);
write_com(0x0c);
//只开显示
write_com(0x01);
//清屏指令
delay(15);
write_com(0x06);
//游标每写完一个字指针就加一
delay(5);
write_com(0x80);
}
/*防止花屏,在画点前应该先清除GDRAM显示,记住水平方向是以字节为单位的,
垂直方向以位为单位,所以一行行清除时,会出错
*/
voidclear_GDRAM()
{uchari,j,lcd_x=0x80,lcd_y=0x80,k;
write_com(0x34);
//因启用了GDRAM,所以需开扩展指令
for(i=0;
i<
2;
i++)
{for(j=0;
j<
32;
j++)//因垂直坐标有32位
{write_com(lcd_y+j);
//一行行的清除
write_com(lcd_x);
//因
for(k=0;
k<
16;
k++)//水平有16个字节
{write_date(0x00);
//依次清除它们,水平方向地址会自动加一
delay_us
(1);
}
lcd_x=0x88;
write_com(0x36);
设定位置显示函数
voidlcd_pos(ucharx,uchary)//设定显示位置,在第x行,且在x行的第y个字符显示
{ucharpos;
switch(x)
{case1:
x=0x80;
break;
case2:
x=0x90;
case3:
x=0x88;
break
case4:
x=0x98;
pos=x+y;
write_com(pos);
图像显示函数,只需往里写代码,用取模软件,得到那些代码,放在一个数组里,我用的是晓奇工作室的软件。
voidwrite_image(uchar*p)
write_com(0x34);
for(i=0;
{for(j=0;
{write_com(lcd_y+j);
{write_date(*p++);
}
write_com(0x36);
write_com(0x30);
/*画点函数,画点时先要读取那地址的数据,再在读取中的数据加入改点的数据
防止该字节中其他的点的显示受到干扰,所以新写的数据应加到之前读到的数据中
若果不先读取先前那个地址的数据,可能会破坏那个地址的显示
x为水平方向坐标,y为垂直方向坐标,水平是以字节为单位,垂直方向以位为单位
color为画点颜色,0为白色,1为黑色,2为使相应位颜色取反
read_H为用来保存读取到的高字节数据,read_L为用来保存读取到的低字节数据
voidwrite_dian(ucharx,uchary,ucharcolor)
{ucharx_locate,y_locate;
ucharx_bit,read_H,read_L;
x_locate=x/16;
//判断在水平方向哪个地址,因每一个地址占两个字节
x_bit=x%16;
//判断在该地址中的哪一位
if(y<
32)//判断在上屏
{y_locate=y;
}
else
{y_locate=y-32;
x_locate=x_locate+8;
write_com(0x34);
//先开扩展指令
write_com(y_locate+0x80);
//写垂直坐标,垂直坐标以位为单位
write_com(x_locate+0x80);
//写水平座标,是以字节写进去的
read_lcdbf();
//判断忙标志可有可无
read_lcd_date();
//空读一个字节,必定要,否则会出错,原因不知
read_H=read_lcd_date();
//读取那时地址中的数据,之后再和写进去的数据整合
read_L=read_lcd_date();
if(x_bit<
8)
{switch(color)
{
case0:
read_H&
=(~(0x01<
<
(7-x_bit)));
break;
//要保证该字节其他点不会受干扰不影响其显示
case1:
read_H|=((0x01<
case2:
read_H^=((0x01<
default:
}
write_date(read_H);
//先写入高字节
write_date(read_L);
//再写入低字节
else
read_L&
(15-x_bit)));
break;
read_L|=((0x01<
read_L^=((0x01<
}
//开绘图显示,
write_com(0x30);
//之后再回到基础指令
有了画点函数后,我们就可以画直线了,或者其他的波形了。
/*============================================================
函数功能:
画水平直线
参数说明:
x0为水平线起始点,x1为水平直线终止点,y图画在第几行
color为0时为白线,为1时为黑线,2时取反该直线上的点
==============================================================*/
voidwrite_x_line(ucharx0,ucharx1,uchary,ucharcolor)
if(x0>
x1)
{
temp=x0;
x0=x1;
x1=temp;
for(;
x0<
x1;
x0++)
write_dian(x0,y,color);
/*================================================================
画垂线
参数说明:
y0为起始点y1为结束点,x为所在第几列,color同上为颜色选择
==================================================================*/
voidwrite_y_line(ucharx,uchary0,uchary1,ucharcolor)
if(y0>
y1)
temp=y0;
y0=y1;
y1=temp;
y0<
y1;
y0++)//画直线就是连续画点
{write_dian(x,y0,color);
有了这些基本函数功能后,下面给一个完整的图片程序,只需改I/O就行,你不妨试一下,先尝试一下,
#include<
reg52.h>
intrins.h>
#defineuintunsignedint
#defineucharunsignedchar
sbitrs=P2^6;
//1为数据选择,0为指令选择
sbitrw=P2^5;
//控制读与写
sbitlcden=P2^7;
//使能端
sbitPSB=P3^2;
//串并接口方式选择,1为并方式,0为串方式
sbitCS1=P3^3;
//空脚,接1或0都行
sbitRST=P3^4;
//复位脚,低电平有效
uchartable[]={"
刘琳!
hello"
};
uchari;
for(x=z;
for(y=110;
for(i=t;
for(j=5;
do
{lcden=0;
rs=0;
rw=1;
_nop_();
lcden=1;
_nop_();
temp=P0;
lcden=0;
while(temp&
{
rs=0;
rw=0;
lcden=0;
P0=com;
lcden=1;
delay_us
(1);
{
rs=1;
P0=date;
{delay(100);
RST=1;
CS1=1;
PSB=1;
delay_us(4);
write_com(0x0c);
write_com(0x01);
delay(15);
write_com(0x06);
delay(5);
write_com(0x80);
/*防止花屏,在画点前应该先清除GDRAM显示,记住水平方向是以字节为单位的,
switch(x)
voidmain()
{init();
clear_GDRAM();
write_image(image);
lcd_pos(4,0);
10;
write_date(table[i]);
while
(1);
图像代码如下:
ucharcodeimage[]={
0x02,0x08,0x00,0x08,0x00,0x00,0x04,0x00,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xD0,0x06,0x04,0x08,0x03,0x02,0x00,
0x38,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x41,0x00,0x09,0x43,0x00,0x04,0xA1,0x80,
0x41,0xFF,0x00,0x00,0x00,0x07,0x00,0x00,
0x42,0x00,0x29,0x00,0x00,0x14,0x80,0x00,
0x8E,0x00,0xE7,0x00,0x00,0x02,0x00,0x00,
0x32,0x88,0x29,0x30,0x04,0x14,0x98,0x00,
0x70,0x00,0x1C,0x80,0x00,0x02,0x00,0x00,
0x0C,0x00,0x16,0x48,0x00,0x0B,0x24,0x00,
0x20,0x00,0x08,0x60,0x00,0x02,0x00,0x00,
0x00,0x20,0x4D,0x80,0x00,0x26,0xC0,0x00,
0x40,0x00,0x08,0x10,0x00,0x02,0x00,0x00,
0x40,0x20,0x00,0x10,0x00,0x00,0x08,0x00,
0x4C,0x00,0x08,0x10,0x00,0x02,0x00,0x00,
0x04,0x24,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x00,0x08,0x20,0x00,0x02,0x00,0x00,
0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x08,0x09,0xC0,0x00,0x07,0x00,0x00,
0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x04,0x00,0x40,0x00,0x00,0x00,0x00,
0x25,0x3F,0xC3,0xFE,0x3F,0xE0,0x00,0x01,
0x10,0x04,0x00,0x40,0x00,0x00,0x00,0x00,
0xA4,0x08,0x40,0x20,0x00,0x41,0x80,0x01,
0x10,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
0xA4,0xC8,0x47,0xFF,0x00,0x83,0xC0,0x01,
0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,
0x59,0x28,0x40,0x20,0x03,0x03,0xC0,0x02,
0x36,0x08,0x81,0xFC,0x02,0x03,0xC0,0x02,
0xF0,0x40,0x10,0x20,0x00,0x02,0x00,0x00,
0x00,0x44,0x81,0x24,0x02,0x01,0x80,0x05,
0x0C,0x04,0x10,0x20,0x00,0x10,0x40,0x00,
0x00,0x05,0x01,0xFC,0x02,0x01,0x80,0x05,
0x42,0x00,0x14,0x40,0x00,0x00,0x00,0x00,
0x00,0x02,0x01,0x24,0x02,0x00,0x00,0x05,
0x51,0x00,0x1C,0x40,0x00,0x20,0x20,0x00,
0x00,0x05,0x03,0xFE,0x02,0x01,0x80,0x04,
0x91,0x03,0xC0,0x40,0x00,0x00,0x00,0x00,
0x00,0x18,0xC0,0x20,0x02,0x01,0x80,0x04,
0x61,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
0x02,0x60,0x37,0xFF,0x0E,0x00,0x00,0x04,
0x1E,0x00,0x00,0x80,0x00,0x20,0x20,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
0x40,0x7F,0xF4,0x0A,0x3B,0xF3,0xFE,0x01,
0x01,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,
0x38,0x05,0x02,0x0A,0x2A,0x90,0x04,0x00,
0xC7,0xF8,0x02,0x00,0x00,0x10,0x40,0x00,
0x04,0x3F,0xE2,0xFF,0x2A,0x90,0x08,0x00,
0x70,0xF8,0x04,0x00,0x00,0x02,0x00,0x00,
0x20,0x25,0x20,0x88,0x3A,0x90,0x30,0x00,
0xC7,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xE2,0xF9,0x2B,0xF0,0x20,0x01,
0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x02,0x89,0x2A,0x00,0x20,0x02,
0x20,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
0x41,0x7F,0xF4,0xFA,0x3A,0x00,0x20,0x04,
0x48,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
0x18,0x08,0x84,0xD4,0x2A,0x00,0x20,0x08,
0x80,0x08,0x00,0x80,0x00,0x20,0x20,0x00,
0x20,0x1D,0x05,0x75,0x2A,0x10,0x20,0x09,
0x00,0x00,0x00,0x
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 12864 专题