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

📄 lcd_pixel.h

📁 嵌入式系统
💻 H
📖 第 1 页 / 共 2 页
字号:
/*-----------------------------------------------------------------------------
@@ Copyright (c) 1999 Sharp Corporation All rights reserved.
@@ (Summary) 	 : The file to set pixel data of LCD controller
@@ (Comment)  	: 
@@ (Author)   	: Tsuneo TOMITA
@@ (History)	: Date		Modifier	Comment
@@ (RCS ID)   	: 
-----------------------------------------------------------------------------*/

#ifndef LCD_PIXEL
#define LCD_PIXEL
#include <string.h>
extern volatile unsigned char	LineData[(APD_LCD_WIDTH * APD_LCD_BPP) / 8];

/******************************************************************************
@@ [Name]		: LCDSign
@@ [Summary]	: Get sign
@@ [Argument]	: sign : the investigating value
@@ [Return]	: 1 : positive
@@		  0 : zero
@@		  -1: negative
@@ [Desc]	: Investigate the value in positive, 0 or negative, and return
@@		  the corresponding value.
@@ [History]	: Date		Modifier	Comment
******************************************************************************/
#define LCDSign( sign ) ((sign) > 0 ? 1: ((sign) == 0 ? 0: (-1)))  

/******************************************************************************
@@ [Name]		: LCDGetXOffsetAdrs
@@ [Summary]	: Get address offset of X coordinates of pixel data
@@ [Argument]	: x		: X coordinates data
@@				  adrs	: Pointer to buffer written half word address data in
@@				  hword	: Pointer to buffer written half word offset data in
@@				  byte	: Pointer to buffer written byte offset data in
@@				  bit	: Pointer to buffer written bit offset data in
@@ [Return]		: Half word address, half word offset, byte offset and 
@@			  bit offset of pixel data
@@ [Desc]		: Calculate half word address, half word offset, byte offset
@@			  and bit offset of the specified X coordinates
@@ [History]	: Date		Modifier	Comment
******************************************************************************/
APD_INLINE void LCDGetXOffsetAdrs(int x,unsigned long **adrs,unsigned char *hword,unsigned char *byte,unsigned char *bit)
{
	unsigned long x_ofst;
	x_ofst = (unsigned long)x * LCD_BPP;		// LCD_BPP ---> 16
	*adrs = (unsigned long *)(x_ofst>>5);
	*hword = (unsigned char)((x_ofst>>4) & 0x01); // >> 4) & 0x01);
}


/******************************************************************************
@@ [Name]	: LCDGetYAdrs
@@ [Summary]	: Get address of Y coordinates of pixel data
@@ [Argument]	: y   : Y coordinates data
@@		  adrs : Pointer to buffer written word address data in
@@ [Return]	: word address of pixel data
@@ [Desc]	: Calculate half word address of the specified Y coordinates
@@ [History]	: Date		Modifier	Comment
******************************************************************************/

APD_INLINE void LCDGetYAdrs(int y,unsigned long **adrs)
{
	unsigned long y_ofst;
	
	y_ofst = (unsigned long)y * LCD_BPL / 8;
	*adrs = (unsigned long *)(0x040700000 + y_ofst);	//0x1c000 + y_ofst);
}

/******************************************************************************
@@ [Name]		: LCDGetPixelAdrs
@@ [Summary]	: Get address of pixel data
@@ [Argument]	: point	: Pointer to coordinates data
@@		  adrs	: Pointer to buffer written half word address in
@@		  hword	: Pointer to buffer written half word offset in
@@		  byte	: Pointer to buffer written byte offset in
@@		  bit	: Pointer to buffer written bit offset in
@@ [Return]		: Half word address, half word offset, byte offset and
@@				  bit offset of pixel data
@@ [Desc]		: Get address of the corresponding pixel data to the specified
@@				  coordinates
@@ [History]	: Date		Modifier	Comment
@@ [END]
******************************************************************************/

APD_INLINE void LCDGetPixelAdrs(APD_LCD_POINT *point,unsigned long **adrs,unsigned char *hword,unsigned char *byte,unsigned char *bit)
{
	unsigned long *xadrs;
	unsigned long *yadrs;

	LCDGetXOffsetAdrs(point->x, &xadrs, hword, byte, bit);
	LCDGetYAdrs(point->y, &yadrs);
	#if (((APD_LCD_WIDTH*APD_LCD_BPP) % 32) != 0)
		if (((unsigned long)yadrs % 4) != 0)
	      		*hword = (0 == *hword) ? 1 : 0;
	#endif
	
	*adrs = (unsigned long *)((unsigned long*)yadrs + (unsigned long)xadrs);
}

/******************************************************************************
@@
@@ [Name]		: LCDSetPixelByWord
@@
@@ [Summary]	: Set pixel data by a word unit
@@				 
@@ [Argument]	: adrs	: Address written image
@@				  color	: Pixel color
@@
@@ [Return]		: None
@@
@@ [Desc]		: Write pixel data by word unit according to raster operation.
@@				  					
@@ [History]	: Date		Modifier	Comment
@@
@@ [END]
******************************************************************************/
APD_INLINE void LCDSetPixelByWord(
unsigned long *adrs,
unsigned long color
)
{
	switch(current_gc.rop)
	{
		case APD_LCD_ROP_n_SoD:		/* ~(S|D) */
			*adrs = ~(*adrs|color);
			break;
		case APD_LCD_ROP_nS_aD:		/* ~S&D */
			*adrs = (~color)&*adrs;
			break;
		case APD_LCD_ROP_nS:		/* ~S */
			*adrs = ~(color);
			break;
		case APD_LCD_ROP_Sa_nD:		/* S&~D */
			*adrs = color&(~(*adrs));
			break;
		case APD_LCD_ROP_nD:		/* ~D */
			*adrs = ~(*adrs);
			break;
		case APD_LCD_ROP_SeD:		/* S^D */
			*adrs = (*adrs^color);
			break;
		case APD_LCD_ROP_n_SaD:		/* ~(S&D) */
			*adrs = ~(*adrs&color);
			break;
		case APD_LCD_ROP_SaD:		/* S&D */
			*adrs = (*adrs&color);
			break;
		case APD_LCD_ROP_n_SeD:		/* ~(S^D) */
			*adrs = ~(*adrs^color);
			break;
		case APD_LCD_ROP_nS_oD:		/* ~S|D */
			*adrs = (~color)|*adrs;
			break;
		case APD_LCD_ROP_So_nD:		/* S|~D */
			*adrs = color|(~(*adrs));
			break;
		case APD_LCD_ROP_SoD:		/* S|D */
			*adrs = *adrs|color;
			break;
		default:				/* APD_LCD_ROP_S (S) */
			*adrs = color;
	}
}

/******************************************************************************
@@
@@ [Name]		: LCDSetPixelByShort
@@
@@ [Summary]	: Set pixel data by a half word unit
@@
@@ [Argument]	: adrs	: Address written image
@@				  color	: Pixel color
@@
@@ [Return]		: None
@@
@@ [Desc]		: Write pixel data by a half word unit in memory according to
@@				  raster operation 
@@				  					
@@ [History]	: Date		Modifier	Comment
@@
@@ [END]
******************************************************************************/
APD_INLINE void LCDSetPixelByShort(unsigned long *adrs,unsigned short color)
{
	switch(current_gc.rop)
	{
		case APD_LCD_ROP_n_SoD:		/* ~(S|D) */
			*adrs = ~(*adrs|color);
			break;
		case APD_LCD_ROP_nS_aD:		/* ~S&D */
			*adrs = (~color)&*adrs;
			break;
		case APD_LCD_ROP_nS:		/* ~S */
			*adrs = ~(color);
			break;
		case APD_LCD_ROP_Sa_nD:		/* S&~D */
			*adrs = color&(~(*adrs));
			break;
		case APD_LCD_ROP_nD:		/* ~D */
			*adrs = ~(*adrs);
			break;
		case APD_LCD_ROP_SeD:		/* S^D */
			*adrs = (*adrs^color);
			break;
		case APD_LCD_ROP_n_SaD:		/* ~(S&D) */
			*adrs = ~(*adrs&color);
			break;
		case APD_LCD_ROP_SaD:		/* S&D */
			*adrs = (*adrs&color);
			break;
		case APD_LCD_ROP_n_SeD:		/* ~(S^D) */
			*adrs = ~(*adrs^color);
			break;
		case APD_LCD_ROP_nS_oD:		/* ~S|D */
			*adrs = (~color)|*adrs;
			break;
		case APD_LCD_ROP_So_nD:		/* S|~D */
			*adrs = color|(~(*adrs));
			break;
		case APD_LCD_ROP_SoD:		/* S|D */
			*adrs = *adrs|color;
			break;
		default:				/* APD_LCD_ROP_S (S) */
			*adrs = color;
	}
}

/******************************************************************************
@@ [Name]	: LCDSetPixelByByte
@@ [Summary]	: Set pixel data by a byte unit
@@ [Argument]	: adrs	: Address written image
@@		  color	: Pixel color
@@ [Return]	: None
@@ [Desc]	: Write pixel data by a byte unit in memory according to 
@@		  raster operation.
@@ [History]	: Date		Modifier	Comment
******************************************************************************/
APD_INLINE void LCDSetPixelByByte(unsigned char *adrs,unsigned char color)
{
	switch(current_gc.rop)
	{
		case APD_LCD_ROP_n_SoD:		/* ~(S|D) */
			*adrs = ~(*adrs|color);
			break;
		case APD_LCD_ROP_nS_aD:		/* ~S&D */
			*adrs = (~color)&*adrs;
			break;
		case APD_LCD_ROP_nS:		/* ~S */
			*adrs = ~(color);
			break;
		case APD_LCD_ROP_Sa_nD:		/* S&~D */
			*adrs = color&(~(*adrs));
			break;
		case APD_LCD_ROP_nD:		/* ~D */
			*adrs = ~(*adrs);
			break;
		case APD_LCD_ROP_SeD:		/* S^D */
			*adrs = (*adrs^color);
			break;
		case APD_LCD_ROP_n_SaD:		/* ~(S&D) */
			*adrs = ~(*adrs&color);
			break;
		case APD_LCD_ROP_SaD:		/* S&D */
			*adrs = (*adrs&color);
			break;
		case APD_LCD_ROP_n_SeD:		/* ~(S^D) */
			*adrs = ~(*adrs^color);
			break;
		case APD_LCD_ROP_nS_oD:		/* ~S|D */
			*adrs = (~color)|*adrs;
			break;
		case APD_LCD_ROP_So_nD:		/* S|~D */
			*adrs = color|(~(*adrs));
			break;
		case APD_LCD_ROP_SoD:		/* S|D */
			*adrs = *adrs|color;
			break;
		default:				/* APD_LCD_ROP_S (S) */
			*adrs = color;
	}
}

/******************************************************************************
@@
@@ [Name]		: LCDSetPixelByWordWithMask
@@
@@ [Summary]	: Set pixel data by a word unit with mask
@@				 
@@ [Argument]	: adrs	: Address written image
@@				  color	: Pixel color
@@				  mask	: mask
@@
@@ [Return]		: None
@@
@@ [Desc]		: Write pixel data with mask by a word unit in memory
@@				  according to raster operation.
@@				  					
@@ [History]	: Date		Modifier	Comment
@@
@@ [END]
******************************************************************************/
APD_INLINE void LCDSetPixelByWordWithMask(unsigned long *adrs,unsigned long color,unsigned long mask)
{
	unsigned long pixel;
	switch(current_gc.rop)
	{
		case APD_LCD_ROP_n_SoD:		/* ~(S|D) */
			pixel = ~(*adrs|color);
			break;
		case APD_LCD_ROP_nS_aD:		/* ~S&D */
			pixel = (~color)&*adrs;
			break;
		case APD_LCD_ROP_nS:		/* ~S */
			pixel = ~(color);
			break;
		case APD_LCD_ROP_Sa_nD:		/* S&~D */
			pixel = color&(~(*adrs));
			break;
		case APD_LCD_ROP_nD:		/* ~D */
			pixel = ~(*adrs);
			break;
		case APD_LCD_ROP_SeD:		/* S^D */
			pixel = (*adrs^color);
			break;
		case APD_LCD_ROP_n_SaD:		/* ~(S&D) */
			pixel = ~(*adrs&color);
			break;
		case APD_LCD_ROP_SaD:		/* S&D */
			pixel = (*adrs&color);
			break;
		case APD_LCD_ROP_n_SeD:		/* ~(S^D) */
			pixel = ~(*adrs^color);
			break;
		case APD_LCD_ROP_nS_oD:		/* ~S|D */
			pixel = (~color)|*adrs;
			break;
		case APD_LCD_ROP_So_nD:		/* S|~D */
			pixel = color|(~(*adrs));
			break;
		case APD_LCD_ROP_SoD:		/* S|D */
			pixel = *adrs|color;
			break;
		default:				/* APD_LCD_ROP_S (S) */
			pixel = color;
	}
	*adrs = (*adrs & (~mask)) | (pixel & mask);
}

/******************************************************************************
@@
@@ [Name]		: LCDSetPixelByByteWithMask
@@
@@ [Summary]	: Set pixel data by a byte unit with mask
@@				 
@@ [Argument]	: adrs	: Address written image
@@				  color	: Pixel color
@@				  mask	: mask
@@
@@ [Return]		: None
@@
@@ [Desc]		: Write pixel data with mask by a byte unit in memory
@@				  according to raster operation.
@@				  					
@@ [History]	: Date		Modifier	Comment
@@
@@ [END]
******************************************************************************/
APD_INLINE void LCDSetPixelByByteWithMask(
unsigned char *adrs,
unsigned char color,
unsigned char mask
)
{
	unsigned char pixel;

	switch(current_gc.rop)
	{
		case APD_LCD_ROP_n_SoD:		/* ~(S|D) */
			pixel = ~(*adrs|color);
			break;
		case APD_LCD_ROP_nS_aD:		/* ~S&D */
			pixel = (~color)&*adrs;
			break;
		case APD_LCD_ROP_nS:		/* ~S */
			pixel = ~(color);
			break;
		case APD_LCD_ROP_Sa_nD:		/* S&~D */
			pixel = color&(~(*adrs));
			break;
		case APD_LCD_ROP_nD:		/* ~D */
			pixel = ~(*adrs);
			break;
		case APD_LCD_ROP_SeD:		/* S^D */
			pixel = (*adrs^color);
			break;
		case APD_LCD_ROP_n_SaD:		/* ~(S&D) */
			pixel = ~(*adrs&color);
			break;
		case APD_LCD_ROP_SaD:		/* S&D */
			pixel = (*adrs&color);
			break;
		case APD_LCD_ROP_n_SeD:		/* ~(S^D) */
			pixel = ~(*adrs^color);
			break;
		case APD_LCD_ROP_nS_oD:		/* ~S|D */
			pixel = (~color)|*adrs;
			break;
		case APD_LCD_ROP_So_nD:		/* S|~D */
			pixel = color|(~(*adrs));
			break;
		case APD_LCD_ROP_SoD:		/* S|D */
			pixel = *adrs|color;
			break;
		default:				/* APD_LCD_ROP_S (S) */
			pixel = color;
	}
	*adrs = (*adrs & (~mask)) | (pixel & mask);
}

⌨️ 快捷键说明

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