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

📄 color_lcd_test.c

📁 基于ARM9芯片的一个简单的GPRS测试程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************************************
* File:	lcdapp.c
* Author:	Embest	
* Desc:	LCD control and display functions
* History:	
*			H.T.Zhang, Programming modify, September 14, 2005
*********************************************************************************************/

/*------------------------------------------------------------------------------------------*/
/*	 								include files						 				    */
/*------------------------------------------------------------------------------------------*/
#include <string.h>
#include "2410lib.h"
#include "lcdlib.h"
#include "glib.h"
#include "lcd.h"
#include "def.h"
#include "demo.h"
#define LCD_D_OFF 			rGPCDAT &= ~(1 << 4); 
#define LCD_D_ON 			rGPCDAT |= (1 << 4); 

/*------------------------------------------------------------------------------------------*/
/*	 								constant define							 			    */
/*------------------------------------------------------------------------------------------*/
#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)

/*------------------------------------------------------------------------------------------*/
/*	 								extern variables						 			    */
/*------------------------------------------------------------------------------------------*/
	
extern const UINT8T g_ucBitmap[][76800];
extern UINT8T g_ucAscii8x16[];
extern UINT8T g_ucHZK16[];
extern UINT8T g_auc_hzk24[];
/*------------------------------------------------------------------------------------------*/
/*	 								function declare                                        */
/*------------------------------------------------------------------------------------------*/
void lcd_disp_ascii6x8(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T * s);
void lcd_disp_ascii8x16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T * s);
void lcd_disp_str16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T *s);
void lcd_disp_hz24(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T *s);
void Lcd_Draw_HLine(INT16T usX0, INT16T usX1, INT16T usY0, UINT8T ucColor, UINT16T usWidth);
void Lcd_Draw_VLine (INT16T usY0, INT16T usY1, INT16T usX0, UINT8T ucColor, UINT16T usWidth);
void lcd_clr(void);

/*********************************************************************************************
* name:		lcd_init_app
* func:		lcd application initialization code 
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_init_app()
{
    Lcd_port_init();
    Lcd_Init(MODE_CSTN_8BIT);
    Glib_Init(MODE_CSTN_8BIT);
    Glib_ClearScr(GREEN-20, MODE_CSTN_8BIT);
    Lcd_PowerEnable(0, 1);
    Lcd_EnvidOnOff(1);	
    uart_printf(" STN 256 COLOR(8bit/1pixel) LCD TEST\n");

}

/*********************************************************************************************
* name:		lcd_init_app_end
* func:		end lcd application initialization
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_init_app_end()
{
    Lcd_EnvidOnOff(0);
    Lcd_Port_Return();
}
/*********************************************************************************************
* name:		lcd_disp_str16()
* func:		display 8x16 ASCII character string and 16x16 chinese character string 
* para:		usX0,usY0 -- character string's start point coordinate
*			ForeColor -- appointed color value
*			pucChar   -- ASCII character string
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
extern int f_nPadRow;
void lcd_disp_str16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T *s)
{
	UINT16T i,j,k,x,y,xx=0,yy,ch=0;
	UINT8T qm,wm;
	UINT32T ulOffset;
	INT8T ywbuf[16],hzbuf[32];//,temp[2];

	for( i = 0; i < strlen((const char*)s); i++ )
	{
		if( ((UINT8T)(*(s+i))) < 161 )
		{
			ch++;
			if(xx > 300)
			{
				ch = 0;
				x0 = 15;
				y0 += f_nPadRow;
			}
			qm = *(s+i);
			ulOffset = (UINT32T)(qm) * 16;		//Here to be changed tomorrow
			for( j = 0; j < 16; j ++ )
			{
				ywbuf[j] = g_ucAscii8x16[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 + ch*8;
			       			yy = y + y0;
			       			PutPixel(xx, yy, (UINT8T)ForeColor);
			       		}
			   	}
            		}
		}
		else
		{
			ch++;
			if(xx > 288) 
			{
				ch = 0;
				x0 = 15;
				y0 += f_nPadRow;
			}
			qm = *(s+i) - 161;
    		wm = *(s + i + 1) - 161;
       		ulOffset = (UINT32T)(qm * 94 + wm) * 32;
			for( j = 0; j < 32; j ++ )
            		{
            			hzbuf[j] = g_ucHZK16[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 + ch * 8;
				    		yy = y + y0;
				    		PutPixel( xx, yy, (UINT8T)ForeColor);
				    	}
			   	}
           		}
	    	i++;
	    	ch++;
		}
	}
}	
/*********************************************************************************************
* name:		lcd_disp_hz24
* func:		display 24x24 Chinese Symbol on Lcd  
* para:		UINT16T x0          --  x coordinate of start point
*           UINT16T y0          --  y coordinate of start point
*           UINT8T Forecolor --  foreground color of lcd 
*           UINT8T *s        --  string to display 
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_disp_hz24(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T *s)
{
	INT16T i,j,k,x,y,xx;
	UINT8T qm,wm;
	INT32T ulOffset;
	INT8T hzbuf[72],temp[2];

	for(i = 0; i < strlen((const char*)s); i++)
	{
		if(((UINT8T)(*(s+i))) < 161)
		{
			temp[0] = *(s+i);
			temp[1] = '\0';
			break;
		}
		else
		{
			qm = *(s+i) - 176;                                  //161;
	    		wm = *(s+i + 1) - 161;
            		ulOffset = (INT32T)(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, (UINT8T)ForeColor);
			       	}
			      }
            		}
		    	i++;
         	}
     	}     	
}
/*********************************************************************************************
* name:		lcd_disp_ascii6x8()
* func:		display 6x8 ASCII character string 
* para:		usX0,usY0 -- ASCII character string's start point coordinate
*			ForeColor -- appointed color value
*			pucChar   -- ASCII character string
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
/*
#define XWIDTH 			6
extern UINT8T g_ucAscii6x8[];
void lcd_disp_ascii6x8(UINT16T usX0, UINT16T usY0,UINT8T ForeColor, UINT8T* pucChar)
{
	UINT32T i,j;
	UINT8T  ucTemp;

	while( *pucChar != 0 )
	{
		for( i=0; i < 8; i++ )
		{
  			ucTemp = g_ucAscii6x8[(*pucChar) * 8 + i];
  			for( j = 0; j < 8; j++ )
  			{
  				if( (ucTemp & (0x80 >> j)) != 0 )
  				{
  					PutPixel(usX0 + i, usY0 + 8 - j, (UINT8T)ForeColor);
  				}  				
  			}
		}
		usX0 += XWIDTH;
		pucChar++;
	}
}
*/
//#ifndef BOARDTEST	
/*********************************************************************************************
* name:		lcd_disp_ascii8x16
* func:		display 8x16 AscII Symbol on Lcd  
* para:		UINT16T x0          --  x coordinate of start point
*           UINT16T y0          --  y coordinate of start point
*           UINT8T Forecolor --  foreground color of lcd 
*           UINT8T *s        --  string to display 
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_disp_ascii8x16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T * s)
{
	INT16T i,j,k,x,y,xx;
	UINT8T qm;
	INT32T ulOffset;
	INT8T ywbuf[16],temp[2];
    
	for(i = 0; i < strlen((const char*)s); i++)
	{
		if((UINT8T)*(s+i) >= 161)
		{
			temp[0] = *(s + i);
			temp[1] = '\0';
			return;
		}
		else
		{
			qm = *(s+i);
            		ulOffset = (INT32T)(qm) * 16;	
            		for (j = 0; j < 16; j ++)
            		{
            			ywbuf[j] = g_ucAscii8x16[ulOffset + j];

⌨️ 快捷键说明

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