单片机,写了一个12864lcd(带字库)的图片显示程序,但是实现不了,求帮助
#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintsbitrs=P2^0;sbitrw=P2^...
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit psb=P2^3;//串并方式选着
sbit RST= P2^4;
uint code tab[] =
{
1024个16进制数
};
void delay1ms(uchar x)//延时
{
unsigned char i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_cmd(uchar cmd)//写指令
{
rs=0;
rw=0;
en=0;
P0=cmd;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void write_data(uchar dat)//写数据
{
rs=1;
rw=0;
en=0;
P0=dat;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void lcd_int()//lcd初始化
{
RST = 1;
psb = 1;
write_cmd(0x30); /*30---基本指令动作*/
delay1ms(5);
write_cmd(0x01); /*清屏,地址指针指向00H*/
delay1ms(5);
write_cmd(0x06); /*光标的移动方向*/
delay1ms(5);
write_cmd(0x0c);/*显示开及光标设置*/
}
void display_bmp(uchar code *address)
{
uchar i,j;
for(i=0;i<32;i++)
{
write_cmd(0x80+i);
write_cmd(0x80);
for(j=0;j<16;j++)
{
write_data(*address);
address++;
}
}
for(i=0;i<0;i++)
{
write_cmd(0x80+i);
write_cmd(0x88);
for(j=0;j<16;j++)
{
write_data(*address);
address++;
}
}
}
void clrram(void)
{
write_cmd(0x01);
write_cmd(0x34);
write_cmd(0x30);
}
main()
{
lcd_int();
while(1)
{
void clrram();
delay1ms(50);
display_bmp(tab);
delay1ms(5000);
}
} 展开
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit psb=P2^3;//串并方式选着
sbit RST= P2^4;
uint code tab[] =
{
1024个16进制数
};
void delay1ms(uchar x)//延时
{
unsigned char i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_cmd(uchar cmd)//写指令
{
rs=0;
rw=0;
en=0;
P0=cmd;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void write_data(uchar dat)//写数据
{
rs=1;
rw=0;
en=0;
P0=dat;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void lcd_int()//lcd初始化
{
RST = 1;
psb = 1;
write_cmd(0x30); /*30---基本指令动作*/
delay1ms(5);
write_cmd(0x01); /*清屏,地址指针指向00H*/
delay1ms(5);
write_cmd(0x06); /*光标的移动方向*/
delay1ms(5);
write_cmd(0x0c);/*显示开及光标设置*/
}
void display_bmp(uchar code *address)
{
uchar i,j;
for(i=0;i<32;i++)
{
write_cmd(0x80+i);
write_cmd(0x80);
for(j=0;j<16;j++)
{
write_data(*address);
address++;
}
}
for(i=0;i<0;i++)
{
write_cmd(0x80+i);
write_cmd(0x88);
for(j=0;j<16;j++)
{
write_data(*address);
address++;
}
}
}
void clrram(void)
{
write_cmd(0x01);
write_cmd(0x34);
write_cmd(0x30);
}
main()
{
lcd_int();
while(1)
{
void clrram();
delay1ms(50);
display_bmp(tab);
delay1ms(5000);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询