一乐电子

一乐电子百科

 找回密码
 请使用微信账号登录和注册会员

QQ登录

只需一步,快速开始

快捷登录

手机号码,快捷登录

搜索
查看: 3689|回复: 15
收起左侧

前几天的320x240 RA8835 点亮了。。发帖庆贺一下。。。

[复制链接]
发表于 2014-4-23 11:52 | 显示全部楼层 |阅读模式
如题:
稍后传上代码。
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 ); //μ&#227;&#206;&#187;ò&#198;éè&#214;&#195;
    DataWrite( 0 );
    CmdWrite( Ovlay ); //&#207;&#212;ê&#190;o&#207;3ééè&#214;&#195;
    DataWrite( 0x04); //ò&#187;&#199;&#248;&#206;&#196;±&#190;·&#189;ê&#189;£&#172;&#198;&#228;&#203;&#251;í&#188;D&#206;£&#172;òì&#187;ò·&#189;ê&#189;
          CmdWrite( 0x4c ); //éè&#214;&#195;1a±êóòò&#198;  

    CmdWrite( DispOn );
    DataWrite( 0x54 ); //&#207;&#212;ê&#190;&#187;-&#195;&#230;2&#187;éá&#203;&#184;£&#172;1&#216;1a±ê&#207;&#212;ê&#190;
}

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);                                // ??????
        }
}




评分

参与人数 1一乐金币 +40 收起 理由
fujiachun + 40 很给力!

查看全部评分

发表于 2014-4-23 11:54 | 显示全部楼层
本帖最后由 hysy 于 2014-4-23 11:56 编辑

上图才是关键。又是黑白屏吧,我手里也有个老的黑白屏,还是高压背光。懒得摆弄了,除了耗电多使用麻烦,没有别的特色。
发表于 2014-4-23 12:04 | 显示全部楼层
用硬封装控制器的屏还是很容易玩起来的,驱动容易,也不怕找不到资料。

只是现在还有几个人喜欢单色屏呢?
发表于 2014-4-23 12:21 | 显示全部楼层
2楼真理,上图才是关键
发表于 2014-4-23 12:45 | 显示全部楼层
贴上来的注解都乱码,求上完整程序学习学习
发表于 2014-4-23 14:25 | 显示全部楼层
玩黑白屏就复古的感觉,,
发表于 2014-4-23 14:32 | 显示全部楼层
我还是比较喜欢黑白屏或者EL之类的屏,至少在某些专业领域我认为挺好的
发表于 2014-4-23 16:16 | 显示全部楼层
无论什么屏,点亮了就是高手
发表于 2014-4-23 17:21 | 显示全部楼层
上图,是什么样的屏都,不知道
 楼主| 发表于 2014-4-23 17:52 | 显示全部楼层

本版积分规则

QQ|一淘宝店|手机版|商店|电子DIY套件|一乐电子 ( 粤ICP备09076165号 ) 公安备案粤公网安备 44522102000183号

GMT+8, 2024-5-15 13:38 , Processed in 0.076046 second(s), 46 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表