这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » STM32 » 12864液晶图片显示

共14条 1/2 1 2 跳转至

12864液晶图片显示

助工
2014-10-17 20:18:44     打赏
最近在学习12864液晶显示,汉字和字符挺顺手的,可是显示图片的程序不懂,下面是我写的图片的程序,显示什么都没有,望大神们帮找找错误,能分享一下视频,资料,显示图片的例程就更好了!在此先谢过了!
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar n,m;
uchar code tu32[]={
  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,0x24,
0xC8,0x00,0x74,0x54,0x7C,0x54,0x7C,0x54,0x74,0x04,0x00,0x88,0x88,0xE8,0xA8,0xA8,
0xAC,0xA8,0xA8,0xE8,0x88,0x88,0x00,0x10,0xF0,0x1C,0xF0,0x10,0x10,0x10,0xFC,0x10,
0x10,0x10,0x00,0x10,0xF0,0x1C,0xF0,0x00,0xF8,0xA8,0xAC,0xA8,0xF8,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,0x80,0x40,0x40,0x40,0x80,0x80,
0x40,0x40,0x40,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x80,0x80,0x00,0x80,0x80,0x80,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x1F,0x00,0x14,0x0D,0x05,0x15,0x1D,0x05,0x0D,0x14,0x00,0x11,0x10,0x08,0x06,0x02,
0x02,0x02,0x1E,0x10,0x10,0x1D,0x00,0x13,0x0A,0x04,0x0B,0x00,0x1F,0x11,0x11,0x11,
0x11,0x1F,0x00,0x10,0x0B,0x04,0x0B,0x00,0x1F,0x10,0x0B,0x04,0x0A,0x11,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,0x80,0x60,0x10,0x8C,0x82,0x41,0xA0,0x60,0x18,0x80,0x44,0x22,
0x22,0x44,0x80,0x01,0x84,0x42,0x22,0x24,0x40,0x8C,0x30,0x42,0x81,0x80,0x00,0x00,
0x00,0x07,0x78,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
0x91,0x55,0xF5,0x5D,0x57,0x55,0x55,0xD5,0x11,0x10,0x00,0x11,0x16,0xF0,0x04,0x14,
0x64,0x04,0x04,0xFF,0x04,0x04,0x00,0x20,0x22,0x2A,0xB2,0x62,0xFF,0x62,0xB2,0x2A,
0x22,0x20,0x00,0x00,0x1C,0x7E,0x7E,0x1C,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,0x01,0x01,0xF1,0x0C,0x02,0x01,0xE0,0x10,0x08,0x09,0x12,0x94,
0x97,0x2B,0x29,0x28,0x21,0x12,0x14,0x17,0x23,0xC1,0xE0,0x10,0x00,0x00,0x01,0x03,
0x0D,0xF2,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x00,0x07,0x05,0x05,0x05,0x05,0x07,0x00,0x80,0x80,0x84,0x02,0x01,0x02,0x84,
0x84,0x85,0x85,0x05,0x84,0x84,0x80,0x02,0x02,0x01,0x80,0x80,0x87,0x80,0x00,0x01,
0x02,0x02,0x00,0x00,0x00,0x03,0x03,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,0x03,0x84,0xC8,0xD0,0x55,0x2A,0x34,0x24,0x49,
0x49,0x90,0x90,0x93,0x93,0x48,0x48,0x64,0x53,0x40,0x20,0x21,0x50,0xD0,0xC8,0x8C,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x21,0x4C,0x82,0x00,0x01,0x03,0x01,0x00,
0x80,0xC0,0x7F,0x21,0x4C,0x82,0x00,0x01,0x03,0x01,0x00,0x80,0xC0,0x61,0x3F,0x1E,
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,0x38,0x3C,0x3E,0x37,0x23,0x00,0x07,0x08,0x17,0x2D,0x0D,0x07,
0x03,0x01,0x03,0x03,0x01,0x03,0x07,0x0D,0x0D,0x07,0x20,0x10,0x08,0x07,0x00,0x23,
0x37,0x3E,0x3C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x06,0x03,
0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x06,0x03,0x01,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,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,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,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,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,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,
};

sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit psb = P2^3;
sbit rst = P2^4;

/***************延时函数***********************/	 
void delay(uint ms)
{
	uint a,b;
	for	(a=ms;a>0;a--)
		for(b=110;b>0;b--);
}

/****************写指令************************/
void com(uchar com)
{
	rs=0;		 //rs拉低为写入指令
	rw=0;		 //选择写操作
	P0=com;		 //往P0口送数据
	delay(5);	 //稍微延时保证数据都送过去
	en=1;		 //使能端拉高写入数据
	delay(5);	 
	en=0;		  //锁存数据
}

/****************写数据************************/
void dat(uchar dat)
{
	rs=1;		 //rs拉低为写入数据
	rw=0;		 //选择写操作
	P0=dat;		 //往P0口送数据
	delay(5);	 //稍微延时保证数据都送过去
	en=1;		 //使能端拉高写入数据
	delay(5);	 
	en=0;		  //锁存数据
}

/***************初始化init函数*****************/
void init()
{
	psb=1;      //设置数据为并行口方式
	com(0x30);	  //初始启动
	delay(5);
	com(0x0e);     //显示开关,打开光标和反白
	delay(5);
	com(0x01);     //清除指令
	delay(5);
}

/***************显示函数********************
void display()
{
	uint i;
com(0x80);
for(i=0;i<622;i++)
{
	dat(tu32[i]);
	delay(2);
}
}

/***************清除GCRAM里的内容,防止花屏*****/
void clear_gcrom()
{
	uchar i,j,k;
	m=n=0x80;
	com(0x34);
	for(i=0;i<2;i++)
	{
		for(j=0;j<32;j++)
		{
			com(m+j);
			com(n);
			for(k=0;k<16;k++)
			{
				dat(0x00);
			}
		}
		n=0x88;
	}
	com(0x36);
	com(0x30);
}

/***************显示图片**********************/
void displaytu(uchar *p)
{
	uchar i,j,k;
	m=n=0x80;
	com(0x34);
	for(i=0;i<2;i++)
	{
		for(j=0;j<32;j++)
		{
			com(m+j);
			com(n);
			for(k=0;k<16;k++)
			{
				dat(*p++);
			}
		}
		n=0x88;
	}
	com(0x36);
	com(0x30);
}

/*****************主函数**********************/
void main()
{
	init();
	displaytu(tu32);
	while(1);
}

 




关键词: 12864     液晶     图片     显示    

专家
2014-10-17 20:21:08     打赏
2楼
将图片转化为数组进行显示

助工
2014-10-17 20:24:26     打赏
3楼
对呀!已经转化了!

专家
2014-10-18 09:58:57     打赏
4楼
可以试着显示动画

工程师
2014-10-18 10:29:09     打赏
5楼
有个小工具是取模用的。。。大概是这样,另外你这个不显示,应该是时序延时有可能不对,你尝试显示一下汉子试试。

院士
2014-10-18 17:36:40     打赏
6楼
楼主 可以查阅一下液晶屏的资料,一般在屏的手册里有如何初始化屏,如何显示图片的示例。

高工
2014-10-19 10:35:27     打赏
7楼
首先不先直接显示图片,,可以先写个清屏。就是将所有像素点全部写0或者全部写1试试。

菜鸟
2014-10-27 17:16:43     打赏
8楼

助工
2014-11-04 16:30:06     打赏
9楼
已经搞定了!

高工
2014-11-04 17:37:22     打赏
10楼

ID不错。坚持就是成功的第一步


共14条 1/2 1 2 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]