code/WPILib/Counter.cpp
/*
 * Get the Period of the most recent count.
 * Returns the time interval of the most recent count. This can be used for velocity calculations
 * to determine shaft speed.
 * @returns The period of the last two pulses in units of seconds.
 */
Get the Period of the most recent count.
Returns the time interval of the most recent count. This can be used for velocity calculations
to determine shaft speed.
@returns The period of the last two pulses in units of seconds.
Get the Period of the most recent count . Returns the time interval of the most recent count . This can be used for velocity calculations to determine shaft speed . @returns The period of the last two pulses in units of seconds .
double Counter::GetPeriod()
{
	tCounter::tTimerOutput output = m_counter->readTimerOutput(&status);
	double period;
	if (output.Stalled)
	{
		double zero = 0.0;
		period = 1.0 / zero;
	}
	else
	{
		period = (double)(output.Period << 1) / (double)output.Count;
	}
	wpi_assertCleanStatus(status);
	return period * 1.0e-6;
}
double Counter :: GetPeriod ( ) { tCounter :: tTimerOutput output = m_counter -> readTimerOutput ( & status ) ; double period ; if ( output . Stalled ) { double zero = 0.0 ; period = 1.0 / zero ; } else { period = ( double ) ( output . Period << 1 ) / ( double ) output . Count ; } wpi_assertCleanStatus ( status ) ; return period * 1.0e-6 ; }
Get the Period of the most recent count.
Get the Period of the most recent count .
// Return infinity // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits)