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

📄 lcd_zk.c

📁 三星公司的生产的ARM 2410 光盘里面带的一些实例的程序
💻 C
字号:
#include <string.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "lcdlib.h"
#include "glib.h"
#include "lcd.h"
//#include "demo256.h"

//#define Ascii6x8
#define Ascii8x16
//#define Hzk12
//#define Hzk16
#define Hzk24
//#define Hzk24s

#ifdef Ascii6x8
extern INT8U g_auc_Ascii6x8[];
void Lcd_DspAscII6X8(U16 x0, U16 y0, INT8U ForeColor, INT8U * s);
#endif
#ifdef Ascii8x16
extern INT8U g_auc_Ascii8x16[];
void Lcd_DspAscII8X16(U16 x0, U16 y0, INT8U ForeColor, INT8U * s);
#endif
#ifdef Hzk12
extern INT8U g_auc_HZK12[];
void Lcd_DspHz12(U16 x0, U16 y0, INT8U ForeColor, INT8U *s);
#endif
#ifdef Hzk24
extern INT8U g_auc_HZK16[];
void Lcd_DspHz16(U16 x0, U16 y0, INT8U ForeColor, INT8U *s);
#endif
#ifdef Hzk24
extern INT8U g_auc_HZK24[];
void Lcd_DspHz24(U16 x0, U16 y0, INT8U ForeColor, INT8U *s);
#endif
#ifdef Hzk24s
extern INT8U g_auc_HZK24s[];
void Lcd_DspHz24s(U16 x0, U16 y0, INT8U ForeColor, INT8U *s);
#endif

#define LCD_BUF_SIZE		(SCR_XSIZE_TFT_640480*SCR_YSIZE_TFT_640480/2)
#define LCD_ACTIVE_BUFFER	(0x33800000)
#define LCD_VIRTUAL_BUFFER (0x33800000 + LCD_BUF_SIZE)


void Lcd_InitZK();
void Lcd_InitZK_End();

/*****************************************************************/

#define Ascii_W 8
#define XWIDTH 6
void Lcd_DisplayHZ(U16 usX0, U16 usY0, INT8U *pucText, S32 ulLen)
{
	S32 i, j;
	INT8U ucTemp;

	for (i = 0; i < 16; i++)
		{
		for (j = 0; j < ulLen; j++)
			{
			ucTemp = *(pucText + i * ulLen / 8 + j /8);
			if ((ucTemp & (0x80 >> (j%8))) == 0)
				{
				PutPixel(usX0 + j, usY0 + i, WHITE);
				}
			else
				{
				PutPixel(usX0 + j, usY0 + i, BLACK);
				}
			}
		}
}

/*********************************************************************/

INT8U ziku[224] = 
{
	0x00,0x08,0x7E,0x08,0x42,0x08,0x4A,0x08,0x4A,0xFE,0x4A,0x18,0x4A,0x18,0x4A,0x28,
	0x4A,0x28,0x4A,0x48,0x08,0x48,0x14,0x88,0x12,0x08,0x23,0x08,0x42,0x28,0x80,0x10,
	0x40,0x00,0x27,0xFE,0x24,0x40,0x04,0x80,0x85,0xFC,0x55,0x04,0x15,0xFC,0x15,0x04,
	0x25,0xFC,0x24,0x20,0xC4,0xA8,0x44,0xA4,0x49,0x22,0x4A,0x22,0x50,0xA0,0x40,0x40,
	0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,
	0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x00,0x00,
	0x01,0x10,0x41,0x10,0x21,0x10,0x37,0xFC,0x21,0x10,0x01,0x10,0x01,0x10,0xF7,0xFE,
	0x11,0x10,0x11,0x10,0x12,0x10,0x12,0x10,0x14,0x10,0x28,0x00,0x47,0xFE,0x00,0x00,
	0x00,0x00,0x40,0x80,0x30,0x80,0x10,0x80,0x0F,0xFC,0x00,0x80,0x00,0x80,0xE0,0x80,
	0x21,0x40,0x21,0x20,0x22,0x18,0x24,0x0C,0x28,0x08,0x50,0x02,0x8F,0xFC,0x00,0x00,
	0x00,0x00,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,
	0x20,0x00,0x10,0x00,0x13,0xFC,0x00,0x40,0x88,0x40,0x48,0x40,0x50,0x40,0x10,0x40,
	0x10,0x40,0x20,0x40,0xE0,0x40,0x20,0x40,0x20,0x40,0x2F,0xFE,0x20,0x00,0x00,0x00,
};

INT8U ziku_depth[8]=
{
	2, 4, 6, 8, 10, 12,14, 0
};

void Lcd_DspHZ(S32 x, S32 y, S32 backcolor)
{
	S32 i, j, k; 
	U16 hztemp;

	for (i = 0; i < 7; i++)
	{
		for (j = 0; j < 16; j++)
		{	
			hztemp = (ziku[i * 32 + j * 2] << 8)  + ziku[i * 32 + j * 2 + 1]; 
			for (k = 0; k < 16; k++)
			{
				if ((hztemp & (0x8000 >> k)) == 0)
				{
					PutPixel((320-(x + i * (16+4) + k)), y + j, backcolor);
				}
				else
				{
					PutPixel((320-(x + i * (16 + 4) + k)), y + j, ziku_depth[i]);
				}
			}
		}
	}
}
void Lcd_InitZK()
{
    Lcd_Port_Init();
    Lcd_Init(MODE_TFT_16BIT_640480);
    Glib_Init(MODE_TFT_16BIT_640480);
    Glib_ClearScr(0, MODE_TFT_16BIT_640480);
    Lcd_PowerEnable(0, 1);
    Lcd_EnvidOnOff(1);	
    Uart_Printf("[TFT 64K COLOR(16bit/1pixel) LCD TEST]\n");

}
void Lcd_InitZK_End()
{
    Lcd_EnvidOnOff(0);
    Lcd_Port_Return();
}
void Lcd_Test(void)
{
INT8U e_info[]=
{"提供嵌入式软硬件开发工具和系统解决方案及技术信息服务"};
	S32 x, y,i;
	i =20;
//	Lcd_DspHZ(50, 80, 0x0);
//	Lcd_DspHZ(80, 120, 0xf);
#ifdef Hzk12
	Lcd_DspHz12(0,i,BLACK,"英蓓特信息技术有限公司");
	Lcd_DspHz12(0,i+=30,BLACK,"十二点阵汉字");
#endif
#ifdef Hzk16
	Lcd_DspHz16(0,i+=30,BLACK,"英蓓特信息技术有限公司");
	Lcd_DspHz16(0,i+=30,BLACK,"十六点阵汉字");
#endif
#ifdef Hzk24
	Lcd_DspHz24(180,i+=30,BLACK,"英蓓特信息技术有限公司");
	Lcd_DspHz24(0,i+=30,BLACK,(INT8U *) e_info);
	Lcd_DspHz24(230,210,BLACK,"二十四点阵汉字");
//	for(i=0;i<10;i++)
//   { Lcd_DspHz24(0,i*24,BLACK,"二十四点阵汉字"); }
#endif	
#ifdef Ascii8x16
	Lcd_DspAscII8X16(250,250,BLACK,"Embest2410");
	Lcd_DspAscII8X16(350,250,BLACK,"8x16");
#endif
#ifdef Ascii6x8
	Lcd_DspAscII6X8(250,250,BLACK,"Embest2410");
	Lcd_DspAscII6x8(350,250,BLACK,"6x8");
#endif
}

#ifdef Hzk12
//*****************************************************************
//** 函数名:void Lcd_DspHz12(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
//** 输 入: x0--字符串的左上角x坐标
//		   y0--字符串的坐上角y坐标
//**          ForeColor--填充的颜色
//		   s--字符串数组指针
//** 输 出: Null
//** 功能描述:显示12x12汉字字符串
//** 全局变量:Null
//*****************************************************************
void Lcd_DspHz12(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
{
	INT16 i,j,k,x,y,xx;
	INT8U qm,wm;
	S32 ulOffset;
	INT8 hzbuf[24],temp[2];

    	for(i = 0; i < strlen((const char*)s); i++)
    	{
    		if( (INT8U)*(s + i) < 161 )
    		{
    	    		/* AscII char */
    			temp[0] = *(s + i); 
    			temp[1] = '\0';    		
    			break;
    		}
    		else
    		{
    	    		/* HanZi */
    			qm = *(s + i) - 161;
    			wm = *(s + i + 1) - 161;
    			ulOffset = (S32)(qm * 94 + wm) * 24;

            		for (j = 0; j < 24; j ++)
            		{
            			hzbuf[j] = g_auc_HZK12[ulOffset + j];
             		}
             		
    			/* Get the HZ ZiMo By X */
    			for(y = 0; y < 12; y++)
    			{
    				for(x = 0; x < 16; x++)
    				{
    			   		if(x < 12)
    			   		{
    			   	 		k = x % 8;    			   	 		
						if (hzbuf[y * 2 + x / 8]  & (0x80 >> k))
						{
	    			   	 		xx = x0 + x + i * 6;
					     		PutPixel( xx, y + y0, ForeColor);			       	
						}
    			   		}
    				}
    			} 
    			/* One HZ Ocupy 2 bytes, So i++ */
    			i++;    		
    		}
    	}
}
#endif
#ifdef Hzk16
//*****************************************************************
//** 函数名:void Lcd_DspHz16(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
//** 输 入: x0--字符串的左上角x坐标
//		   y0--字符串的坐上角y坐标
//**          ForeColor--填充的颜色
//		   s--字符串数组指针
//** 输 出: Null
//** 功能描述:显示16x16汉字字符串
//** 全局变量:Null
//*****************************************************************
void Lcd_DspHz16(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
{
	INT16 i,j,k,x,y,xx;
	INT8U qm,wm;
	S32 ulOffset;
	INT8 hzbuf[32],temp[2];

	for(i = 0; i < strlen((const char*)s); i++)
	{
		if(((INT8U)(*(s+i))) < 161)
		{
			temp[0] = *(s+i);
			temp[1] = '\0';
			break;
		}
		else
		{
			qm = *(s+i) - 161;
	    		wm = *(s + i + 1) - 161;
            		ulOffset = (S32)(qm * 94 + wm) * 32;
            		for (j = 0; j < 32; j ++)
            		{
            			hzbuf[j] = g_auc_HZK16[ulOffset + j];
             		}
            		for(y = 0; y < 16; y++)
            		{
	               		for(x = 0; x < 16; x++) 
	               		{
                   			k = x % 8;
				       	if (hzbuf[y * 2 + x / 8]  & (0x80 >> k))
				       	{
				       		xx = x0 + x + i * 8;
				       		PutPixel( xx, y + y0, (INT8U)ForeColor);
				       	}
			   	}
            		}
		    	i++;
         	}
     	}     	
}
#endif
#ifdef Hzk24
//*****************************************************************
//** 函数名:void Lcd_DspHz24(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
//** 输 入: x0--字符串的左上角x坐标
//		   y0--字符串的坐上角y坐标
//**          ForeColor--填充的颜色
//		   s--字符串数组指针
//** 输 出: Null
//** 功能描述:显示24x24汉字字符串
//** 全局变量:Null
//*****************************************************************
void Lcd_DspHz24(U16 x0, U16 y0, INT8U ForeColor, INT8U *s)
{
	INT16 i,j,k,x,y,xx;
	INT8U qm,wm;
	S32 ulOffset;
	INT8 hzbuf[72],temp[2];

	for(i = 0; i < strlen((const char*)s); i++)
	{
		if(((INT8U)(*(s+i))) < 161)
		{
			temp[0] = *(s+i);
			temp[1] = '\0';
			break;
		}
		else
		{
			qm = *(s+i) - 176;//161;
	    		wm = *(s+i + 1) - 161;
            		ulOffset = (S32)(qm * 94 + wm) * 72;
            		for (j = 0; j < 72; j ++)
            		{
            			hzbuf[j] = g_auc_HZK24[ulOffset + j];
             		}
            		for(y = 0; y < 24; y++)
            		{
	               	for(x = 0; x < 24; x++) 
	               	{
           				k = x % 8;
			       	if (hzbuf[y * 3 + x / 8]  & (0x80 >> k))
			       	{
			       		xx = x0 + x + i*12;
			       		PutPixel( xx, y + y0, (INT8U)ForeColor);
			       	}
			       }
            		}
            	/*	for(x=0;x<24;x++)
            		{
            			for(y=0;y<24;y++)
            			{
   					k = y%8;
    					if( hzbuf[x*3+y/8] & (0x80 >> k) )
    					{
    						xx = x0+x+i*8;
    						PutPixel(xx,y+y0,(INT8U)ForeColor);
    					}
            			}
            		}*/
		    	i++;
         	}
     	}     	
}
#endif
#ifdef Ascii6x8
//*****************************************************************
//** 函数名:void Lcd_DspAscII6x8(U16 usX0, U16 usY0,INT8U ForeColor, INT8U* pucChar)
//** 输 入: usX0--字符串的左上角x坐标
//		   usY0--字符串的坐上角y坐标
//**          ForeColor--填充的颜色
//		   pucChar--字符串数组指针
//** 输 出: Null
//** 功能描述:显示6x8英文字符串
//** 全局变量:Null
//*****************************************************************
void Lcd_DspAscII6x8(U16 usX0, U16 usY0,INT8U ForeColor, INT8U* pucChar)
{
	S32 i, j;
	INT8U ucTemp;

	while (*pucChar != 0)
	{
		for (i=0; i < 8; i++)
		{
  			ucTemp = g_auc_Ascii6x8[(*pucChar) * 8 + i];
  			for (j = 0; j < 8; j++)
  			{
  				if ((ucTemp & (0x80 >> j)) != 0)
  				{
  					PutPixel(usX0 + i, usY0 + 8 - j, (INT8U)ForeColor);
  				}  				
  			}
		}
		usX0 += XWIDTH;
		pucChar++;
	}
}
#endif
#ifdef Ascii8x16
//*****************************************************************
//** 函数名:void Lcd_DspAscII8X16(U16 x0, U16 y0, INT8U ForeColor, INT8U * s)
//** 输 入: x0--字符串的左上角x坐标
//		   y0--字符串的坐上角y坐标
//**          ForeColor--填充的颜色
//		   s--字符串数组指针
//** 输 出: Null
//** 功能描述:显示8x16英文字符串
//** 全局变量:Null
//*****************************************************************
void Lcd_DspAscII8X16(U16 x0, U16 y0, INT8U ForeColor, INT8U * s)
{
	INT16 i,j,k,x,y,xx;
	INT8U qm;
	S32 ulOffset;
	INT8 ywbuf[16],temp[2];
    
	for(i = 0; i < strlen((const char*)s); i++)
	{
		if((INT8U)*(s+i) >= 161)
		{
			temp[0] = *(s + i);
			temp[1] = '\0';
			return;
		}
		else
		{
			qm = *(s+i);
            		ulOffset = (S32)(qm) * 16;		//Here to be changed tomorrow
            		for (j = 0; j < 16; j ++)
            		{
            			ywbuf[j] = g_auc_Ascii8x16[ulOffset + j];
            		}

            		for(y = 0; y < 16; y++)
            		{
               		for(x = 0; x < 8; x++) 
               		{
                   			k = x % 8;
			       	if (ywbuf[y]  & (0x80 >> k))
			       	{
			       		xx = x0 + x + i*8;
			       		PutPixel( xx, y + y0, (INT8U)ForeColor);
			       	}
			   	}
            		}
         	}
     	}
}
#endif

⌨️ 快捷键说明

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