正点原子7寸液晶屏V1.8版(与V1版除了触屏接口有点改动外,其他没变),在以连续模式写入数据时出现头几个像素点与后面的像素点在颜 {MOD}上有很大反差,主要是体现在红 {MOD}和白 {MOD}时是这样。
举个例子:我要以红 {MOD}刷屏,我设定起始坐标 CUR_Y=0,CUR_X=0;自动折返点
END_X =799;然后我往其像素数据寄存器PIXEL连续写入0xf800(红 {MOD}),头几个点(约10个像素左右)亮度叫大,后续的数据偏暗。在使用白 {MOD}刷屏时依然如此。
然而,我采用单独写入的方式时颜 {MOD}是正常的。即我每一次写入数据前都对
CUR_Y、CUR_X、
END_X这几个寄存器重新设定。
另外,测试视频如下:
http://v.youku.com/v_show/id_XMTM4ODIwNDczNg==.html
好了,直接上图。
下面是图片重复显示,图像的背景本是白 {MOD},但是由于是连续写入,背景有些偏蓝
下图当中的背景为白 {MOD}的图片显示采用的是非连续方式,很显然这才是正常的数据。
好了,直接上STC90C516代码:
const unsigned char code gImage_pic2[13720] = { /* 0X00,0X10,0X46,0X00,0X62,0X00,0X01,0X1B, */
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,0X18,0XC6,
}
上面是图片数据,由于太多页面装不下所以只上一部分数据。
下面是51单片机源代码,供大家学习交流只用,完全自编:
#include<reg52.h>
#include"pic2.h"
#define CUR_Y 0X0000
#define CUR_X 0X0001
#define PIXEL 0X0002
#define END_X 0X0003
#define NONE0 0X0004
#define PREF 0X0005
#define NONE1 0X0006
#define MIRRO 0X0007
#define data0 P0
#define Addr0 P0
#define data1 P1
#define Addr1 P1
sbit NEC=P2^0;
sbit RS =P2^1;
//sbit WR =P3^6;
//sbit RD =P3^7;
sbit RST=P2^4;
sbit MISO=P2^5;
sbit MISI=P2^6;
sbit PEN =P2^7;
/****************************/
/*Basic function */
/****************************/
void nop(void)
{
int time=1;
while(time--);
}
void delay(long int time)
{
while(time--)
{
nop();
}
}
/******************************/
/*Function:Reset the LCD */
/******************************/
void RstLCD(void)
{
RST=0;
nop();
nop();
nop();
nop();
nop();
nop();
nop();
RST=1;
while((data0&0X01)!=0X01);
}
/******************************/
/*Function:Write address */
/******************************/
void WriteAddressLCD( int com)
{
WR=1;
NEC=0;
RD=1;
RS=0;
Addr0=(unsigned char)(0x00ff&com);
Addr1=(unsigned char)((0xff00&com)>>8);
nop();
WR=0;
nop();
WR=1;
NEC=1;
}
/******************************/
/*Function:Write data */
/******************************/
void WriteDataLCD( int Data)
{
WR=1;
NEC=0;
RD=1;
RS=1;
Addr1=( char)((Data&0xff00)>>8);
Addr0=( char)(Data&0x00ff);
nop();
WR=0;
nop();
WR=1;
NEC=1;
}
/************************************/
/*Function:Set operate page, display*/
/*page, light degeray */
/************************************/
void SetBasicParameterLCD(int OperatPage,int DisplayPage,int Light)
{
unsigned Temp;
Temp=DisplayPage<<9|OperatPage<<12|Light;
WriteAddressLCD(PREF);
WriteDataLCD(Temp);
}
/*********************************/
/*Function:Set the display zone */
/*********************************/
void SetZone(int X,int Y,int Turn)
{
WriteAddressLCD(CUR_X);
WriteDataLCD(X);
WriteAddressLCD(CUR_Y);
WriteDataLCD(Y);
WriteAddressLCD(END_X);
WriteDataLCD(Turn);
}
int ReadPixelDataLCD(void)
{
int temp0,temp1,temp;
char temp00;
WR=1;
RS=0;
nop();
NEC=0;
RD=1;
nop();
RD=0;
nop();
do
{
temp00=P0;
//temp1=P1;
}while((temp00&0x01)!=0x01);
RD=1;
//WR=1;
nop();
//RD=1;
//nop();
//NEC=0;
//nop();
RS=1;
nop();
RD=0;
nop();
temp0=data0;
temp1=data1;
nop();
RD=1;
temp=temp1<<8|temp0;
NEC=1;
return temp;
}
/*********************************/
/*Funtion:Read the pixel data for*/
/*continuously */
/*********************************/
char *ReadPictue(int StartX,int StartY,int EndX,int wideX,int highY,char *counst)
{
int x,y,temp0,temp1,*address;
char temp00;
address=counst;
SetZone(StartX,StartY,EndX);
for(y=0;y<highY;y++)
{
for(x=0;x<wideX*2;x=x+2)
{
/*************************************/
WR=1; //Check
RS=0; //whether
nop(); //if
NEC=0; //LCD
RD=1; //is
nop(); //busy
RD=0; //or
nop(); //not
do //
{ //
temp00=P0; //
//temp1=P1; //
}while((temp00&0x01)!=0x01); //
RD=1; //
RS=1; //
/*************************************/
RD=0;
nop();
temp0=data0;
temp1=data1;
nop();
RD=1;
//counst=counst+x+y;
counst[x+y]=temp0;
//counst=counst+1;
counst[x+y+1]=temp1;
}
}
NEC=1;
return address;
}
/*********************************/
/*Function:Brush the screen */
/*********************************/
void BrushLCD(int OperatPage,int DisplayPage,int Light,int color)
{
long int i;
SetBasicParameterLCD(OperatPage,DisplayPage,Light);
SetZone(0,0,799);
WriteAddressLCD(PIXEL);
WR=1;
NEC=0;
RD=1;
RS=1;
//P0=0XFF;
//while((P0&0x01)!=0x01);
Addr1=(char)((color&0xff00)>>8);
Addr0=(char)( color&0x00ff) ;
for(i=0;i<384000;i++)
{
nop();
WR=0;
nop();
WR=1;
}
WR=1;
NEC=1;
}
/*********************************/
/*Function
isplay a picture */
/*which is wideX multiply highY */
/*********************************/
void PictureLCD( int OperatPage,int DisplayPage,int Light,char *pic,long int wideX,long int highY,int x,int y)
{
long int i;
unsigned int p;
SetBasicParameterLCD(OperatPage, DisplayPage, Light);
WriteAddressLCD(CUR_X);
WriteDataLCD(x);
WriteAddressLCD(CUR_Y);
WriteDataLCD(y);
WriteAddressLCD(END_X);
WriteDataLCD(x+wideX-1);
WriteAddressLCD(PIXEL);
for(i=0;i<wideX*highY*2;i=i+2)
{
p=pic[i+1]<<8|pic
;
WriteDataLCD(p);
}
}
void main(void)
{
long int i,j,k;
int da;
char ta[140],*ad;
delay(10);
delay(10);
RstLCD();
for(k=0;k<4;k++)
{
PictureLCD(0,0,0x003f,gImage_pic2,70,100,0,k*100);
for(j=1;j<11;j++)
{
for(i=0;i<100;i++)
{
ad=ReadPictue(0,k*100+i,70,70,1,ta);
PictureLCD(0,0,0x003f,ad,70,1,j*70,k*100+i);
}
}
}
delay(100000);
for(j=0;j<100;j++)
{
for(i=0;i<70;i++)
{
SetZone(i,j,70);
da=ReadPixelDataLCD();
SetZone(80+i,j,80+70);
WriteAddressLCD(PIXEL);
WriteDataLCD(da);
}
}
delay(100000);
SetBasicParameterLCD(0,1,0x003f);
WriteAddressLCD(MIRRO);
delay(10000);
WriteDataLCD(2);
delay(10000);
WriteDataLCD(3);
delay(10000);
WriteDataLCD(0);
delay(10000);
WriteDataLCD(1);
BrushLCD(0x0000,0x0000,0x003f,0xffff);
BrushLCD(0x0000,0x0000,0x003f,0xf800);
BrushLCD(0x0000,0x0000,0x003f,0x001f);
for(j=0;j<100;j++)
{
for(i=0;i<70;i++)
{
SetZone(i,j,70);
da=ReadPixelDataLCD();
SetZone(80+i,j,80+70);
WriteAddressLCD(PIXEL);
WriteDataLCD(da);
}
}
BrushLCD(0x0000,0x0000,0x003f,0x07e0);
BrushLCD(0x0000,0x0000,0x003f,0xf800);
for(j=0;j<100;j++)
{
for(i=0;i<70;i++)
{
SetZone(i,j,70);
da=ReadPixelDataLCD();
SetZone(80+i,j,80+70);
WriteAddressLCD(PIXEL);
WriteDataLCD(da);
}
}
delay(999999);
//1,Red
BrushLCD(0x0001,0x0001,0x003f,0xf801);
for(i=1;i<8;i++)
{
BrushLCD(i,i,0x003f,i*20);
}
while(1)
{
for(i=0;i<8;i++)
{
SetBasicParameterLCD(0,i,0x003f);
delay(100000);
}
}
}
---------------------------------
事实上视频后期的颜 {MOD}值已经不是0xf800了,另外我相信写入的颜 {MOD}数据绝对是正确的,因为我将写入LCD的图像数据读出一个点来然后采用单独写点的方法在LCD新的区域重现,这样连续读一个写一个,整图片的颜 {MOD}又恢复正常了。
一周热门 更多>