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

📄 lcd.c

📁 通过使用Embest EduKit II实验板的256色彩色液晶屏进行电路设计
💻 C
📖 第 1 页 / 共 2 页
字号:
    {
        usLen = usX1 - usX0 + 1;
        while( (usLen--) > 0 )
        {
        	LCD_PutPixel(usX0 + usLen, usY0, ucColor);
        }
        usY0++;
    }
}

/*********************************************************************************************
* name:		lcd_draw_vline()
* func:		Draw vertical line with appointed color
* para:		usX0,usY0 -- line's start point coordinate
*			usY1 -- line's end point Y-coordinate
*			ucColor -- appointed color value
*			usWidth -- line's width
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_draw_vline (UINT16T usY0, UINT16T usY1, UINT16T usX0, UINT8T ucColor, UINT16T usWidth)
{
	UINT16T usLen;

    if( usY1 < usY0 )
    {
        GUISWAP (usY1, usY0);
    }

    while( (usWidth--) > 0 )
    {
        usLen = usY1 - usY0 + 1;
        while( (usLen--) > 0 )
        {
        	LCD_PutPixel(usX0, usY0 + usLen, ucColor);
        }
        usX0++;
    }
}

/*********************************************************************************************
* name:		lcd_disp_ascii8x16()
* func:		display 8x16 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:		
*********************************************************************************************/
void lcd_disp_ascii8x16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T * s)
{
	UINT16T i,j,k,x,y,xx;
	UINT8T qm;
	UINT32T 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 = (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 + i*8;
			       		LCD_PutPixel(xx, y + y0, (UINT8T)ForeColor);
			       	}
			   	}
            }
		}
	}
}

/*********************************************************************************************
* 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:		
*********************************************************************************************/
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 )
  				{
  					LCD_PutPixel(usX0 + i, usY0 + 8 - j, (UINT8T)ForeColor);
  				}  				
  			}
		}
		usX0 += XWIDTH;
		pucChar++;
	}
}

#ifdef CHINESE_VERSION
/*********************************************************************************************
* name:		lcd_disp_hz16()
* func:		display chinese character string in 16x16 dot array
* para:		usX0,usY0 -- ASCII character string's start point coordinate
*			ForeColor -- appointed color value
*			pucChar   -- ASCII character string
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_disp_hz16(UINT16T x0, UINT16T y0, UINT8T ForeColor, UINT8T *s)
{
	UINT16T i,j,k,x,y,xx;
	UINT8T qm,wm;
	UINT32T ulOffset;
	INT8T hzbuf[32],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) - 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 + i * 8;
				    	LCD_PutPixel( xx, y + y0, (UINT8T)ForeColor);
				    }
			   	}
           	}
		    i++;
		}
	}
}
#endif
/************************************************************
* name:     lcd_testrect()
* func:     lcd show rectangle
* para:		none
* ret:		none
* modify:
* comment:
**************************************************************/
void lcd_testrect(void)
{
	int us_left=10,us_top=40,us_right=310,us_bottom=230,j;
	
		for(j=0;j<12;j++)//循环显示12个由大到小的矩形
		{
			lcd_draw_box(us_left,us_top,us_right,us_bottom,RED);
			us_left+=10;
			us_top+=5;
			us_right-=10;
			us_bottom-=5;
			delay(40000);
		}
		delay(40000);
		lcd_clr();
		
}
/************************************************************
* name:     lcd_testhz()
* func:     lcd show 汉字
* para:		none
* ret:		none
* modify:
* comment:
**************************************************************/
void lcd_testhz(void)
{
		lcd_disp_hz16(10,34,BLUE,"单位:西安建筑科技大学");
		lcd_draw_hline(60,190,50,BLACK,2);//划线:长度190
		lcd_disp_hz16(10,74,BLUE,"实验名称:嵌入式系统开发");
		lcd_draw_hline(90,200,90,BLACK,2);
		lcd_disp_hz16(10,114,BLUE,"小组人员:贾宗星;张维勤;代平");
		lcd_draw_hline(90,251,130,BLACK,2);
		delay(80000);
		lcd_clr();

}
/************************************************************
* name:     lcd_testpic()
* func:     lcd show picture
* para:		none
* ret:		none
* modify:
* comment:
**************************************************************/
void lcd_testpic(void)
{
	int i;
	
	for (i = 0; i < 3; i++)// 循环显示三幅图片
	{
		bitmap_view320x240x256((UINT8T*)(g_ucBitmap[i]));
		delay(20000);
	}
	delay(40000);
	lcd_clr();
}
/*********************************************************************************************
* name:		lcd_test()
* func:		LCD test function
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void lcd_test(void)
{
	int i,j;
	
	lcd_init();									// initial LCD controller
	lcd_clr();									// clear screen

#ifdef CHINESE_VERSION
	lcd_disp_hz16(10,10,BLUE,"开发平台");
#else
	lcd_disp_ascii8x16(10,0,BLUE,"Embest S3CEV40 ");
#endif
   	while (1)
	{
		lcd_testhz();//调用显示汉字功能函数
		delay(20000);
		lcd_testrect();//调用显示矩形功能函数
		delay(20000);
		lcd_testpic();//调用显示图片功能函数
		
	}
}

⌨️ 快捷键说明

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