首页 > 代码库 > 12864显示图片
12864显示图片
/******************************************************************************
功能简介: 本程序驱动12864显示一副的图片。
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*12864端口定义*/
#define LCD_data P0 //数据口
sbit LCD_RS = P3^5; //寄存器选择输入
sbit LCD_RW = P3^6; //液晶读/写控制
sbit LCD_EN = P3^4; //液晶使能控制
sbit LCD_PSB = P3^7; //串/并方式控制
sbit wela = P2^6;
sbit dula = P2^7;
unsigned char code zhu[]= //图片代码
{
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
0x95,0x55,0x48,0x80,0x00,0x00,0x00,0x00,0x2B,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xA8,0x00,0x22,0x15,0x20,0x00,0x00,0x00,0x97,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,
0x45,0x55,0x08,0xA0,0x00,0x00,0x00,0x0A,0x6F,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x80,0x40,0x00,0x04,0x40,0x00,0x00,0xBA,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x4D,0x55,0x15,0x15,0x20,0x00,0x00,0x95,0xD5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xE8,0x40,0x40,0x00,0x00,0x00,0x4A,0xAA,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x2A,0x00,0x40,0x00,0x00,0x15,0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFD,0xD0,0xAA,0x01,0x00,0x00,0x25,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xB6,0x00,0x10,0x00,0x01,0x4A,0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFD,0xE8,0x50,0x00,0x00,0x11,0x00,0x24,0x84,0x00,0x00,0x00,0x00,0x00,
0xAB,0xFF,0xFF,0x55,0x00,0x00,0x00,0x24,0x02,0x49,0x5E,0xA0,0x00,0x00,0x00,0x00,
0x84,0xBF,0xFF,0xF4,0x88,0x00,0x00,0x00,0x10,0x05,0xFF,0xF4,0x00,0x00,0x00,0x00,
0x29,0x0B,0xFF,0xFA,0x20,0x00,0x00,0x00,0x02,0xBF,0xFF,0xFC,0x00,0x00,0x00,0x00,
0x44,0xA0,0x57,0xFD,0x80,0x00,0x00,0x00,0x08,0x5F,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x91,0x0A,0xAA,0xF6,0x50,0x00,0x00,0x00,0x41,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
0x44,0xA0,0x01,0x1B,0x84,0x00,0x00,0x00,0x26,0xFF,0xFF,0xFF,0x90,0x00,0x00,0x00,
0x11,0x0A,0xAA,0x6D,0x68,0x00,0x00,0x00,0x0B,0xFB,0xFF,0xEF,0xE0,0x00,0x00,0x00,
0xC4,0xA0,0x01,0x02,0x82,0x00,0x00,0x00,0x43,0xF1,0xFE,0x63,0xF0,0x00,0x00,0x00,
0x15,0x55,0x54,0x55,0x6A,0x00,0x00,0x00,0x9F,0xE3,0xFC,0x87,0x38,0x00,0x00,0x00,
0xCA,0xAB,0x91,0x00,0x90,0x00,0x00,0x00,0x07,0xC1,0xFA,0x2A,0x80,0x00,0x00,0x00,
0x25,0xFF,0xFE,0x95,0x2A,0x00,0x00,0x00,0x2F,0x13,0xFE,0xFC,0x10,0x00,0x00,0x00,
0x95,0xFF,0xFF,0xC0,0x50,0x00,0x00,0x00,0x0F,0x41,0xFF,0xF3,0x80,0x00,0x00,0x00,
0x4F,0xFF,0xFF,0xF9,0x2A,0x08,0x00,0x00,0x9F,0x08,0xFF,0xD4,0x00,0x00,0x00,0x00,
0xB3,0xFF,0xFF,0xFE,0x54,0x86,0x00,0x00,0x1E,0xA0,0x7F,0xA0,0x00,0x00,0x00,0x00,
0x5F,0xFE,0x7F,0xFE,0xAA,0x00,0x08,0x00,0x5F,0x57,0xFE,0x00,0x00,0x00,0x00,0x00,
0xAF,0xFD,0x7F,0xFF,0x94,0x80,0x00,0x00,0x1F,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFA,0x7F,0x5F,0xCA,0x00,0x00,0x06,0x3F,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xAF,0xF1,0x7F,0xDE,0xF5,0x40,0x00,0x00,0x1A,0xA0,0x80,0x00,0x00,0x00,0x00,0x00,
0xDF,0xF2,0x3F,0xFC,0xC2,0x00,0x00,0x00,0x50,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x2F,0xFA,0xBF,0xFF,0xF4,0xA0,0x00,0x00,0x05,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
0x97,0xFE,0x3F,0xFF,0xE3,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x68,0xFF,0xDF,0xD5,0x78,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x5F,0xFF,0x48,0x02,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD0,0xAA,0xF4,0xA0,0xAA,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x45,0x09,0x05,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA1,0x28,0xA0,0x00,0x44,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x42,0x04,0x52,0x12,0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA5,0x09,0x51,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x50,0x04,0x4A,0x12,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xAA,0x05,0x50,0x21,0x48,0x20,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x90,0x02,0x84,0x12,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD4,0x05,0x48,0x10,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x81,0x20,0x00,0x02,0x02,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA4,0x84,0x92,0x48,0x94,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x48,0x10,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xEE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x8D,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFE,0x80,0x00,0x00,0x03,0x00,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0xC0,0x00,0x00,0x06,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x38,0x00,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x0C,0x03,0xE0,0xB8,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x07,0xFF,0xFF,0xF0,0x00,0xB0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x28,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x80,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
void delay0(uchar x); //x*0.14MS
void beep();
void dataconv();
void lcd_pos(uchar X,uchar Y); //确定显示位置
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<250;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/*******************************************************************/
/* */
/*检查LCD忙状态 */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。 */
/* */
/*******************************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
/*******************************************************************/
/* */
/*写指令数据到LCD */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */
/* */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/*写显示数据到LCD */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。 */
/* */
/*******************************************************************/
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/* LCD初始化设定 */
/* */
/*******************************************************************/
void lcd_init()
{
LCD_PSB = 1; //并口方式
lcd_wcmd(0x34); //扩充指令操作
delay(5);
lcd_wcmd(0x30); //基本指令操作
delay(5);
lcd_wcmd(0x0C); //显示开,关光标
delay(5);
lcd_wcmd(0x01); //清除LCD的显示内容
delay(5);
}
/*******************************************
函数名称:Draw_PM
功 能:在整个液晶屏幕上画图
参 数:无
返回值 :无
********************************************/
void Draw_PM(const uchar *ptr)
{
uchar i,j,k;
wela=0;
dula=0;
lcd_wcmd(0x34); //打开扩展指令集
i = 0x80;
for(j = 0;j < 32;j++)
{
lcd_wcmd(i++);
lcd_wcmd(0x80);
for(k = 0;k < 16;k++)
{
lcd_wdat(*ptr++);
}
}
i = 0x80;
for(j = 0;j < 32;j++)
{
lcd_wcmd(i++);
lcd_wcmd(0x88);
for(k = 0;k < 16;k++)
{
lcd_wdat(*ptr++);
}
}
lcd_wcmd(0x36); //打开绘图显示
lcd_wcmd(0x30); //回到基本指令集
}
main()
{
wela=0;
dula=0;
lcd_init(); //初始化LCD
Draw_PM(zhu); //显示可爱猪的图片
while(1);
}
功能简介: 本程序驱动12864显示一副的图片。
************************************************************************************/
用取模软件来实现
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*12864端口定义*/
#define LCD_data P0 //数据口
sbit LCD_RS = P3^5; //寄存器选择输入
sbit LCD_RW = P3^6; //液晶读/写控制
sbit LCD_EN = P3^4; //液晶使能控制
sbit LCD_PSB = P3^7; //串/并方式控制
sbit wela = P2^6;
sbit dula = P2^7;
unsigned char code zhu[]= //图片代码
{
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
0x95,0x55,0x48,0x80,0x00,0x00,0x00,0x00,0x2B,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xA8,0x00,0x22,0x15,0x20,0x00,0x00,0x00,0x97,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,
0x45,0x55,0x08,0xA0,0x00,0x00,0x00,0x0A,0x6F,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x80,0x40,0x00,0x04,0x40,0x00,0x00,0xBA,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x4D,0x55,0x15,0x15,0x20,0x00,0x00,0x95,0xD5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xE8,0x40,0x40,0x00,0x00,0x00,0x4A,0xAA,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x2A,0x00,0x40,0x00,0x00,0x15,0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFD,0xD0,0xAA,0x01,0x00,0x00,0x25,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xB6,0x00,0x10,0x00,0x01,0x4A,0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFD,0xE8,0x50,0x00,0x00,0x11,0x00,0x24,0x84,0x00,0x00,0x00,0x00,0x00,
0xAB,0xFF,0xFF,0x55,0x00,0x00,0x00,0x24,0x02,0x49,0x5E,0xA0,0x00,0x00,0x00,0x00,
0x84,0xBF,0xFF,0xF4,0x88,0x00,0x00,0x00,0x10,0x05,0xFF,0xF4,0x00,0x00,0x00,0x00,
0x29,0x0B,0xFF,0xFA,0x20,0x00,0x00,0x00,0x02,0xBF,0xFF,0xFC,0x00,0x00,0x00,0x00,
0x44,0xA0,0x57,0xFD,0x80,0x00,0x00,0x00,0x08,0x5F,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x91,0x0A,0xAA,0xF6,0x50,0x00,0x00,0x00,0x41,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
0x44,0xA0,0x01,0x1B,0x84,0x00,0x00,0x00,0x26,0xFF,0xFF,0xFF,0x90,0x00,0x00,0x00,
0x11,0x0A,0xAA,0x6D,0x68,0x00,0x00,0x00,0x0B,0xFB,0xFF,0xEF,0xE0,0x00,0x00,0x00,
0xC4,0xA0,0x01,0x02,0x82,0x00,0x00,0x00,0x43,0xF1,0xFE,0x63,0xF0,0x00,0x00,0x00,
0x15,0x55,0x54,0x55,0x6A,0x00,0x00,0x00,0x9F,0xE3,0xFC,0x87,0x38,0x00,0x00,0x00,
0xCA,0xAB,0x91,0x00,0x90,0x00,0x00,0x00,0x07,0xC1,0xFA,0x2A,0x80,0x00,0x00,0x00,
0x25,0xFF,0xFE,0x95,0x2A,0x00,0x00,0x00,0x2F,0x13,0xFE,0xFC,0x10,0x00,0x00,0x00,
0x95,0xFF,0xFF,0xC0,0x50,0x00,0x00,0x00,0x0F,0x41,0xFF,0xF3,0x80,0x00,0x00,0x00,
0x4F,0xFF,0xFF,0xF9,0x2A,0x08,0x00,0x00,0x9F,0x08,0xFF,0xD4,0x00,0x00,0x00,0x00,
0xB3,0xFF,0xFF,0xFE,0x54,0x86,0x00,0x00,0x1E,0xA0,0x7F,0xA0,0x00,0x00,0x00,0x00,
0x5F,0xFE,0x7F,0xFE,0xAA,0x00,0x08,0x00,0x5F,0x57,0xFE,0x00,0x00,0x00,0x00,0x00,
0xAF,0xFD,0x7F,0xFF,0x94,0x80,0x00,0x00,0x1F,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFA,0x7F,0x5F,0xCA,0x00,0x00,0x06,0x3F,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xAF,0xF1,0x7F,0xDE,0xF5,0x40,0x00,0x00,0x1A,0xA0,0x80,0x00,0x00,0x00,0x00,0x00,
0xDF,0xF2,0x3F,0xFC,0xC2,0x00,0x00,0x00,0x50,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x2F,0xFA,0xBF,0xFF,0xF4,0xA0,0x00,0x00,0x05,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
0x97,0xFE,0x3F,0xFF,0xE3,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x68,0xFF,0xDF,0xD5,0x78,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x5F,0xFF,0x48,0x02,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD0,0xAA,0xF4,0xA0,0xAA,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x45,0x09,0x05,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA1,0x28,0xA0,0x00,0x44,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x42,0x04,0x52,0x12,0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA5,0x09,0x51,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x50,0x04,0x4A,0x12,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xAA,0x05,0x50,0x21,0x48,0x20,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x90,0x02,0x84,0x12,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD4,0x05,0x48,0x10,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x81,0x20,0x00,0x02,0x02,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA4,0x84,0x92,0x48,0x94,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x48,0x10,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xEE,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x8D,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFE,0x80,0x00,0x00,0x03,0x00,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0xC0,0x00,0x00,0x06,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x38,0x00,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x0C,0x03,0xE0,0xB8,0x00,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x07,0xFF,0xFF,0xF0,0x00,0xB0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x28,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x80,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
void delay0(uchar x); //x*0.14MS
void beep();
void dataconv();
void lcd_pos(uchar X,uchar Y); //确定显示位置
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<250;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/*******************************************************************/
/* */
/*检查LCD忙状态 */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。 */
/* */
/*******************************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
/*******************************************************************/
/* */
/*写指令数据到LCD */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */
/* */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/*写显示数据到LCD */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。 */
/* */
/*******************************************************************/
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/* LCD初始化设定 */
/* */
/*******************************************************************/
void lcd_init()
{
LCD_PSB = 1; //并口方式
lcd_wcmd(0x34); //扩充指令操作
delay(5);
lcd_wcmd(0x30); //基本指令操作
delay(5);
lcd_wcmd(0x0C); //显示开,关光标
delay(5);
lcd_wcmd(0x01); //清除LCD的显示内容
delay(5);
}
/*******************************************
函数名称:Draw_PM
功 能:在整个液晶屏幕上画图
参 数:无
返回值 :无
********************************************/
void Draw_PM(const uchar *ptr)
{
uchar i,j,k;
wela=0;
dula=0;
lcd_wcmd(0x34); //打开扩展指令集
i = 0x80;
for(j = 0;j < 32;j++)
{
lcd_wcmd(i++);
lcd_wcmd(0x80);
for(k = 0;k < 16;k++)
{
lcd_wdat(*ptr++);
}
}
i = 0x80;
for(j = 0;j < 32;j++)
{
lcd_wcmd(i++);
lcd_wcmd(0x88);
for(k = 0;k < 16;k++)
{
lcd_wdat(*ptr++);
}
}
lcd_wcmd(0x36); //打开绘图显示
lcd_wcmd(0x30); //回到基本指令集
}
main()
{
wela=0;
dula=0;
lcd_init(); //初始化LCD
Draw_PM(zhu); //显示可爱猪的图片
while(1);
}
12864显示图片
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。