📄 lcd44b0.c
字号:
*/WriteBit0: SetPixel(x+0, y, *(pTrans+(pixels>>4))); if (!--xsize) return;WriteBit1: SetPixel(x+1, y, *(pTrans+(pixels&0xf))); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteBit0;/* Write with transparency*/WriteTBit0: if (pixels>>4) SetPixel(x+0, y, *(pTrans+(pixels>>4))); if (!--xsize) return;WriteTBit1: if (pixels&0xf) SetPixel(x+1, y, *(pTrans+(pixels&0xf))); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteTBit0;}#endif/* ********************************************* * * * Draw Bitmap 8 BPP (256 colors) * * * **********************************************/#if (LCD_MAX_LOG_COLORS > 16)static void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans) { LCD_PIXELINDEX pixel; if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) { if (pTrans) { for (;xsize > 0; xsize--,x++,p++) { pixel = *p; SetPixel(x, y, *(pTrans+pixel)); } } else { for (;xsize > 0; xsize--,x++,p++) { SetPixel(x, y, *p); } } } else { /* Handle transparent bitmap */ if (pTrans) { for (; xsize > 0; xsize--, x++, p++) { pixel = *p; if (pixel) { SetPixel(x+0, y, *(pTrans+pixel)); } } } else { for (; xsize > 0; xsize--, x++, p++) { pixel = *p; if (pixel) { SetPixel(x+0, y, pixel); } } } }}#endif/*********************************************************** ** Universal draw Bitmap routine ** ***********************************************************/void LCD_L0_DrawBitmap (int x0, int y0, int xsize, int ysize, int BitsPerPixel, int BytesPerLine, const U8* pData, int Diff, const LCD_PIXELINDEX* pTrans) { int i; for (i=0; i<ysize; i++) { switch (BitsPerPixel) { case 1: DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans); break; #if (LCD_MAX_LOG_COLORS > 2) case 2: DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans); break; #endif #if (LCD_MAX_LOG_COLORS > 4) case 4: DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans); break; #endif #if (LCD_MAX_LOG_COLORS > 16) case 8: DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans); break; #endif } pData += BytesPerLine; }}/********************************************************* ** LCD_L0_SetOrg ** ********************************************************** Purpose: Sets the original position of the virtual display. Has no function at this point with the PC-driver.*/int OrgX, OrgY;void LCD_L0_SetOrg(int x, int y) { OrgX = x; OrgY = y;}/*********************************************************** ** LCD_On ** LCD_Off ** ***********************************************************/void LCD_Off (void) { Delay(100); rPDATC = ( rPDATC | (1<<8)); Delay(100);}void LCD_On (void) { Delay(100); rPDATC = ( rPDATC & (~(1<<8)) ); Delay(100);}/*************************************************************************LCD_Init_Controler()define how to Init LCD_Controler Onchip for deffrent LCD*************************************************************************/void LCD_Init_Controler() { int i,j;#ifdef LCDMONO //320x240 1bit/1pixel LCD if((U32)frameBuffer1==0) { frameBuffer1=(unsigned int (*)[SCR_XSIZE/32])malloc(ARRAY_SIZE_MONO); } for(j=0;j<240;j++) for(i=0;i<10;i++) { frameBuffer1[j][i]=0x0; } rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12); // disable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk, rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21); // LINEBLANK=10 rLCDSADDR1= (0x0<<27) | ( ((U32)frameBuffer1>>22)<<21 ) | M5D((U32)frameBuffer1>>1); // monochrome, LCDBANK, LCDBASEU rLCDSADDR2= M5D( (((U32)frameBuffer1+(SCR_XSIZE*LCD_YSIZE/8))>>1) ) | (MVAL<<21); // LCDBASSEL, MVAL rLCDSADDR3= (LCD_XSIZE/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 ); // PAGEWIDTH, OFFSIZE (the number of halfwords) // No virtual screen. rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12); // enable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk,#endif//********************************************************************************#ifdef LCDG4 if((U32)frameBuffer4==0) { frameBuffer4=(unsigned int (*)[SCR_XSIZE/16])malloc(ARRAY_SIZE_G4); } for(j=0;j<240;j++) for(i=0;i<20;i++) { frameBuffer4[j][i]=0x0; } rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G4<<12); // disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk, rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21); //LINEBLANK=10 (without any calculation) rLCDSADDR1= (0x1<<27) | ( ((U32)frameBuffer4>>22)<<21 ) | M5D((U32)frameBuffer4>>1); // 4-gray, LCDBANK, LCDBASEU rLCDSADDR2= M5D((((U32)frameBuffer4+(SCR_XSIZE*LCD_YSIZE/4))>>1)) | (MVAL<<21); rLCDSADDR3= (LCD_XSIZE/8) | ( ((SCR_XSIZE-LCD_XSIZE)/8)<<9 ); //The following value has to be changed for better display. //Select 4 levels among 16 gray levels. rBLUELUT=0xfa40; rDITHMODE=0x0; 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=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G4<<12); // enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk, #endif//********************************************************************************#ifdef LCDG16 if((U32)frameBuffer16==0) { frameBuffer16=(unsigned int (*)[SCR_XSIZE/8])malloc(ARRAY_SIZE_G16); } for(j=0;j<LCD_YSIZE;j++){ for(i=0;i<(LCD_XSIZE/8);i++) { frameBuffer16[j][i]=0x0; } } //The following value has to be changed for better display./* rDITHMODE=0x1223a; //philips rDP1_2 =0x5a5a; rDP4_7 =0x366cd9b; rDP3_5 =0xda5a7; rDP2_3 =0xad7; rDP5_7 =0xfeda5b7; rDP3_4 =0xebd7; rDP4_5 =0xebfd7; rDP6_7 =0x7efdfbf;*/ rDITHMODE=0x12210; //rDITHMODE=0x0; 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=(0)|(0<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x0<<10)|(CLKVAL_G16<<12); // disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk, rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21); //LINEBLANK=10 (without any calculation) rLCDSADDR1= (0x2<<27) | ( ((U32)frameBuffer16>>22)<<21 ) | M5D((U32)frameBuffer16>>1); // 16-gray, LCDBANK, LCDBASEU rLCDSADDR2= M5D((((U32)frameBuffer16+(SCR_XSIZE*LCD_YSIZE/4))>>1)) | (MVAL<<21)|(0<<29); rLCDSADDR3= (LCD_XSIZE/4) | ( ((SCR_XSIZE-LCD_XSIZE)/4)<<9 ); rLCDCON1=(1)|(0<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G16<<12); // enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,#endif#ifdef LCDCOLOR if((U32)frameBuffer256==0) { //The total frame memory should be inside 4MB. //For example, if total memory is 8MB, the frame memory //should be in 0xc000000~0xc3fffff or c400000~c7fffff. //But, the following code doesn't meet this condition(4MB) //if the code size & location is changed.. frameBuffer256=(unsigned int (*)[SCR_XSIZE/4])malloc(ARRAY_SIZE_COLOR); } rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12); // disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk, rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21); //LINEBLANK=10 (without any calculation) rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1); // 256-color, LCDBANK, LCDBASEU rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>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; 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=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12); // enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,#endif}unsigned int LCD_L0_GetPixelIndex(int x, int y) { return GetPixelIndex(x,y);}/*********************************************************** ** LCD_L0_SetLUTEntry ** ***********************************************************/void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {}/*********************************************************** ** LCD_L0_ReInit : Re-Init the display ** **********************************************************ReInit contains all of the code that can be re-executed at any point withoutchanging or even disturbing what can be seen on the LCD.Note that it is also used as a subroutine by LCD_Init().*/void LCD_L0_ReInit(void) { LCD_Init_Controler(); /* macro defined in config */}/*********************************************************** ** LCD_Init : Init the display ** ***********************************************************/int LCD_L0_Init(void) { GUI_DEBUG_LOG("\nLCD_Init()"); /* Init controllers (except lookup table) */ LCD_L0_ReInit(); LCD_Off(); return 0; /* Init successfull ! */}/*********************************************************** ** LCD_L0_CheckInit ** ** Check if display controller(s) is/are still ** properly initialized ** **********************************************************Return value: 0 => No error, init is O.K.*/int LCD_L0_CheckInit(void) { return 0;}#elsevoid LCD13XX(void) { } /* avoid empty object files */#endif /* (LCD_CONTROLLER == 0) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -