/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.							  */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
/*----------------------------------------------------------------------------*/

#ifndef KANALOGULTRASONIC_H_
#define KANALOGULTRASONIC_H_

#include "SensorBase.h"

class AnalogChannel;
class AnalogModule;

/**
 * Use a rate gyro to return the robots heading relative to a starting position.
 * The Gyro class tracks the robots heading based on the starting position. As the robot
 * rotates the new heading is computed by integrating the rate of rotation returned
 * by the sensor. When the class is instantiated, it does a short calibration routine
 * where it samples the gyro while at rest to determine the default offset. This is
 * subtracted from each sample to determine the heading.
 */
class KAnalogUltrasonic : public SensorBase
{
public:
	static const float kSamplesPerSecond = 50.0; //gyro number
	static const float kCalibrationSampleTime = 5.0; //gyro number
	static const float kDefaultVoltsPerInch = 0.0098; //correct
	static const float kDefaultSetUpTime = 0.1; //correct

	KAnalogUltrasonic(UINT32 slot, UINT32 channel);
	explicit KAnalogUltrasonic(UINT32 channel);
	explicit KAnalogUltrasonic(AnalogChannel *channel);
	explicit KAnalogUltrasonic(AnalogChannel &channel);
	virtual ~KAnalogUltrasonic();
	float GetDistance();
	void SetVoltsPerInch (float voltsPerInch){ m_voltsPerInch = voltsPerInch;}
	float GetVoltsPerInch () {return m_voltsPerInch;}
	void SetSetUpTime (float SetUpTime){ m_setUpTime = SetUpTime;}
	float GetSetUpTime () { return m_setUpTime;}
	void Reset();
	

private:
	void Init();

	AnalogChannel *m_analog;
	float m_voltsPerInch;
	float m_setUpTime;
	float m_offset;
	bool m_channelAllocated;
};
#endif
