コード例 #1
0
/// <summary>
/// _mapGP2Y0A21YK_CM: calculates the distance in centimeters using a LUT (LUT filled with data calculated by the inverse tranferfunction)
///    -> Two different LUTs depending on ADC reference voltage
/// </summary>
int DistanceGP2Y0A21YK::_mapGP2Y0A21YK_CM(int value)
{
	if (_refVoltage == 3)
	{
		int sum = 0;
		for (int i=0;i<_average;i++)
		{
			sum=sum + pgm_read_byte_near (transferFunctionLUT3V + (getDistanceRaw()/4));
		}
		return(sum/_average);
	}
	else
	{
		int sum = 0;
		for (int i=0;i<_average;i++)
		{
			sum=sum + pgm_read_byte_near (transferFunctionLUT5V + (getDistanceRaw()/4));
		}
		return(sum/_average);
	}
}
コード例 #2
0
/// <summary>
/// getDistanceCentimeter(): Returns the distance in centimeters
/// </summary>
int DistanceGP2Y0A21YK::getDistanceCentimeter()
{
	return _mapGP2Y0A21YK_CM(getDistanceRaw());
}
コード例 #3
0
/// <summary>
/// getDistanceVolt(): Returns the distance as a Voltage: ADC Input: 0V -> 5V (or 0V -> 3.3V)
/// </summary>
int DistanceGP2Y0A21YK::getDistanceVolt()
{
	return _mapGP2Y0A21YK_V(getDistanceRaw());
}
コード例 #4
0
double GP2Y0A21YK0F::getDistanceVolt()
{
	return (getDistanceRaw()*0.0049);
}
コード例 #5
0
/// getDistanceVolt(): Returns the distance as a Voltage: ADC Input: 0V -> 5V (or 0V -> 3.3V)
int AnalogDistanceSensor::getDistanceVolt()
{
  return _mapGP2Y0A21YK_V(getDistanceRaw());
}
コード例 #6
0
ファイル: GP2Y0A02F.cpp プロジェクト: rhae/arduino
/**
 *  Calculate the distance
 * 
 *  The value is read from the analogue pin and converted to a distance.
 * 
 *  \return distance in cm
 */
uint16_t GP2Y0A02F::getDistanceCm()
{
  return getDistanceCm( getDistanceRaw() );
}