/*STC89c52 、12864、串口图片显示*/
#include<reg52.h>
#define uint unsigned int#define uchar unsigned char
sbit CS=P2^0;
sbit SID=P2^1;
sbit SCLK=P2^2;
sbit PSB=P2^3;
uchar code denglong[64][16]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,
0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xE0,0x00,0xFF,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFE,
0x03,0xF8,0x1F,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF8,
0xFF,0xFF,0xC3,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE3,
0xFF,0xFF,0xF9,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xCF,
0xFF,0xFF,0xFE,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x3F,
0xFF,0xFF,0xFF,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x7F,
0xFF,0xFF,0xFF,0xDC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0xFF,
0xFF,0xFF,0xFF,0xEC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFB,0xFF,
0xFF,0xFF,0xFF,0xF6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFA,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xC7,0xFF,
0xFF,0xFF,0xFF,0xFF,0xDC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFE,0xDC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,
0xF0,0x01,0xFF,0xFE,0x5C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0x8F,0xF0,
0x00,0x00,0x03,0xFF,0xDC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xAF,0x03,
0xFF,0xFF,0xF8,0x3E,0xDC,0x00,0xC0,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x7F,
0xFF,0xFF,0xFF,0x8E,0x5C,0x00,0xC0,0x00,
0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0xEF,0xFF,
0xFF,0xFF,0xFF,0xFE,0xDC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x87,0xFF,
0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFB,0xFF,
0xFF,0xFF,0xFF,0xFA,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFD,0xFF,
0xFF,0xFF,0xFF,0xF4,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0xFF,
0xFF,0xFF,0xFF,0xCC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x7F,
0xFF,0xFF,0xFF,0x9C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x9F,
0xFF,0xFF,0xFF,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC7,
0xFF,0xFF,0xFC,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF1,
0xFF,0xFF,0xE3,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,
0x3F,0xFF,0x87,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,
0x80,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xF8,0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,
0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,
0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void delay_1ms(uint x)
{
uchar i=110;
while(x--)
{
i=110;
while(i--);
}
}
void send_command(uchar command_data)
{
uchar i;
uchar i_data;
i_data=0xf8; //写指令第一个字节11111000
CS=1;
SCLK=0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
i_data=command_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
i_data=command_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
CS=0;
delay_1ms(10);
}
void send_data(uchar command_data)
{
uchar i;
uchar i_data;
i_data=0xfa; //写数据11111010
CS=1;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
i_data=command_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
i_data=command_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCLK=0;
SCLK=1;
i_data<<=1;
}
CS=0;
delay_1ms(10);
}
void lcd_init()
{
PSB=0;
delay_1ms(100);
send_command(0x30);//设置8位数据接口,基本指令模式
send_command(0x02);//清DDRAM
send_command(0x06);//游标显示右移一位
send_command(0x0c);//整体显示开,游标关,反白关
send_command(0x01);//写入空格清屏
send_command(0x80);//设定首次显示位置
}
void display()
{
uchar i,j;
send_command(0x34);//开扩充指令集
for(i=0;i<32;i++)
{
send_command(0x80+i);
send_command(0x80);
for(j=0;j<16;j++)
{
send_data(denglong[i][j]);
}
}
for(i=0;i<32;i++)
{
send_command(0x80+i);
send_command(0x88);
for(j=0;j<16;j++)
{
send_data(denglong[i+32][j]);
}
}
send_command(0x36); //开绘图
send_command(0x30);//返回基本指令集
}
void main()
{
lcd_init();
display();
while(1);
}
128x64的单色位图