Пример #1
0
/**
  * @brief: 保存校准参数
  */
void TP_Save_Adjdata(void)
{
	s32 temp;			 
	//保存校正结果!		   							  
	temp=tp_dev.xfac*100000000;//保存x校正因素      
	AT24CXX_WriteLenByte(SAVE_ADDR_BASE,temp,4);   
	temp=tp_dev.yfac*100000000;//保存y校正因素    
	AT24CXX_WriteLenByte(SAVE_ADDR_BASE+4,temp,4);
	//保存x偏移量
	AT24CXX_WriteLenByte(SAVE_ADDR_BASE+8,tp_dev.xoff,2);		    
	//保存y偏移量
	AT24CXX_WriteLenByte(SAVE_ADDR_BASE+10,tp_dev.yoff,2);	
	//保存触屏类型
	AT24CXX_WriteOneByte(SAVE_ADDR_BASE+12,tp_dev.touchtype);	
	temp=0X0A;//标记校准过了
	AT24CXX_WriteOneByte(SAVE_ADDR_BASE+13,temp); 
}
Пример #2
0
//在AT24CXX里面的指定地址开始写入指定个数的数据
//WriteAddr :开始写入的地址 对24c02为0~255
//pBuffer   :数据数组首地址
//NumToWrite:要写入数据的个数
void AT24CXX_Write(u16 WriteAddr,u8 *pBuffer,u16 NumToWrite)
{
	while(NumToWrite--)
	{
		AT24CXX_WriteOneByte(WriteAddr,*pBuffer);
		WriteAddr++;
		pBuffer++;
	}
}
Пример #3
0
//检查AT24CXX是否正常
//这里用了24XX的最后一个地址(255)来存储标志字.
//如果用其他24C系列,这个地址要修改
//返回1:检测失败
//返回0:检测成功
u8 AT24CXX_Check(void)
{
	u8 temp;
	temp=AT24CXX_ReadOneByte(255);//避免每次开机都写AT24CXX			   
	if(temp==0X55)return 0;		   
	else//排除第一次初始化的情况
	{
		AT24CXX_WriteOneByte(255,0X55);
	    temp=AT24CXX_ReadOneByte(255);	  
		if(temp==0X55)return 0;
	}
	return 1;											  
}
Пример #4
0
uint8_t AT24CXX_Check(void)
{
	uint8_t temp;
	AT24CXX_ReadOneByte(255, &temp, 1);
	if(temp==0X55)return 0;		   
	else
	{
		AT24CXX_WriteOneByte(255,0X55);
	  AT24CXX_ReadOneByte(255, &temp, 1);	  
		if(temp==0X55)return 0;
	}
	return 1;											  
}
Пример #5
0
void key_idset(void)
{
	
	u8 h;
	if((KEY0==0)&&m)
	{
	   delay_us(10000);
	   m=0;
	   if(KEY0==0)
	   while(KEY0==0)
	   	{
	   	   delay_us(10000);
		   h++;
		   if(h>=250)break;
	   
	   	}
			   if(h>=250)
			   {		
					zhongduan_flag=0;
						
			   		Clera_lcd();
		
			   		Graf_setid(id_num);
			   }
			   else
				   {  
				     if(zhongduan_flag==1)
				      	{
					  		grafnum++;
					  		if(grafnum>6)grafnum=1;
					  
					    	  switch(grafnum)
								{				 
									case 1:	//显示功率因数和电压值
										Clera_lcd();
										Graf_con_u(gonglvshishu,dianya_zhi);
										break;
									case 2:	//显示电流
										Clera_lcd();
										Graf_cuirrent(dianliuzhi);
										break;
									case 3:	//显示无功功率	 
										Clera_lcd();
										Graf_qkvar(wugongkvar);
										break;
									case 4:	//显示温度 
										Clera_lcd();
										Graf_temp(tempshuzhi);
										break;
					
									case 5:	//显示ID 
										Clera_lcd();
										Graf_id(hguestnum,id_num);
										break;
					
									case 6:	//显示VER 
										Clera_lcd();
										Graf_ver(vernum);
										break;
					
								}
					 	}
						if(zhongduan_flag==0)
				      	{
					  		id_num++;
					  		if(id_num>32)id_num=0;
							Clera_lcd();
	   						Graf_setid(id_num);
							AT24CXX_WriteOneByte(0x0010,id_num);
						}
				   }
	
	}
	else if(KEY0==1)
		{
		 	m=1;
			delay_us(10000);
			 while(KEY0==1)
			 {
		   	   delay_us(10000);
			   h++;
			   if(h>=250)break;
	   
	   		 }
			   if(h>=250)
				 {
						  zhongduan_flag=1;
					  	  switch(grafnum)
							{				 
								case 1:	//显示功率因数和电压值
									Clera_lcd();
									Graf_con_u(gonglvshishu,dianya_zhi);
									break;
								case 2:	//显示电流
									Clera_lcd();
									Graf_cuirrent(dianliuzhi);
									break;
								case 3:	//显示无功功率	 
									Clera_lcd();
									Graf_qkvar(wugongkvar);
									break;
								case 4:	//显示温度 
									Clera_lcd();
									Graf_temp(tempshuzhi);
									break;
				
								case 5:	//显示ID 
									Clera_lcd();
									Graf_id(hguestnum,id_num);
									break;
				
								case 6:	//显示VER 
									Clera_lcd();
									Graf_ver(vernum);
									break;
				
							}	
				 }

		}
}