这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » 44B0,320,240LCD 关于44B0驱动单色320 240LCD的问题

共2条 1/1 1 跳转至

44B0,320,240LCD 关于44B0驱动单色320 240LCD的问题

院士
2006-09-17 18:14:16     打赏
44B0,320,240LCD 关于44B0驱动单色320 240LCD的问题



关键词: 240LCD     关于     驱动     单色     问题    

院士
2006-12-22 22:43:00     打赏
2楼
1: 关于44B0驱动单色320 240LCD的问题现在在做44B0驱动单色320 240LCD
开发板自带的是彩色256色的程序,如下
LCD。H中的内容
#ifndef __LCD_H__
#define __LCD_H__
#include    "def.h"     

#define SCR_XSIZE     (320)  
#define SCR_YSIZE     (240)

#define COLOR_NUMBER 256

#define LCD_XSIZE     (320)
#define LCD_YSIZE     (240)

#define M5D(n) ((n) & 0x1fffff)
#define ARRAY_SIZE_COLOR     (SCR_XSIZE/1*SCR_YSIZE)
#define HOZVAL            (LCD_XSIZE/4-1)
#define HOZVAL_COLOR        (LCD_XSIZE*3/8-1)
#define LINEVAL            (LCD_YSIZE-1)
#define MVAL            (13)
#define CLKVAL_COLOR         (4) //60Mhz
#define MVAL_USED 0
#define LCD_BUF_SIZE (SCR_XSIZE * SCR_YSIZE)

extern INT32U aLcdActiveBuffer[LCD_YSIZE][LCD_XSIZE/4];

#define LCD_PutPixel(x, y, c)\
    aLcdActiveBuffer[(y)][(x)/4]=(( aLcdActiveBuffer[(y)][(x)/4] & (~(0xff000000>>((x)%4)*8)) ) | ( (c)<<((4-1-((x)%4))*8) ));
#define LCD_ActivePutPixel(x, y, c)\
    aLcdActiveBuffer[(y)][(x)/4]=(( aLcdActiveBuffer[(y)][(x)/4] & (~(0xff000000>>((x)%4)*8)) )\
    | ( (c)<<((4-1-((x)%4))*8) ));

#define GUISWAP(a, b) {a^=b; b^=a; a^=b;}
void Lcd_Init(void);
void Lcd_Clr(void);
void Lcd_Draw_Box (INT16 usLeft, INT16 usTop, INT16 usRight, INT16 USBottom, INT8U ucColor);
void Lcd_Draw_Line (INT16 usX0, INT16 usY0, INT16 usX1, INT16 usY1, INT8U ucColor, INT16U usWidth);
void Lcd_Draw_HLine (INT16 usX0, INT16 usX1, INT16 usY0, INT8U ucColor, INT16U usWidth);
void Lcd_Draw_VLine (INT16 usY0, INT16 usY1, INT16 usX0, INT8U ucColor, INT16U usWidth);
void Lcd_Fill_Box (INT16U usX0, INT16U usY0, INT16U usX1, INT16U usY1, INT8U ucColor);

#endif

初始化部分
void Lcd_Init (void)
{     
    //int i, j;
    //int time = 10000*2;
    
         rLCDCON1=(0x0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|        (CLKVAL_COLOR<<12);//0x4f40
        // disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
    rLCDCON2=(119)|(HOZVAL_COLOR<<10)|(10<<21);  
        //LINEBLANK=10 (without any calculation)
    rLCDSADDR1= (0x3<<27) | ( ((unsigned int)   aLcdActiveBuffer>>22)<<21 ) | M5D((unsigned int)aLcdActiveBuffer>>1);
        // 256-color, LCDBANK, LCDBASEU
    rLCDSADDR2= M5D((((unsigned int)aLcdActiveBuffer+ (SCR_XSIZE*LCD_YSIZE)/2)>>1)) | (MVAL<<21);
    rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );

    //The following value has to be changed for better display.

    rREDLUT  =0xfdb96420;
    rGREENLUT=0xfdb96420;
    rBLUELUT =0xfb40;

    //rDITHMODE=0x0;
    rDITHMODE    = 0x12210;
    rDP1_2 =0xa5a5;      
    rDP4_7 =0xba5da65;
    rDP3_5 =0xa5a5f;
    rDP2_3 =0xd6b;
    rDP5_7 =0xeb7b5ed;
    rDP3_4 =0x7dbe;
    rDP4_5 =0x7ebdf;
    rDP6_7 =0x7fdfbfe;

    rLCDCON1=(0x1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12); //enable
    //rLCDCON1=(0x1)|(2<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12); //enable
    rPDATE=0x1fe;
    Lcd_Clr();

疑问
1:原来的是用INT32U aLcdActiveBuffer[LCD_YSIZE][LCD_XSIZE/4];
LCD BUFFER SIZE是如何计算得到的,如换单色或其他色的如何改?#define LCD_BUF_SIZE (SCR_XSIZE * SCR_YSIZE)这个大小为什么与上面的不同?
2:#define M5D(n) ((n) & 0x1fffff) M5D做何用?
3:#define LCD_PutPixel(x, y, c)\
    aLcdActiveBuffer[(y)][(x)/4]=(( aLcdActiveBuffer[(y)][(x)/4] & (~(0xff000000>>((x)%4)*8)) ) | ( (c)<<((4-1-((x)%4))*8) ));
#define LCD_ActivePutPixel(x, y, c)\
    aLcdActiveBuffer[(y)][(x)/4]=(( aLcdActiveBuffer[(y)][(x)/4] & (~(0xff000000>>((x)%4)*8)) )\
    | ( (c)<<((4-1-((x)%4))*8) ));
这两个画点函数/4 *8 %4 怎么得来的?如为其他色应该如何修改?

问题有点多,不过还是希望哪位老兄给解答一下,先谢了!!

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]