这段时间对12864—5V带字库的图形模式和文本模式学习一段时间。我用的是STC12C5A60S2的单片机,板子就是普通的开发板 推荐用32系列较快,51单片机的扫描太慢了。效果图后面补上
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int //宏定义
#define LCD P0 //数据端口
sbit LCD_RS = P2^6; //指令/数据选择信号
sbit LCD_RW = P2^5; //读写选择信号
sbit LCD_EN = P2^7; //使能端
sbit LCD_PSB = P2^1; //串并端口/高电平为并行,低电平为串行
uchar code ai[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF0,0xA3,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x3E,0xD7,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xEF,0x39,0xFB,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xEF,0x41,0xFF,0xC0,0x1B,0x78,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0xEF,0x4E,0xDF,0xC0,0xFF,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0xEF,0x9F,0x73,0x0F,0xFF,0x7C,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x7F,0xCF,0x77,0x4F,0xFF,0xB8,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x3F,0x87,0xDC,0x7F,0xF3,0xCE,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1F,0x87,0x83,0xFF,0xE1,0xFE,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x06,0x8F,0x03,0xFF,0x00,0xF9,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xC3,0x8E,0x0F,0xFC,0x08,0xFE,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF9,0x0C,0x3F,0xF8,0x30,0xFF,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0xBE,0x7F,0xEC,0x60,0xFF,0x40,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x87,0xFF,0xF8,0xC4,0x9E,0x38,
0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x30,0x00,0x31,0xFD,0xFF,0x61,0xCD,0x9F,0xDC,
0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xEF,0xE0,0x73,0xF0,0xFD,0xC3,0x9F,0x8F,0xFC,
0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x60,0xFF,0xDF,0xFF,0x8F,0x07,0x1F,0xEF,0xF8,
0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x60,0x3F,0xBF,0x8F,0xEF,0xFE,0x3F,0xFF,0xF4,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x60,0x1F,0x9F,0x9C,0xFC,0xFF,0xFF,0xFF,0xF6,
0x00,0x00,0x00,0x00,0x07,0xFF,0xFC,0x60,0x0F,0x3F,0xBF,0xF8,0x30,0x73,0xFF,0xFF,
0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0x60,0x0F,0xFF,0xFF,0xE0,0xE0,0xF0,0x07,0xFF,
0x00,0x00,0x00,0x7F,0xFF,0x80,0x1F,0xEE,0x37,0xFF,0xC0,0x03,0xE1,0xE0,0x03,0xFB,
0x00,0x00,0xFF,0xFF,0xFF,0x00,0x03,0xFF,0xF7,0xFD,0xFC,0x0F,0xC3,0xE0,0x00,0xFE,
0x00,0x1F,0xFF,0xF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x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xC4,0xFF,0xFF,0xF1,0xB8,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0xE0,0x3D,0xFF,0xF9,0xF1,0xFF,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x3C,0x1F,0xFF,0xE1,0xFE,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x3C,0x07,0xFF,0xBC,0x7E,0x9F,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x3E,0x00,0xFF,0xB9,0xBC,0x20,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x7E,0x00,0x1F,0xB0,0xFF,0xFF,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x7E,0x00,0x00,0xF8,0x7F,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x7E,0x00,0x00,0x7E,0x2F,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0xFE,0x00,0x00,0x1F,0x84,0x00,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x3E,0x00,0x00,0x07,0xE6,0x00,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xC7,0x80,0x00,0x01,0xE3,0x00,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0xFE,0x00,0x00,0x61,0x00,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF8,0xE7,0x00,0x00,0x35,0x80,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x9F,0x80,0x1C,0x80,0x3C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xCF,0xC0,0x1E,0x80,0x3C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF3,0x47,0xEF,0xFF,0x80,0x7C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0xFF,0xE3,0xFF,0xFF,0x00,0x7C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x60,0xFF,0xFC,0x00,0x38,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x3F,0x00,0x00,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFC,0x00,0x00,0x00,0xF0,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x00,0xF0,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,0xE0,0x00,0x00,0xF0,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0xE0,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x60,0x00,0x00
}; //图片数据
void delay(uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--)
;
}
void xiezhiling(uchar a) //写指令函数
{
LCD_RS=0; //输入指令/L
LCD_RW=0; //输入指令或数据
LCD=a;
delay(5);
LCD_EN=1;
delay(5);
LCD_EN=0;
}
void xieshuju(uchar a) //写数据函数
{
LCD_RS=1; //输入数据/H
LCD_RW=0;
LCD=a;
delay(5);
LCD_EN=1; //读取信息
delay(5);
LCD_EN=0;
}
void qingping() //清除RAM的数据,送入0
{
uchar x,y,a,b,c;
x=0x80;
y=0x80;
xiezhiling(0x34); // 关闭绘图功能
for(a=0;a<2;a++)
{
for(b=0;b<32;b++)
{
xiezhiling(y+b);
xiezhiling(x);
for(c=0;c<16;c++)
xieshuju(0x00);
}
x=0x88;
}
xiezhiling(0x36); //打开绘图功能
xiezhiling(0x30);
}
void tupian(uchar *p) //图片数据提取函数
{
uchar x,y,a,b,c;
xiezhiling(0x34); //关闭绘图功能
x=0x80;
y=0x80;
for(c=0;c<2;c++)
{
for(a=0;a<32;a++)
{
xiezhiling(y+a);
xiezhiling(x);
for(b=0;b<16;b++)
xieshuju(*p++);
}
x=0x88;
}
xiezhiling(0x36); //打开绘图功能
xiezhiling(0x30);
}
void init() //初始化函数
{
xiezhiling(0x30); //功能设定为基本指令
xiezhiling(0x0c); //显示开,游标关
xiezhiling(0x01); //清除显示
qingping(); //清屏
}
void main()
{
init();
tupian(ai);
while(1);
}