基于89c52的nokia5110图片显示(测试过)

#include

/* https://www.360docs.net/doc/9d18332193.html, 雨亭电子
代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M晶振 单片机工作电压3.3V
程序默认IO连接方式:
sce-P0^0; res-P0^1; dc-P0^2; sdin-P1^5; sclk-P1^7;
*/

sbit sce = P2^0; //片选
sbit res = P2^1; //复位,0复位
sbit dc = P2^2; //1写数据,0写指令
sbit sdin = P2^3; //数据
sbit sclk = P2^4; //时钟



unsigned char code hanzi[]=
{
/*-- 调入了一幅图像:C:\Users\Administrator.PC-20111029FWWQ\Desktop\logo.bmp --*/
/*-- 宽度x高度=103x49 --*/
/*-- 高度不是8的倍数,现调整为:宽度x高度=103x56 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xE0,0xE0,0xE0,0xF0,0x70,
0x70,0x30,0x38,0x38,0x18,0x18,0x1C,0x0C,0x0C,0x0C,0x0E,0x86,0x86,0xC6,0xC6,0xE6,
0xE3,0xF3,0xF3,0xF3,0xFB,0xFB,0xF8,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF8,0xF8,0xF8,0xF0,0xF0,0xF0,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x06,0x06,0x8C,0xFC,0xF8,0xF8,0xF8,0xF0,0xE0,
0xC0,0x9C,0x3E,0x3F,0x3F,0x3E,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0xC0,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0x1F,0x0F,0x07,
0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00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F,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,
0x0F,0x0F,0x07,0x87,0xC3,0xC1,0xC0,0x40,0x60,0x60,0x60,0x30,0x30,0x30,0x18,0x18,
0x1C,0x0C,0x0E,0x06,0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x30,0xF0,
0xE0,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x00,0x01,0x01,0x01,0x03,0xE3,0xF3,0xF2,
0x06,0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,

0x30,0xF0,0xF0,0x00,0x00,0x00,0x00,0xE0,0xF0,0x30,0xF0,0xF0,0x00,0x00,0x00,0x00,
0x00,0xF0,0xF0,0xE0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0xF0,0xF0,0xE0,0x00,0x00,0x00,0xE0,0xF0,
0x30,0xF0,0xE0,0xE3,0xE7,0x8E,0xFC,0xF8,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x80,0x80,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xE0,0xE0,0x00,0x00,0x00,0x00,0xFF,0xFF,
0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x80,0x00,0x00,
0x00,0x00,0xF0,0xFF,0x3F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFB,0x00,0x00,0x00,0xE3,0xE7,0x8E,0xFC,0xF8,0x01,0x01,0x01,0x01,0x01,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x01,0x01,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x01,

};

void delayms(unsigned int ii)//1ms延时函数
{
unsigned int i,x;
for (x=0;x{
for (i=0;i<100;i++);
}
}

/*--------------------------------------------
LCD_write_byte: 使用SPI接口写数据到LCD
输入参数:dt:写入的数据;
command :写数据/命令选择;
编写日期:20080918
----------------------------------------------*/
void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce=0;
dc=command;
for(i=0;i<8;i++)
{
if(dt&0x80)
sdin=1;
else
sdin=0;
dt=dt<<1;
sclk=0;
sclk=1;
}
dc=1;
sce=1;
sdin=1;
}
/*---------------------------------------
LCD_init: 3310LCD初始化
编写日期:20080918
----------------------------------------- */
void LCD_init(void)
{
res=0;
delayms(10);
res=1;
LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令
LCD_write_byte(0xC6,0);//设定液晶偏置电压
LCD_write_byte(0x06,0);//温度校正
LCD_write_byte(0x13,0);;//1:48
LCD_write_byte(0x20,0);//使用基本指令
LCD_write_byte(0x0C,0);//设定显示模式,正常显示
}
/*-------------------------------------------
LCD_set_XY: 设置LCD坐标函数
输入参数:X:0-83 Y:0-5
编写日期:20080918
---------------------------------------------*/
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
/*------------------------------------------
LCD_clear: LCD清屏函数
编写日期:20080918
----

----------------------------------------*/
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);

}
}
}
void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y)
{
unsigned int i,n;
unsigned char row;
//计算位图所占行数
if (Pix_y%8==0) //如果为位图所占行数为整数
row=Pix_y/8;
else
row=Pix_y/8+1; //如果为位图所占行数不是整数

LCD_set_XY(X,Y);
for (n=0;n{
for(i=0;i{
LCD_set_XY(X+i,Y+n);
LCD_write_byte(map[i+n*Pix_x], 1);
}
}
}


main()
{

unsigned char k;
sce=0;
res=0;
for(k=0;k<250;k++);
res=1;
LCD_init(); //初始化LCD模块
LCD_clear(); //清屏幕
LCD_draw_bmp_pixel(0,0,hanzi,103,56);




while(1)
{

delayms(5000);
}
}

相关文档
最新文档