📄 glib.c
字号:
/*********************************************************************************************
* File: glib.c
* Author: Embest
* Desc: general lib
* History:
*
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* 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;
break;
case MODE_STN_2BIT:
PutPixel=_PutStn2Bit;
break;
case MODE_STN_4BIT:
PutPixel=_PutStn4Bit;
break;
case MODE_CSTN_8BIT:
PutPixel=_PutCstn8Bit;
break;
case MODE_CSTN_12BIT:
PutPixel=_PutCstn12Bit;
break;
case MODE_TFT_8BIT_240320:
PutPixel=_PutTft8Bit_240320;
break;
case MODE_TFT_16BIT_240320:
PutPixel=_PutTft16Bit_240320;
break;
case MODE_TFT_1BIT_640480:
PutPixel=_PutTft1Bit_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;
break;
//--------------------------------------
case MODE_TFT_1BIT_800600:
PutPixel=_PutTft1Bit_800600;
break;
case MODE_TFT_8BIT_800600:
PutPixel=_PutTft8Bit_800600;
break;
case MODE_TFT_16BIT_800600:
PutPixel=_PutTft16Bit_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) );
}
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: _PutStn12Bit()
* func: put pixel to 12bpp 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*6000 TFT
* para: UINT32T x -- x coordinate
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -