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

📄 glib.c

📁 Embest EudKit-II教学系统配Samsung S3C2410处理器的部分测试程序。
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************************************
* File:	glib.c
* Author:	Embest	
* Desc:	general lib
* History:	
*			Y.J.Guo, Programming modify, April 12, 2005
*********************************************************************************************/

/*------------------------------------------------------------------------------------------*/
/*	 								include files						 				    */
/*------------------------------------------------------------------------------------------*/
#include "def.h"
#include "lcdlib.h"
#include "glib.h"
#include "lcd.h"

/*------------------------------------------------------------------------------------------*/
/*	 								functions declare                                       */
/*------------------------------------------------------------------------------------------*/
void (*PutPixel)(UINT32T,UINT32T,UINT32T);
void (*BitmapView)(UINT8T *pBuffer);

/*********************************************************************************************
* name:		Glib_Init()
* func:		Glib initialization
* para:		type    --  lcd display mode
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void Glib_Init(int type)
{
    switch(type)
    {
	    case MODE_STN_1BIT:
	    	PutPixel=_PutStn1Bit;
	    	BitmapView=BitmapViewStn1Bit;
	    	break;
	    case MODE_STN_2BIT:
	       	PutPixel=_PutStn2Bit;
	       	BitmapView=BitmapViewStn2Bit;
	       	break;
	    case MODE_STN_4BIT:
	        PutPixel=_PutStn4Bit;
	        BitmapView=BitmapViewStn4Bit;
	        break;
	    case MODE_CSTN_8BIT:
	    	PutPixel=_PutCstn8Bit;
	    	BitmapView=BitmapViewCstn8Bit;
	    	break;   
	    case MODE_CSTN_12BIT:
	    	PutPixel=_PutCstn12Bit;
	    	BitmapView=BitmapViewCstn12Bit;
	    	break;   
	    case MODE_TFT_8BIT_240320:
	    	PutPixel=_PutTft8Bit_240320;
	    	BitmapView=BitmapViewTft8Bit_240320;  	
	    	break;   
	    case MODE_TFT_16BIT_240320:
	    	PutPixel=_PutTft16Bit_240320;
	    	BitmapView=BitmapViewTft16Bit_240320;  	
	    	break;   
	    case MODE_TFT_1BIT_640480:
	    	PutPixel=_PutTft1Bit_640480;
	    	BitmapView=BitmapViewTft1Bit_640480;
	    	break;   
	    case MODE_TFT_8BIT_640480:
	    	PutPixel=_PutTft8Bit_640480;
	    	BitmapView=BitmapViewTft8Bit_640480;
	    	break;   
	    case MODE_TFT_16BIT_640480:
	    	PutPixel=_PutTft16Bit_640480;
	    	BitmapView=BitmapViewTft16Bit_640480;
	    	break;   
	    case MODE_TFT_24BIT_640480:
	    	PutPixel=_PutTft24Bit_640480;
	    	BitmapView=BitmapViewTft24Bit_640480;
	    	break;   
	    case MODE_TFT_1BIT_800600:
	    	PutPixel=_PutTft1Bit_800600;
	    	BitmapView=BitmapViewTft1Bit_800600;
	    	break;   
	    case MODE_TFT_8BIT_800600:
	    	PutPixel=_PutTft8Bit_800600;
	    	BitmapView=BitmapViewTft8Bit_800600;
	    	break;   
	    case MODE_TFT_16BIT_800600:
	    	PutPixel=_PutTft16Bit_800600;
	    	BitmapView=BitmapViewTft16Bit_800600;
	    	break;   
	    default: 
	    	break;
   }
}

/*********************************************************************************************
* name:		_PutStn1Bit()
* func:		put pixel to 1bpp stn
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutStn1Bit(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_STN&& y<SCR_YSIZE_STN)
	frameBuffer1Bit[(y)][(x)/32]=( frameBuffer1Bit[(y)][(x)/32]
	& ~(0x80000000>>((x)%32)*1) ) | ( (c&0x00000001)<< ((32-1-((x)%32))*1) );
}

/*********************************************************************************************
* name:		_PutStn2Bit()
* func:		put pixel to 2bpp stn
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutStn2Bit(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_STN&& y<SCR_YSIZE_STN)
        frameBuffer2Bit[(y)][(x)/16]=( frameBuffer2Bit[(y)][x/16]
	& ~(0xc0000000>>((x)%16)*2) ) | ( (c&0x00000003)<<((16-1-((x)%16))*2) );
}

/*********************************************************************************************
* name:		_PutStn4Bit()
* func:		put pixel to 4bpp stn
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/void _PutStn4Bit(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_STN&& y<SCR_YSIZE_STN)
        frameBuffer4Bit[(y)][(x)/8]=( frameBuffer4Bit[(y)][x/8]
	& ~(0xf0000000>>((x)%8)*4) ) | ( (c&0x0000000f)<<((8-1-((x)%8))*4) );
}

/*********************************************************************************************
* name:		_PutCstn8Bit()
* func:		put pixel to 8bpp color stn
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutCstn8Bit(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_CSTN&& y<SCR_YSIZE_CSTN)
        frameBuffer8Bit[(y)][(x)/4]=( frameBuffer8Bit[(y)][x/4]
	    & ~(0xff000000>>((x)%4)*8) ) | ( (c&0x000000ff)<<((4-1-((x)%4))*8) );
}

/*********************************************************************************************
* name:		_PutCstn12Bit()
* func:		put pixel to 12bpp color stn
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutCstn12Bit(UINT32T x,UINT32T y,UINT32T c)
{
    UINT32T z;
    z=((x)%8);
    if(x<SCR_XSIZE_CSTN&& y<SCR_YSIZE_CSTN)
    {

        if((z%3)!=2)
            frameBuffer12Bit[(y)][(x)*3/8]=
            ( frameBuffer12Bit[(y)][(x)*3/8] & ~(0xfff00000>>(((z/3)*4)+((z)%3)*12) )
		| ( (c&0xfff)<<(20-(((z/3)*4)+((z)%3)*12))) );
        else
        {
            if(z==2)
            {
                frameBuffer12Bit[(y)][(x)*3/8]=( (frameBuffer12Bit[(y)][(x)*3/8]
                								& ~(0xff)) | ((c&0xff0)>>4)  ); 
                frameBuffer12Bit[(y)][((x)*3/8)+1]=( (frameBuffer12Bit[(y)][((x)*3/8)+1]
		    										& ~(0xf0000000)) | ((c&0xf)<<28)  );
           }   
            else if(z==5)
            {
                frameBuffer12Bit[(y)][(x)*3/8]=( (frameBuffer12Bit[(y)][(x)*3/8]
	            & ~(0xf)) | ((c&0xf00)>>8)  );
                frameBuffer12Bit[(y)][((x)*3/8)+1]=( (frameBuffer12Bit[(y)][((x)*3/8)+1]
	            & ~(0xff000000)) | ((c&0xff)<<24)  );
           }   
       }
   }
}

/*********************************************************************************************
* name:		_PutTft8Bit_240320()
* func:		put pixel to 8bpp 240*320 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft8Bit_240320(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_240320 && y<SCR_YSIZE_TFT_240320)
        frameBuffer8BitTft240320[(y)][(x)/4]=( frameBuffer8BitTft240320[(y)][x/4]
        & ~(0xff000000>>((x)%4)*8) ) | ( (c&0x000000ff)<<((4-1-((x)%4))*8) );
}

/*********************************************************************************************
* name:		_PutTft16Bit_240320()
* func:		put pixel to 16bpp 240*320 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft16Bit_240320(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_240320 && y<SCR_YSIZE_TFT_240320)
        frameBuffer16BitTft240320[(y)][(x)/2]=( frameBuffer16BitTft240320[(y)][x/2]
        & ~(0xffff0000>>((x)%2)*16) ) | ( (c&0x0000ffff)<<((2-1-((x)%2))*16) );
}

/*********************************************************************************************
* name:		_PutTft1Bit_640480()
* func:		put pixel to 1bpp 640*480 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft1Bit_640480(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480)
        frameBuffer1BitTft640480[(y)][(x)/32]=( frameBuffer1BitTft640480[(y)][x/32]
	& ~(0x80000000>>((x)%32)*1) ) | ( (c&0x00000001)<< ((32-1-((x)%32))*1) );
}

/*********************************************************************************************
* name:		_PutTft8Bit_640480()
* func:		put pixel to 8bpp 640*480 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft8Bit_640480(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480)
        frameBuffer8BitTft640480[(y)][(x)/4]=( frameBuffer8BitTft640480[(y)][x/4]
        & ~(0xff000000>>((x)%4)*8) ) | ( (c&0x000000ff)<<((4-1-((x)%4))*8) );
}

/*********************************************************************************************
* name:		_PutTft16Bit_640480()
* func:		put pixel to 16bpp 640*480 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft16Bit_640480(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480)
        frameBuffer16BitTft640480[(y)][(x)/2]=( frameBuffer16BitTft640480[(y)][x/2]
        & ~(0xffff0000>>((x)%2)*16) ) | ( (c&0x0000ffff)<<((2-1-((x)%2))*16) );
}


/*********************************************************************************************
* name:		_PutTft24Bit_640480()
* func:		put pixel to 24bpp 640*480 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft24Bit_640480(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480)
        frameBuffer24BitTft640480[(y)][(x)]=( frameBuffer24BitTft640480[(y)][(x)]
        & (0x0) | ( c&0xffffff00)); // | ( c&0x00ffffff)); LSB 
}


/*********************************************************************************************
* name:		_PutTft1Bit_800600()
* func:		put pixel to 1bpp 800*600 TFT
* para:		UINT32T x   --  x coordinate
*           UINT32T y   --  y coordinate
*           UINT32T c   --  color value          
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _PutTft1Bit_800600(UINT32T x,UINT32T y,UINT32T c)
{
    if(x<SCR_XSIZE_TFT_800600 && y<SCR_YSIZE_TFT_800600)
        frameBuffer1BitTft800600[(y)][(x)/32]=( frameBuffer1BitTft800600[(y)][x/32]
	& ~(0x80000000>>((x)%32)*1) ) | ( (c&0x00000001)<< ((32-1-((x)%32))*1) );
}

⌨️ 快捷键说明

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