S3C2440-LCD图片显示

哈尔滨理工大学软件工程专业08-7李万鹏原创作品,转载请标明出处

http://blog.csdn.net/woshixingaaa/archive/2010/12/23/6093448.aspx

折腾了几日,终于可以将图片显示在LCD上了,我使用的东华的WXCAT35-TG3#001 TFT LCD。首先使用PHOTOSHOP软件将图片改成宽320,高240,注意不要反了。然后用Image2Lcd_32软件提取出数组。我选的是24位真彩。所以一个像素3个字节,显示的时候,通过位运算将3个字节合到一起,显示在一个像素上。

Image2Lcd_32的配置方法:

#include "2440addr.h" #include "picture.h" //垂直同步信号的脉宽、后肩和前肩 #define VSPW 15 #define VBPD 3 #define VFPD 5 //水平同步信号的脉宽、后肩和前肩 #define HSPW 8 #define HBPD 58 #define HFPD 15 #define CLKVAL 10 #define HOZVAL 319 #define LINEVAL 239 #define PWREN 1 #define MMODE 0 #define PNRMODE 3 #define BPPMODE 13 #define INVVCLK 0 #define INVVD 0 #define INVVDEN 0 #define U32 unsigned int #define M5D(n) ((n) & 0x1fffff) #define PAGEWIDTH 320 #define OFFSIZE 0 #define LCD_XSIZE 320 #define LCD_YSIZE 240 #define SCR_XSIZE 320 #define SCR_YSIZE 240 #define INVVLINE 1 #define INVVFRAME 1 #define BPP24BL 0 #define BSWP 0 #define HWSWP 0 volatile U32 LCD_BUFFER[240][320]; void Init_LCD(){ rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0; //设置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],决定VM的触发方式,选择显示模式和BPP模式,暂时不要开启LCD,因为还没有设置好 rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4主要设置时序 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); //INVVLINE和INVVFRAME需要进行翻转,因为CPU发出的是正脉冲,LCD使用的是负脉冲,所以要改变极性,PWREN使能电源信号 rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1); rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 ); rLCDSADDR3=PAGEWIDTH*32/16; rLCDINTMSK|=(3); rTCONSEL = 0; rGPCUP = 0x0; rGPDCON = 0xaaaaaaaa; rGPCCON = 0xaaaa02a9; rGPDUP = 0x0; rGPGUP=rGPGUP&(~(1<<4))|(1<<4); rGPGCON=rGPGCON&(~(3<<8))|(3<<8); rLCDCON1 |= 1; //使能数据输出和LCD控制信号 } void Paint(unsigned char ch[]){ int y, x, t = 0; for(y = 0; y < LCD_YSIZE; y++) for(x = 0; x < LCD_XSIZE; x++){ LCD_BUFFER[y][x] = (ch[t]<<16)|(ch[t+1]<<8)|(ch[t+2]); //因为是24位真彩,所将3个字节赋值到一个像素点上 t = t + 3; } } void Paint_background(U32 c){ unsigned int i, j; for(j = 0; j < LCD_YSIZE; j++) for(i = 0; i < LCD_XSIZE; i++) LCD_BUFFER[j][i] = c; } int LcdMain(){ Init_LCD(); Paint_background(0xFFFFFF); Paint(picture); //picture是从图片中提取出来的数组 while(1); }

你可能感兴趣的:(S3C2440-LCD图片显示)