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

📄 lcd.c

📁 LCD.C
💻 C
📖 第 1 页 / 共 3 页
字号:
        
/********************************************/
/*画线。任意方向的斜线,直线数学方程	aX+bY=1	*/
/********************************************/
// 参数类型有待修改
void Linexy(unsigned int x0,unsigned char y0,
		unsigned int xt,unsigned char yt,
		unsigned char att,unsigned char locate)
{
    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++ )
	{											//画线输出
		Point((unsigned int)col,row,att,locate);				//画点
		xerr +=	delta_x	;
		yerr +=	delta_y	;
		
		if(	xerr > distance	)
		{
			xerr-=distance;
			col+=incx;
		}
		if(	yerr > distance	)
		{
			yerr-=distance;
			row+=incy;
		}
	}
}

void PutWord(unsigned int x,unsigned char y,
		unsigned char* index,unsigned char number)
{
    unsigned char i;
    for (i=0;i<number;i++)
    {
        PutCdotInGraph2( x+i*2,y,*(index+i),16);
    }
}

void block(unsigned char zone,unsigned char locate)
{  
    unsigned int Optr,tempCount1;
    unsigned char tempCount2;
    
	WriteCommand( CsrDirR );						// 自动右移。

	for(tempCount1=0;tempCount1<31;tempCount1++)
	{   
	    Optr=paraP9*tempCount1+zone*10;
		WriteCommand( CsrW );						// 光标定位指令  zone*8
		WriteData( (unsigned char)(Optr &0xff) );		    // 设置光标地址CSR
		WriteData( (unsigned char)(Optr /256 )+BasePart2*locate );
		WriteCommand( mWrite );	
        for(tempCount2=0;tempCount2<10;tempCount2++)
        {	
            WriteData(0xff);
        }	
	}
}


void kuang(unsigned char locate)
{  
    unsigned int Optr,tempCount1;
    unsigned char tempCount2;
    
    WriteCommand( CsrDirR );						// 自动右移。
    for(tempCount1=0;tempCount1<8;tempCount1++)
    {
        Optr=2240+920*tempCount1;
        WriteCommand( CsrW );
        WriteData( (unsigned char)(Optr &0xff) );		    // 设置光标地址CSR
        WriteData( (unsigned char)(Optr /256 )+BasePart2*locate );
        WriteCommand( mWrite );
        for(tempCount2=0;tempCount2<paraP9;tempCount2++)
        {	
            WriteData(0xff);
        }
    }
}
//绘画按键
void button( unsigned int x0,unsigned char y0,
			unsigned int length,unsigned char width,
			unsigned char att,unsigned char locate)
{ 
    unsigned int xt;
    unsigned char yt;
    xt=x0+length;
    yt=y0+width;
    Linexy(x0,y0,xt,y0,att,locate); 
    Linexy(x0,y0,x0,yt,att,locate);
    Linexy(x0,yt,xt-1,yt,att,locate);      
    Linexy(xt,y0,xt,yt-1,att,locate);   
    Linexy(x0+1,yt+1,xt,yt+1,att,locate);  
    Linexy(xt+1,y0+1,xt+1,yt,att,locate); 
    Linexy(x0+2,yt+2,xt+1,yt+2,att,locate);
    Linexy(xt+2,y0+2,xt+2,yt+1,att,locate); 
} 
//绘画矩形,两种方式
void rectangle_1( unsigned int x0,unsigned char y0,
			unsigned int xt,unsigned char yt,
			unsigned char att,unsigned char locate)
{ 
    Linexy(x0,y0,xt,y0,att,locate); 
    Linexy(x0,y0,x0,yt,att,locate);
    Linexy(x0,yt,xt,yt,att,locate);      
    Linexy(xt,y0,xt,yt,att,locate);   
} 



void rectangle_2( unsigned int x0,unsigned char y0,
			unsigned int length,unsigned char width,
			unsigned char att,unsigned char locate)
{ 
    unsigned int xt;
    unsigned char yt;
    xt=x0+length;
    yt=y0+width;
    Linexy(x0,y0,xt,y0,att,locate); 
    Linexy(x0,y0,x0,yt,att,locate);
    Linexy(x0,yt,xt,yt,att,locate);      
    Linexy(xt,y0,xt,yt,att,locate);  
} 

//绘画双矩形 矩形不能小于6*6
void rectangle2( unsigned int x0,unsigned char y0,
			unsigned int length,unsigned char width,
			unsigned char att,unsigned char locate)
{ 
    unsigned int xt;
    unsigned char yt;
    xt=x0+length;
    yt=y0+width;
    rectangle_2(x0,y0,length,width,att,locate);
    rectangle_2(x0+3,y0+3,length-6,width-6,att,locate); 
    Point(x0+1,y0+1,att,locate);
    Point(x0+2,y0+2,att,locate);
    Point(xt-1,y0+1,att,locate);
    Point(xt-2,y0+2,att,locate);
    Point(xt-1,yt-1,att,locate);
    Point(xt-2,yt-2,att,locate);
    Point(x0+1,yt-1,att,locate); 
    Point(x0+2,yt-2,att,locate);
}


unsigned char judge(unsigned int x,unsigned char y)
{  
    unsigned int x1;
    unsigned char y1;
    WriteCommand( CsrR );
    x1=ReadDataLcm();
    y1=ReadDataLcm();
    if((x1==x)&&(y1==y)) return 1;
    else return 0;
}	

extern uchar LCD_state;


void set_add(unsigned char locate)
{
	unsigned char a;
	unsigned int c;
	a=5;
	WriteCommand( CsrDirR ); 			// 光标移动方向定义:自动右移
	WriteCommand( CsrW );					// 光标Locate,定位
	//addr=0;
	WriteData( 0 );						// 写入参数CSRL设置参数光标指针低8位
	WriteData(0+locate*BasePart2 );	// 写入参数CSRH设置参数光标指针高8位
	WriteCommand( mWrite );
	for(c=0;c<1200;c++)	
		{
		WriteData( 0xff);						// 写入数据0
		}
		

		
		
		PutWord16_2(a+4,8,index+129,1,locate);
		PutWord16_2(a+8,8,index+130,1,locate);
		PutWord16_2(a+12,8,index+131,1,locate);
		PutWord16_2(a+16,8,index+132,1,locate);
		PutWord16_2(a+20,8,index+133,1,locate);
		PutWord16_2(a+24,8,index+134,1,locate);//上面的字
		//PutWord16

		
		//rectangle_2(200,35,80,30,0,locate);//去掉设置车厢号框子
		
		PutWord16(2,42,index+111,3,locate);//顺位号3字
		
		/*
		PutWord16(26,42,index+93,1,locate);
		PutWord16(26+2,42,index+93,1,locate);
		PutWord16(26+4,42,index+93,1,locate);
		PutWord16(26+6,42,index+93,1,locate);
		*/
	rectangle_2(160,35,30,30,1,locate);
	rectangle_2(208,35,30,30,1,locate); 
	//rectangle_2(161,36,28,28,1,locate);
	//rectangle_2(209,36,28,28,1,locate); //+ -框

	Linexy(165,50,185,50,1,locate);
	Linexy(175,40,175,60,1,locate);
	Linexy(213,50,233,50,1,locate); //+ -

	rectangle_2(260,35,40,30,1,locate);
	PutWord16(33,42,index+73,2,locate);

	rectangle_2(260,75,40,30,1,locate);
	PutWord16(33,82,index+135,2,locate);
    
    /*
	if(Set_No==22)
	{
		Set_No=1;
	}
	
	PutWord8(10,44,index+(unsigned char)(Set_No/10),1,locate);
	PutWord8(11,44,index+Set_No%10,1,locate);//车厢号
	*/
		
		
}

//; 图形方式下汉字显示方法,x方向2字节一个汉字
void PutWordInGraph( void ) 
{	
//x坐标以半个汉字定位左起0开始计算
//y坐标以像素行定位,顶部0开始计算
//汉字码以点阵码列表所对应32字节位单位进界,从0开始计算
    /*
	PutCdotInGraph( 28, 30, 6, 16 );	// 调汉字写入子程序,0=设置汉字代码
	PutCdotInGraph( 30, 30, 7, 16 );	// 调汉字写入子程序,1=设置汉字代码
	PutCdotInGraph(	32, 30, 4, 16 );	// 调汉字写入子程序
	PutCdotInGraph( 34, 30, 5, 16 );	// 调汉字写入子程序
	PutCdotInGraph( 36, 30, 0, 16 );	// 调汉字写入子程序,0=设置汉字代码
	PutCdotInGraph( 38, 30, 1, 16 );	// 调汉字写入子程序,1=设置汉字代码
     */
		//delay_ms(50);
}
    


void LcmInition( void ) 
{

    unsigned char i;
    WriteCommand( SystemSet );			// 系统参数设置
    for (i=0;i<8;i++) {				
    	WriteData( ParaSysTable8[i] );	//
    }

    WriteCommand( Scroll ); 			//设定显示区域起始地址
    for (i=0;i<10;i++) {
    	WriteData( ParaScrTableA[i] );
    }
    WriteCommand( CsrForm );		// 光标形状设置,代码0x5d
    WriteData( 0x07 );				// 设置光标水平点为CSX=8
    WriteData( 0x07 );				// 光标为块状形式,垂直点为CSY=8
    WriteCommand( HdotScr );		// 写入点位移指令代码
    WriteData( 0 );					// 写入P1参数
    WriteCommand( Ovlay );			// 显示合成方式设置
    WriteData( 0x0C );					// 0000 0100 显示图形文本,三区文本属性,二重"或"合成
    WriteCommand( DispOn );			// 写入指令代码
    WriteData( 0x04 );				// 显示 1~4 区开显示,光标显示FR/32闪烁

}

//本车地址
extern unsigned char Local_Addr;
//查看地址
//extern unsigned char Obsv_Addr;
 /*=====================================
 初始化子程序
======================================*/
/*
void Timer_add_1(unsigned char locate)
{
	 
	 PutWord8(2,40,index1+((rtc_all.YEAR&0xf0)>>4),1,locate);
	 PutWord8(3,40,index1+(rtc_all.YEAR&0x0f),1,locate);//年
	 
	 PutWord8(4,40,index1+79,1,locate);
	 	 
	 PutWord8(5,40,index1+((rtc_all.MONTH&0xf0)>>4),1,locate);
	 PutWord8(6,40,index1+(rtc_all.MONTH&0x0f),1,locate);//月
	 
	 PutWord8(7,40,index1+79,1,locate);
	 
	 PutWord8(8,40,index1+((rtc_all.DAY&0xf0)>>4),1,locate);
	 PutWord8(9,40,index1+(rtc_all.DAY&0x0f),1,locate);//日
	 
	 	 
	 PutWord8(11,40,index1+((rtc_all.HOU&0xf0)>>4),1,locate);
	 PutWord8(12,40,index1+(rtc_all.HOU&0x0f),1,locate);
	 
	 PutWord8(13,40,index1+42,1,locate);
	 
	 PutWord8(14,40,index1+((rtc_all.MINTU&0xf0)>>4),1,locate);
	 PutWord8(15,40,index1+(rtc_all.MINTU&0x0f),1,locate);
	 
	 PutWord8(16,40,index1+42,1,locate);
	 
	 PutWord8(17,40,index1+((rtc_all.SECON&0xf0)>>4),1,locate);
	 PutWord8(18,40,index1+(rtc_all.SECON&0x0f),1,locate);
	
}
*/
//end of LCD.c

⌨️ 快捷键说明

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