微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > s3c2440之LCD字符显示

s3c2440之LCD字符显示

时间:11-11 来源:互联网 点击:

*/
void Draw_Text24(U32 x,U32 y,U32 color,const unsigned char ch[])

{

unsigned short int i,j;

unsigned char mask,buffer;

for(i=0;i<24;i++)

{

mask=0x80; /*掩码*/

buffer=ch[i*3]; /*提取一行的第一个字节*/

for(j=0;j<8;j++)

{

if(buffer&mask)

{

PutPixel(x+j,y+i,color); /*为笔画上色*/

}

mask=mask>>1;

}

mask=0x80; /*掩码*/

buffer=ch[i*3+1]; /*提取一行的第二个字节*/

for(j=0;j<8;j++)

{

if(buffer&mask)

{

PutPixel(x+j+8,y+i,color); /*为笔画上色*/

}

mask=mask>>1;

}
mask=0x80;
buffer=ch[i*3+2];
for(j=0;j<8;j++)

{

if(buffer&mask)

{

PutPixel(x+j+16,y+i,color); /*为笔画上色*/

}

mask=mask>>1;

}

}

}

/*绘制大小为8×16的ASCII码*/

void Draw_ASCII(U32 x,U32 y,U32 color,const unsigned char ch[])

{

unsigned short int i,j;

unsigned char mask,buffer;

for(i=0;i<16;i++)

{

mask=0x80;

buffer=ch[i];

for(j=0;j<8;j++)

{

if(buffer&mask)

{

PutPixel(x+j,y+i,color);

}

mask=mask>>1;

}

}

}

/*LCD初始化*/

void LCD_Init()

{
/*设置LCD引脚*/
rGPCUP = 0x00000000;

rGPCCON = 0xaaaa02a9;

rGPDUP = 0x00000000;

rGPDCON=0xaaaaaaaa;

rLCDCON1=(CLKVAL_TFT<8)|(MVAL_USED<7)|(PNRMODE_TFT<5)|(BPPMODE_TFT<1)|0;

rLCDCON2=(VBPD<24)|(LINEVAL<14)|(VFPD<6)|(VSPW);

rLCDCON3=(HBPD<19)|(HOZVAL<8)|(HFPD);

rLCDCON4=(HSPW);

rLCDCON5 = (BPP24BL<12) | (INVVCLK<10) | (INVVLINE<9) | (INVVFRAME<8) | (0<7) | (INVVDEN<6) | (PWREN<3) |(BSWP<1) | (HWSWP);

rLCDSADDR1=(((U32)LCD_BUFFER>>22)<21)|M5D((U32)LCD_BUFFER>>1);

rLCDSADDR2=M5D( ((U32)LCD_BUFFER+(LCD_WIDTH*LCD_HEIGHT*4))>>1 );

rLCDSADDR3=LCD_WIDTH*4/2;

rLCDINTMSK|=(3);

rTCONSEL = 0;

rGPGUP=rGPGUP&(~(1<4))|(1<4);

rGPGCON=rGPGCON&(~(3<8))|(3<8);

rGPGDAT = rGPGDAT | (1<4) ;

rLCDCON5=rLCDCON5&(~(1<3))|(1<3);

rLCDCON5=rLCDCON5&(~(1<5))|(0<5);

}

void Main(void)

{

LCD_Init();

rLCDCON1|=1; /*开启LCD显示*/

Brush_Background(0xFFFFFF); /*绘制白色背景*/

/*绘制黑色字符*/

Draw_Text16(50,100,0xff,ning);

Draw_Text16(74,100,0xff00,bo);

Draw_Text16(96,100,0xffff00,da);

Draw_Text16(120,100,0xff0000,xue);

Draw_ASCII(50,130,0x0,ASCII_A);

Draw_ASCII(62,130,0x0,ASCII_R);

Draw_ASCII(74,130,0x0,ASCII_M);

while(1)

{

;

}

}


效果图:

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top