黄金会员
主题
帖子
积分6738
阅读权限40
注册时间2012-6-26
最后登录1970-1-1
在线时间 小时
|
如题:
稍后传上代码。
1:gnd
2:VCC
3:VHIN
4:WR
5:RD
6:CS
7:A0
8:RESET
9:D0
10:D1
11:D2
12:D3
13:D4
14:D5
15:D6
16:D7
17:VLED
18:VHOUT
void CmdWrite(unsigned int Data )
{
MCU_CSL;
//DelayUs(1);
MCU_A0H;
//DelayUs(1);
DrvGPIO_SetPortBits(E_GPA,Data);
//DelayUs(1);
MCU_WRL;
//DelayUs(1);
MCU_WRH;
//DelayUs(1);
//MCU_CSH;
}
void DataWrite(unsigned int Data )
{
MCU_CSL;
//DelayUs(1);
MCU_A0L;
//DelayUs(1);
DrvGPIO_SetPortBits(E_GPA,Data);
//DelayUs(1);
MCU_WRL;
//DelayUs(1);
MCU_WRH;
//DelayUs(1);
MCU_CSH;
}
unsigned char DataRead(void )
{
unsigned char dat;
MCU_CSL;
//DelayUs(1);
MCU_A0L;
DrvGPIO_SetPortBits(E_GPA,0xffff);
//DelayUs(1);
dat= DrvGPIO_GetPortBits(E_GPA)&0x00ff;
//DelayUs(1);
MCU_WRL;
//DelayUs(1);
MCU_WRH;
//DelayUs(1);
MCU_CSH;
return dat;
}
//oˉêy1|Äü: òo¾§ÆáÇå 32K RAM oˉêy,·′ó3μ½ÆáÄ»¼′ÎaÇåÆá
// μ«ò»°ãÇåÆá2»DèòaÇåËùóD 32K RAM,Õa¸öìØêa
//èë¿ú2Îêy: ÎT
//3ö¿ú2Îêy: ÎT
void FullScreenFill(unsigned char low,unsigned char high,unsigned char fill_data)
{
unsigned char i,j;
CmdWrite(0x46);
DataWrite(low);
DataWrite(high);
CmdWrite(0x42);
for(i=0;i<240;i++)
{
for(j=0;j<40;j++)
{
DataWrite(fill_data);
}
}
}
void LcdInit(void)
{
MCU_CSL;
MCU_RSL;
DelayMs(100);
MCU_RSH;
DelayMs(100);
CmdWrite(SystemSet);
DataWrite(0x32);
DataWrite(0x87);
DataWrite(0x07);
DataWrite(0x27);
DataWrite(0x42);
DataWrite(0xf0);
DataWrite(0x28);
DataWrite(0x00);
CmdWrite(Scroll );
CmdWrite(Scroll );
DataWrite(0x00);
DataWrite(0x00);
DataWrite(0xF0); //?? f0
DataWrite(0x00);
DataWrite(0x40);
DataWrite(0xF0); //??
DataWrite(0x00);
DataWrite(0x80); //??
DataWrite(0x00);
DataWrite(0x00); //??
CmdWrite( HdotScr ); //μãλòÆéèÖÃ
DataWrite( 0 );
CmdWrite( Ovlay ); //ÏÔê¾oÏ3ééèÖÃ
DataWrite( 0x04); //ò»ÇøÎı¾·½ê½£¬ÆäËûí¼DΣ¬òì»ò·½ê½
CmdWrite( 0x4c ); //éèÖÃ1a±êóòòÆ
CmdWrite( DispOn );
DataWrite( 0x54 ); //ÏÔê¾»-Ãæ2»éá˸£¬1Ø1a±êÏÔê¾
}
void LcmLocateXY(unsigned char x,unsigned char y)
{
unsigned int temp,locateH,locateL;
temp = (unsigned int)y*paraP9+x;
locateL = (unsigned char)(temp & 0xff);
locateH = (unsigned char)(temp / 256 );
if( LcmLayer == 2 ) { locateH = locateH + 0x40; }
if( LcmLayer == 3 ) { locateH = locateH +0x80; }
CmdWrite( CsrW );
DataWrite( locateL );
DataWrite( locateH );
}
void Locatexy(unsigned char x,unsigned char y, unsigned char attribs)
{
unsigned int temp;
temp = (unsigned int)y*paraP9+x;
if(attribs)temp += BasePart2*256;
CmdWrite( CsrW ); // ??Locate,??
DataWrite( (unsigned char)(temp & 0xff) ); // ????CSRL?????????8?
DataWrite( (unsigned char)(temp /256 ) ); // ????CSRH?????????8?
}
void Point(unsigned int Px, unsigned char Py, unsigned char attr )
{
unsigned int tempPtr;
unsigned char tempD,tempP;
tempPtr = (unsigned int)Py * paraP9 + (Px & 0x7fff)/8;
CmdWrite( CsrDirD );
CmdWrite( CsrW );
DataWrite( (unsigned char)(tempPtr & 0xff) );
DataWrite( (unsigned char)(tempPtr /256) );
CmdWrite( mRead );
tempD = DataRead();
tempP = 1<<(unsigned char)(7-Px & 0x0007);
// ?????????????
if( attr )tempD |= tempP; // ??
else tempD &= ~tempP; // ??
CmdWrite( CsrW );
DataWrite((unsigned char)(tempPtr & 0xff) );
DataWrite((unsigned char)(tempPtr /256) );
CmdWrite( mWrite ); // ??0x42,??????
DataWrite( tempD ); // ??????
}
void circle(unsigned int Ox,unsigned char Oy,unsigned char Rx,unsigned char attr)
{
unsigned int xx,rr,xt,yt,rs,col,row;
yt=Rx;
rr=Rx*Rx+1;
rs=(yt+(yt>>1))>>1;
for (xt=0;xt<=rs;xt++)
{
xx=xt*xt;
while ((yt*yt)>(rr-xx))yt--;
col=Ox+xt; //????
row=Oy-yt;
Point(col,row,attr);
col=Ox-xt; //????
Point(col,row,attr);
row=Oy+yt; //????
Point(col,row,attr);
col=Ox+xt; //????
Point(col,row,attr);
/***************45???????***************/
col=Ox+yt; //????
row=Oy-xt;
Point(col,row,attr);
col=Ox-yt; //????
Point(col,row,attr);
row=Oy+xt; //????
Point(col,row,attr);
col=Ox+yt; //????
Point(col,row,attr);
}
}
void Linexy(unsigned int x0,unsigned char y0,unsigned int xt,unsigned char yt,unsigned char att)
{
register unsigned char t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy;
unsigned int row,col;
delta_x = xt-x0; //??????
delta_y = yt-y0;
col = x0;
row = y0;
if(delta_x>0) incx=1; //??????
else
{
if( delta_x==0 ) incx=0; //???
else {incx=-1;delta_x=-delta_x;}
}
if(delta_y>0) incy=1;
else
{
if( delta_y==0 ) incy=0;
else {incy=-1;delta_y=-delta_y;}
}
if( delta_x > delta_y ) distance=delta_x;
else distance=delta_y;
for( t=0;t <= distance+1; t++ )
{
Point((unsigned int)col,row,att);
xerr += delta_x ;
yerr += delta_y ;
if( xerr > distance )
{
xerr-=distance;
col+=incx;
}
if( yerr > distance )
{
yerr-=distance;
row+=incy;
}
}
}
void TextDisp( unsigned char Ox,unsigned char Oy, unsigned char *ptr )
{
unsigned char TexLength=0,ii;
unsigned int iTemp;
while(ptr[TexLength]>0x1f) {TexLength++;}; // ??????
iTemp = Oy*paraP9+Ox;
CmdWrite( CsrForm ); // ??????,??0x5d
DataWrite( 0x07 ); // ????????CSX=8
DataWrite( 0x07 ); // ???????,????CSY=8
CmdWrite( Ovlay ); // ????????.??0x5b
DataWrite( 0x01 ); // ????:??3??????,??xor??
CmdWrite( DispOn ); // ????DISP ON/OFF??,????:
DataWrite( 0x56 ); // 01 01 01 10??1~4????,??????
iTemp = (unsigned int)Oy * paraP9 + Ox; // ???????ram????
CmdWrite( CsrDirR ); // ????????
CmdWrite( CsrW ); // ??????
DataWrite( (unsigned char)(iTemp &0xff) ); // ??????CSR
DataWrite( (unsigned char)(iTemp /256 + BasePart3) ); // ??????????SAD2H
CmdWrite( mWrite ); // ??????????
for(ii=0;ii < TexLength;ii++)
{
DataWrite( ptr[ii] ); // ????????
}
}
void PutCdotInGraph( unsigned int Ox, unsigned char Oy, unsigned char Cnumber, unsigned char DotWidth ) {
unsigned int tempPtr,Optr;
unsigned char tempCount1,tempCount2,nByte;
Optr = (unsigned int)Oy * paraP9 + Ox;
nByte = DotWidth/8;
CmdWrite( CsrDirD );
tempPtr = (unsigned int)Cnumber * DotWidth*nByte;
for (tempCount1=0;tempCount1<nByte;tempCount1++) {
CmdWrite( CsrW );
DataWrite( (unsigned char)(Optr &0xff) );
DataWrite( (unsigned char)(Optr /256 ) );
CmdWrite( mWrite );
switch(DotWidth)
{
case 16: for(tempCount2=0;tempCount2<DotWidth;tempCount2++)
{
DataWrite( Cdotlib[tempCount2*2+tempCount1] ); // ????
}
break;
case 24: for(tempCount2=0;tempCount2<DotWidth;tempCount2++)
{
DataWrite( Cdot24lib[tempPtr] ); // ????
tempPtr += nByte;
}
break;
}
tempPtr = Cnumber * DotWidth*nByte + tempCount1 + 1;
Optr++;
}
}
unsigned char dprintf(unsigned char x,unsigned char y, char *ptr, unsigned char att)
{
unsigned char c1,c2;
unsigned char i,j,uLen,uRow,uCol,temp;
unsigned int k;
uRow = x;
uCol = y;
uLen=0;
CmdWrite( CsrDirD ); // ????????:????
Locatexy(uRow,uCol,att); //????
while ( (unsigned char)ptr[uLen] >= 0x10 ){uLen++;}; //??????
i=0;
while(i<uLen)
{
c1 = ptr[i];
c2 = ptr[i+1];
//ascii????????????128???,?????????
if(c1 <=128) // ASCII
{
if (c1 >= 0x10) {
CmdWrite( mWrite ); // ???(??)
for(j=0;j<16;j++) DataWrite( ASC_MSK[(c1-0x20)*16 +j ]);
}
uRow++; // ???1
}
else // ??
{
for(j=0;j < (sizeof(Cdotlib))/sizeof(Cdotlib[0]);j++) // ????
{
if((c1 == Cdotlib[temp*2 + k]) && (c2 == Cdotlib[temp + k])) break;
}
for(k=0;k<2;k++) // ?16???
{
Locatexy(uRow+k,uCol,att);
CmdWrite( mWrite ); // ???(??)
for(temp=0;temp<16;temp++) DataWrite( Cdotlib[temp*2 + k]);
}
uRow +=2; // ???????
i++;
}
if(uRow >= 40) // ????
{
uCol += 16; // Y??
uRow = 0; // X??
if( uCol >= 240 ) uCol = 0;
}
Locatexy(uRow,uCol,att);
i++;
}
return uLen; //??????,???2????
}
// ?????????
void PutCdotInAlpha( unsigned char Ox, unsigned char Oy, unsigned char Cnumber ) {
unsigned int tempPtr;
unsigned char tempCount;
tempPtr = (unsigned int)Oy * paraP9 + Ox;
CmdWrite( CsrDirD ); // CSRDIR ??(??)
for(tempCount=0;tempCount<2;tempCount++) {
CmdWrite( CsrW ); // CSRW ??,??????
DataWrite( (unsigned char)(tempPtr &0xff) ); // ??????CSR
DataWrite( tempPtr /256 + BasePart3 );
CmdWrite( mWrite ); // ??0x42,??????
DataWrite( Cnumber++ ); // ??????
DataWrite( Cnumber++ ); // ??????
tempPtr++; // ??????
}
}
void RollLaft( void )
{
unsigned char tempI,jj=25;
unsigned int iTemp=0;
while(jj--) {
for(tempI=0;tempI<8;tempI++) {
CmdWrite( HdotScr ); // ??HDOT SET ??
DataWrite( tempI ); // ????
DelayMs(20); // ??????
}
iTemp ++;
CmdWrite( Scroll ); // ??????????
DataWrite( (unsigned char)(iTemp & 0xff) ); // ????
DataWrite( (unsigned char)(iTemp /256) ); // ????
}
}
// ?????????
void Rollright( void ) {
unsigned char tempI,jj=25;
unsigned int iTemp=24;
while(jj--) {
tempI = 8;
CmdWrite( Scroll ); // ????(??)??
DataWrite( (unsigned char)(iTemp & 0xff) ); // ????
DataWrite( (unsigned char)(iTemp /256) ); // ????
while( tempI-- ) {
CmdWrite( HdotScr ); // ??HDOT SET ??
DataWrite( tempI ); // ????
DelayMs(20); // ??????
}
iTemp--;
}
}
// ?????????
void RollDown( void ) {
unsigned char jj = 50; // ??32?
unsigned int iTemp=paraP9*50;
while(jj--)
{
iTemp -= paraP9;
CmdWrite( Scroll ); // ??????????
DataWrite( (unsigned char)(iTemp & 0xff) ); // ????
DataWrite( (unsigned char)(iTemp /256) ); // ????
DelayMs(20);
}
CmdWrite( Scroll );
DataWrite( 0 );
DataWrite( 0 );
}
// ?????????
void RollUp( void ) {
unsigned int iTemp=0;
unsigned char jj = 50; // ??30?
while(jj--) {
iTemp += paraP9;
CmdWrite( Scroll ); // ??????????
DataWrite( (unsigned char)(iTemp & 0xff) ); // ????
DataWrite( (unsigned char)(iTemp /256) ); // ????
DelayMs(30); // ??????
}
}
|
评分
-
查看全部评分
|