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

📄 gui.c

📁 我改写的在TFT上显示SD卡中BMP文件的程序
💻 C
字号:
/******************************************
//测试系统
//芯片:ATmega16L
//频率:8MHz内频
//电压:3.3V
*******************************************/

#include"gui.h"


//
//与LCD硬件无关的函数

#if _GUI_DISP_NUM == 1
const unsigned char suzi[] PROGMEM={
/*--  0  --*/
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,

/*--  1  --*/
0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,

/*--  2  --*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,

/*--  3  --*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,

/*--  4  --*/
0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,

/*--  5  --*/
0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,

/*--  6  --*/
0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00,

/*--  7  --*/
0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,

/*--  8  --*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,

/*--  9  --*/
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00,

/*--  ??×?:  A  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3C,0x44,0x42,0x42,0xE7,0x00,0x00,

/*--  ??×?:  B  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0xF8,0x44,0x44,0x44,0x78,0x44,0x42,0x42,0x42,0x44,0xF8,0x00,0x00,

/*--  ??×?:  C  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0x3E,0x42,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00,

/*--  ??×?:  D  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0xF8,0x44,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x44,0xF8,0x00,0x00,

/*--  ??×?:  E  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x42,0x42,0xFC,0x00,0x00,

/*--  ??×?:  F  --*/
/*--  ??ì?12;  ′?×?ì?????ó|μ?μ??ó?a£o?íx??=8x16   --*/
0x00,0x00,0x00,0xFC,0x42,0x48,0x48,0x78,0x48,0x48,0x40,0x40,0x40,0xE0,0x00,0x00,
};





/*********************************************
//显示数字函数
//(x,y)点的坐标量,nu数字值,color颜色,b_color背景颜色
**********************************************/
void  GUI_sprintf_nu(unsigned char x, unsigned int y,unsigned char nu, unsigned int color,unsigned int b_color)
{  
	unsigned char  s_x ,s_y, temp ;
  
	for( s_y=0 ; s_y < 16 ; s_y++ )
		{
		if(s_y+y<320)
			{
			temp = pgm_read_byte(suzi+nu*16+s_y) ;
	  
			for( s_x=0 ; s_x<8 ; s_x++ )
				{
				if(x+s_x<240)
					{
					if((temp&(0x80>>(s_x))) == (0x80>>(s_x))  )
						{
						LCD_Point(x+s_x, y+s_y,color) ;
						}
					else
						{
						LCD_Point(x+s_x, y+s_y,b_color) ;
						}
					}
				}
			}
		}
}


/**********************************************************
//写入二进制字符
//(x,y)开始点的坐标量,color 线的颜色,
************************************************************/
void  GUI_sprintf_chartobit(unsigned char x, unsigned int y,unsigned char bin_data, unsigned int color,unsigned int b_color)
{  
  unsigned char i ;
  for(i=0;i<8;i++)
    {
	  if((bin_data&(0x80>>i))==(0x80>>i))
	    {
		  GUI_sprintf_nu(x,y,1,color,b_color) ;
		}
	  else 
	    {
		  GUI_sprintf_nu(x,y,0,color,b_color) ;
		}
		
	  x+=8 ;
	}
 
}


/**********************************************************
//写入十六进制字符
//(x,y)开始点的坐标量,color 线的颜色,
************************************************************/
void  GUI_sprintf_chartohex(unsigned char x, unsigned int y,unsigned char hex_data, unsigned int color,unsigned int b_color)
{  
  unsigned char i ;

		  GUI_sprintf_nu(x,y,hex_data>>4,color,b_color) ;
		  x+=8 ;
		  GUI_sprintf_nu(x,y,hex_data&0x0f,color,b_color) ;

 
}
#endif//_GUI_DISP_NUM == 1

#if _GUI_DISP_LINE == 1
/******************************************************************** 
函 数 名:line()
功    能:画线
说    明:在12864屏上画线
入口参数:tx,ty ,xe,ye,   color
          起点    终点     颜色
返 回 值:无
***********************************************************************/
void GUI_Line(unsigned int x0,unsigned int y0,unsigned int xt,unsigned int yt,unsigned int color)  
{  
	unsigned int t;  
	int xerr=0,yerr=0,delta_x,delta_y,distance;  
	int incx,incy;  
	unsigned int row,col;  
	delta_x = xt-x0;					//计算坐标增量  
	delta_y = yt-y0;  
	col = x0;  
	row = y0;

	if(delta_x>0)						//设置单步方向  
		incx=1;
	else   
		{  
		if( delta_x==0)
			incx=0;						//垂直线  
		else
			{
			incx=-1;
			delta_x=-delta_x;
			}  
		}

	if(delta_y>0)
		incy=1;  
	else  
		{  
		if( delta_y==0)
			incy=0;						//水平线  
		else
			{
			incy=-1;
			delta_y=-delta_y;
			}  
		}

	if(delta_x> delta_y )
		distance=delta_x;				//选取基本增量坐标轴  
	else
		distance=delta_y;  

	for( t=0;t <= distance+1; t++ )  
		{								//画线输出  
		LCD_Point(col, row, color);
 
		xerr +=delta_x;
		yerr +=delta_y;

		if(xerr > distance)  
			{  
			xerr -= distance;  
			col += incx;  
			}  
		if(yerr > distance)  
			{  
			yerr -= distance;  
			row += incy;  
			}  
		}  
}

#endif	//_GUI_DISP_LINE == 1

⌨️ 快捷键说明

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