示例#1
0
int  GUI_TOUCH_X_MeasureY(void)
{
  	unsigned char t=0,t1,count=0;
	unsigned short int databuffer[10]={5,7,9,3,2,6,4,0,3,1};//数据组
	unsigned short temp=0,Y=0;	
 
    while(count<10)	//循环读数10次
	{	   	  
		databuffer[count]=ADS_Read(CMD_RDY);
		count++;  
	}  
	if(count==10)//一定要读到10次数据,否则丢弃
	{  
	    do//将数据X升序排列
		{	
			t1=0;		  
			for(t=0;t<count-1;t++)
			{
				if(databuffer[t]>databuffer[t+1])//升序排列
				{
					temp=databuffer[t+1];
					databuffer[t+1]=databuffer[t];
					databuffer[t]=temp;
					t1=1; 
				}  
			}
		}while(t1); 	    		 	 		  
		Y=(databuffer[3]+databuffer[4]+databuffer[5])/3;	  
	}
	return(Y); 
}
示例#2
0
void ADC_display()
{
	//char data[5];
	//float sensor;

	static signed int local_data, far_data;
	signed int temp;
	flag &= ~ BIT4;					// flag is reset
	if (!(flag & BIT5))
	{
		local_data = ADS_Read(1);	//read local temperature data and start a new
	}								//conversion for far-end temperature sensor.
	else
	{
		far_data = ADS_Read(0);		//read far-end temperature,and start a new conversion
									//for local temperature sensor.

		// transform the local_data to compensation codes of far-end.
		temp = far_data + local_compensation(local_data);

		temp = ADC_code2temp(temp);	// transform the far-end
									// thermocouple codes to temperature.

		if(flag & BIT8)				// display temperature in Fahrenheit
		{
			Act_temp = temp * 9 / 5 +320;
			LCD_display_temp(1,8,Act_temp);
			LCD_display_char(1,14,'F');
		}
		else
		{
			Act_temp = temp;
			LCD_display_temp(1,8,Act_temp);
			LCD_display_char(1,14,'C');
		}

	}
}
示例#3
0
u16 Read_XY(u8 CMD)
{
	u16 i, j;
	u16 buf[10];
	u16 sum=0;
	u16 temp;
	for(i=0;i<10;i++)buf[i]=ADS_Read(CMD);				    
	for(i=0;i<9; i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(buf[i]>buf[j])
			{
				temp=buf[i];
				buf[i]=buf[j];
				buf[j]=temp;
			}
		}
	}	  
	for(i=3;i<7;i++)sum+=buf[i];
	temp=sum/(4);
	return temp;   
}