j_driver.c

来自「基于μCGUI的嵌入式图形界面设计」· C语言 代码 · 共 67 行

C
67 行
字号
/******************************************************************************
									J_GUI
						The JJJ's Graphics Interface Library
								
					 	COPYRIGHT (c) JJJSTUDIO, 2006 BY JJJ.
                       		--  ALL RIGHTS RESERVED  --
                       		
   	Filename:	J_Driver.h
   	Author	:   Jianjun Jiang 	
   	Created	:   2006/01/20
   	Website	:	http://www.jjjbbs.com
   	Modified:	NO
   	Revision: 	1.00
   	Readme	:	The Driver C File
******************************************************************************/

#define GBA_REG_DISPCNT 		(*(volatile UINT16 *)0x04000000)	//显示控制寄存器地址
#define GBA_VRAM 				(*(volatile UINT16 *)0x06000000)	//图像缓冲区地址

void J_LCDInitial(void)
{
	GBA_REG_DISPCNT = 0x0403;
}

void J_LCDSetPixel(UINT32 x, UINT32 y, TCOLOR Color)
{
	*(&GBA_VRAM + 240*y + x) = J_Color2Index_565(Color);
}

TCOLOR GDI_LCDGetPixel(UINT32 x, UINT32 y)
{
	return (J_Index2Color_565(*(&GBA_VRAM + 240*y + x)));
}

void J_LCDHLine(UINT32 x0, UINT32 y0, UINT32 x, TCOLOR Color)
{
	UINT32 i,j;
	UINT16 ColorIndex = J_Color2Index_565(Color);
	j = 240*y0;
	if(x >= x0)
	{
		for(i=x0; i<=x; i++)
			*(&GBA_VRAM + j + i) = ColorIndex;
	}
	else
	{
		for(i=x0; i>=x; i--)
			*(&GBA_VRAM + j + i) = ColorIndex;		
	}
}

void J_LCDVLine(UINT32 x0, UINT32 y0, UINT32 y, TCOLOR Color)
{
	UINT32 i;
	UINT16 ColorIndex = J_Color2Index_565(Color);
	if(y >= y0)
	{
		for(i=y0; i<=y; i++)
			*(&GBA_VRAM + 240*i + x0) = ColorIndex;
	}
	else
	{
		for(i=y0; i>=y; i--)
			*(&GBA_VRAM + 240*i + x0) = ColorIndex;		
	}
}
/*****************************************************************************/

⌨️ 快捷键说明

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