⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd44b0.c

📁 ucgui在44b0上移植
💻 C
📖 第 1 页 / 共 2 页
字号:
/**********************************************************---------------------------------------------------------File	: lcd44b0.cPurpose	: S3C44B0X的lcd控制器的驱动,用于uC/GUIData	: 2003-7-9 13:46---------------------------------------------------------2003-7-31 13:52------完成4,16级灰度支持********************************************************* */#include <stddef.h>           /* needed for definition of NULL */#include "LCD_Private.H"      /* private modul definitions & config */#include "GUI_Private.H"#include "GUIDebug.h"#include "LCD_0.h"            /* Defines for first display *///********************************************************//#include <string.h>#include "..\inc\44b.h"#include "..\inc\44blib.h"#include "..\inc\def.h"//********************************************************#if (LCD_CONTROLLER == 0 ) && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))/***********************************************************                                                       **           Compiler specific settings                  **                                                       ***********************************************************/#ifdef WIN32   /* Avoid warnings in MS-compiler */  	#pragma warning(disable : 4244)  // warning C4244: '=' : conversion from 'long ' to 'unsigned char ', possible loss of data  	#pragma warning(disable : 4761)  // warning C4761: integral size mismatch in argument; conversion supplied#endif/***********************************************************                                                       **           Defaults for configuration                  **                                                       ***********************************************************/#define   COLOR LCD_COLORINDEX#ifdef LCDMONO	U32 (*frameBuffer1)[SCR_XSIZE/32];#endif#ifdef LCDG4	U32 (*frameBuffer4)[SCR_XSIZE/16];#endif#ifdef LCDG16	U32 (*frameBuffer16)[SCR_XSIZE/8];#endif#ifdef LCDCOLOR	U32 (*frameBuffer256)[SCR_XSIZE/4];#endif/***********************************************************                                                       **       Internal set pixel routines                     **                                                       ***********************************************************/static void SetPixel(int x, int y, LCD_PIXELINDEX c) {	//	c=LCD_NUM_COLORS-1-c;//黑白	#ifdef LCDMONO	    if(x<SCR_XSIZE && y<SCR_YSIZE)		frameBuffer1[(y)][(x)/32]=( frameBuffer1[(y)][(x)/32] & ~(0x80000000>>((x)%32)*1) )            | ( (c)<< ((32-1-((x)%32))*1) );#endif//4级灰度#ifdef LCDG4    if(x<SCR_XSIZE && y<SCR_YSIZE)        frameBuffer4[(y)][(x)/16]=( frameBuffer4[(y)][x/16] & ~(0xc0000000>>((x)%16)*2) )            | ( (c)<<((16-1-((x)%16))*2) );#endif//16级灰度#ifdef LCDG16    unsigned char X_Table[]={3,2,1,0,7,6,5,4};	if(x<SCR_XSIZE && y<SCR_YSIZE)        frameBuffer16[(y)][(x)/8]=( frameBuffer16[(y)][x/8] & ~(0xF0000000>>((X_Table[(x)%8]))*4) )            | ( (c)<<((8-1-(X_Table[(x)%8]))*4) );#endif//256色#ifdef LCDCOLOR	if(x<SCR_XSIZE && y<SCR_YSIZE)        frameBuffer256[(y)][(x)/4]=( frameBuffer256[(y)][x/4] & ~(0xff000000>>((x)%4)*8) )            | ( (c)<<((4-1-((x)%4))*8) );#endif}unsigned int GetPixelIndex(int x, int y) {    LCD_PIXELINDEX col;//黑白	#ifdef LCDMONO  	col=( frameBuffer1[(y)][(x)/32] >> ( 32-1-(x%32)*1 ) ) & 0x1;  	return col;#endif//4级灰度#ifdef LCDG4	col=( frameBuffer4[(y)][(x)/16] >> ( 32-2-(x%16)*2 ) ) & 0x3;  	return col;#endif//16级灰度#ifdef LCDG16	col=( frameBuffer16[(y)][(x)/8] >> ( 32-4-(x%8)*4 ) ) & 0xf;  	return col;#endif//256色#ifdef LCDCOLOR	col=( frameBuffer256[(y)][(x)/4] >> ( 32-8-(x%4)*8 ) ) & 0xff;  	return col;#endif}static void XorPixel   (int x, int y) {    LCD_PIXELINDEX Index = GetPixelIndex(x,y);    SetPixel(x,y,LCD_NUM_COLORS-1-Index);}/***********************************************************                                                       **       LCD_L0_XorPixel                                 **                                                       **********************************************************Purpose:  This routine is called by emWin. It writes 1 pixel into the          display.*/void LCD_L0_XorPixel(int x, int y) {  	XorPixel(x, y);}void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {  	SetPixel(x, y, ColorIndex);}/***********************************************************                                                       **          LCD_L0_DrawHLine optimized                   **                                                       **          16 bit bus, Using BITBLT                     **                                                       ***********************************************************/void LCD_L0_DrawHLine  (int x0, int y,  int x1) {  	if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)   	{    	while (x0 <= x1)     	{      		XorPixel(x0, y);      		x0++;    	}  	} else   	{    	while (x0 <= x1)     	{      		SetPixel(x0, y, COLOR);      		x0++;    	}  	}}/***********************************************************                                                       **          LCD_L0_DrawVLine optimized                   **                                                       **          16 bit bus, using BITBLT                     **                                                       ***********************************************************/void LCD_L0_DrawVLine  (int x, int y0,  int y1) {  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {    while (y0 <= y1) {      XorPixel(x, y0);      y0++;    }  } else {    while (y0 <= y1) {      SetPixel(x, y0, COLOR);      y0++;    }  }}/***********************************************************                                                       **          LCD_FillRect                                 **                                                       ***********************************************************/void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {#if !LCD_SWAP_XY  for (; y0 <= y1; y0++) {    LCD_L0_DrawHLine(x0,y0, x1);  }#else  for (; x0 <= x1; x0++) {    LCD_L0_DrawVLine(x0,y0, y1);  }#endif}/************************************************************                                                        **		  Draw a line                                    **                                                        ************************************************************/static void  DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {//  	LCD_PIXELINDEX aColor[2];  	U16 Pixels = ((*p) << 8) | (*(p + 1));  	U8 RemPixels;  	p++;//  	aColor[0] = *pTrans;//  	aColor[1] = *(pTrans + 1);  	x += Diff;  	RemPixels = 16 - Diff;  	Pixels <<= Diff;    	if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {    	do {      		if (RemPixels==0) {        		Pixels = ((*(p + 1)) << 8) | (*(p + 2));        		p += 2;        		RemPixels = 16;      		}      		if (Pixels & 0x8000) {        		XorPixel(x, y);      		}      		RemPixels--;      		Pixels <<=1;      		x++;    	} while (--xsize);  	}   	else {    	do {      		if (RemPixels==0) {        		Pixels = ((*(p + 1)) << 8) | (*(p + 2));        		p += 2;        		RemPixels = 16;      		}      		if (Pixels & 0x8000) {        		SetPixel(x, y, *(pTrans+1));      		}      		RemPixels--;      		Pixels <<=1;      		x++;    	} while (--xsize);  	} }/*    *********************************************    *                                           *    *      Draw Bitmap 2 BPP                    *    *                                           *    **********************************************/#if (LCD_MAX_LOG_COLORS > 2)static void  DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {  LCD_PIXELINDEX pixels;/*// Jump to right entry point*/  pixels = *p;  if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) {  case 0:    goto WriteTBit0;  case 1:    goto WriteTBit1;  case 2:    goto WriteTBit2;  default:    goto WriteTBit3;  } else switch (Diff&3) {  case 0:    goto WriteBit0;  case 1:    goto WriteBit1;  case 2:    goto WriteBit2;  default:    goto WriteBit3;  }/*        Write without transparency*/WriteBit0:  SetPixel(x+0, y, *(pTrans+(pixels>>6)));  if (!--xsize)    return;WriteBit1:  SetPixel(x+1, y, *(pTrans+(3&(pixels>>4))));  if (!--xsize)    return;WriteBit2:  SetPixel(x+2, y, *(pTrans+(3&(pixels>>2))));  if (!--xsize)    return;WriteBit3:  SetPixel(x+3, y, *(pTrans+(3&(pixels))));  if (!--xsize)    return;  pixels = *(++p);  x+=4;  goto WriteBit0;/*        Write with transparency*/WriteTBit0:  if (pixels&(3<<6))    SetPixel(x+0, y, *(pTrans+(pixels>>6)));  if (!--xsize)    return;WriteTBit1:  if (pixels&(3<<4))    SetPixel(x+1, y, *(pTrans+(3&(pixels>>4))));  if (!--xsize)    return;WriteTBit2:  if (pixels&(3<<2))    SetPixel(x+2, y, *(pTrans+(3&(pixels>>2))));  if (!--xsize)    return;WriteTBit3:  if (pixels&(3<<0))    SetPixel(x+3, y, *(pTrans+(3&(pixels))));  if (!--xsize)    return;  pixels = *(++p);  x+=4;  goto WriteTBit0;}#endif/*    *********************************************    *                                           *    *      Draw Bitmap 4 BPP                    *    *                                           *    **********************************************/#if (LCD_MAX_LOG_COLORS > 4)static void  DrawBitLine4BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {  U8 pixels;/*// Jump to right entry point*/  pixels = *p;  if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) {    if ((Diff&1) ==0)      goto WriteTBit0;    goto WriteTBit1;  } else {    if ((Diff&1) ==0)      goto WriteBit0;    goto WriteBit1;  }/*        Write without transparency

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -