WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
frc::GearTooth Class Reference

Alias for counter class. More...

#include <GearTooth.h>

Inheritance diagram for frc::GearTooth:
frc::Counter frc::ErrorBase frc::SendableBase frc::CounterBase frc::Sendable

Public Member Functions

 GearTooth (int channel, bool directionSensitive=false)
 Construct a GearTooth sensor given a channel. More...
 
 GearTooth (DigitalSource *source, bool directionSensitive=false)
 Construct a GearTooth sensor given a digital input. More...
 
 GearTooth (std::shared_ptr< DigitalSource > source, bool directionSensitive=false)
 Construct a GearTooth sensor given a digital input. More...
 
 GearTooth (GearTooth &&)=default
 
GearToothoperator= (GearTooth &&)=default
 
void EnableDirectionSensing (bool directionSensitive)
 Common code called by the constructors.
 
void InitSendable (SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from frc::Counter
 Counter (Mode mode=kTwoPulse)
 Create an instance of a counter where no sources are selected. More...
 
 Counter (int channel)
 Create an instance of a Counter object. More...
 
 Counter (DigitalSource *source)
 Create an instance of a counter from a Digital Source (such as a Digital Input). More...
 
 Counter (std::shared_ptr< DigitalSource > source)
 Create an instance of a counter from a Digital Source (such as a Digital Input). More...
 
 Counter (const AnalogTrigger &trigger)
 Create an instance of a Counter object. More...
 
 Counter (EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted)
 Create an instance of a Counter object. More...
 
 Counter (EncodingType encodingType, std::shared_ptr< DigitalSource > upSource, std::shared_ptr< DigitalSource > downSource, bool inverted)
 Create an instance of a Counter object. More...
 
 Counter (Counter &&rhs)
 
Counteroperator= (Counter &&rhs)
 
void SetUpSource (int channel)
 Set the upsource for the counter as a digital input channel. More...
 
void SetUpSource (AnalogTrigger *analogTrigger, AnalogTriggerType triggerType)
 Set the up counting source to be an analog trigger. More...
 
void SetUpSource (std::shared_ptr< AnalogTrigger > analogTrigger, AnalogTriggerType triggerType)
 Set the up counting source to be an analog trigger. More...
 
void SetUpSource (DigitalSource *source)
 
void SetUpSource (std::shared_ptr< DigitalSource > source)
 Set the source object that causes the counter to count up. More...
 
void SetUpSource (DigitalSource &source)
 Set the source object that causes the counter to count up. More...
 
void SetUpSourceEdge (bool risingEdge, bool fallingEdge)
 Set the edge sensitivity on an up counting source. More...
 
void ClearUpSource ()
 Disable the up counting source to the counter.
 
void SetDownSource (int channel)
 Set the down counting source to be a digital input channel. More...
 
void SetDownSource (AnalogTrigger *analogTrigger, AnalogTriggerType triggerType)
 Set the down counting source to be an analog trigger. More...
 
void SetDownSource (std::shared_ptr< AnalogTrigger > analogTrigger, AnalogTriggerType triggerType)
 Set the down counting source to be an analog trigger. More...
 
void SetDownSource (DigitalSource *source)
 Set the source object that causes the counter to count down. More...
 
void SetDownSource (DigitalSource &source)
 Set the source object that causes the counter to count down. More...
 
void SetDownSource (std::shared_ptr< DigitalSource > source)
 
void SetDownSourceEdge (bool risingEdge, bool fallingEdge)
 Set the edge sensitivity on a down counting source. More...
 
void ClearDownSource ()
 Disable the down counting source to the counter.
 
void SetUpDownCounterMode ()
 Set standard up / down counting mode on this counter. More...
 
void SetExternalDirectionMode ()
 Set external direction mode on this counter. More...
 
void SetSemiPeriodMode (bool highSemiPeriod)
 Set Semi-period mode on this counter. More...
 
void SetPulseLengthMode (double threshold)
 Configure the counter to count in up or down based on the length of the input pulse. More...
 
void SetReverseDirection (bool reverseDirection)
 Set the Counter to return reversed sensing on the direction. More...
 
void SetSamplesToAverage (int samplesToAverage)
 Set the Samples to Average which specifies the number of samples of the timer to average when calculating the period. More...
 
int GetSamplesToAverage () const
 Get the Samples to Average which specifies the number of samples of the timer to average when calculating the period. More...
 
int GetFPGAIndex () const
 
int Get () const override
 Read the current counter value. More...
 
void Reset () override
 Reset the Counter to zero. More...
 
double GetPeriod () const override
 Get the Period of the most recent count. More...
 
void SetMaxPeriod (double maxPeriod) override
 Set the maximum period where the device is still considered "moving". More...
 
void SetUpdateWhenEmpty (bool enabled)
 Select whether you want to continue updating the event timer output when there are no samples captured. More...
 
bool GetStopped () const override
 Determine if the clock is stopped. More...
 
bool GetDirection () const override
 The last direction the counter value changed. More...
 
void InitSendable (SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from frc::ErrorBase
 ErrorBase (ErrorBase &&)=default
 
ErrorBaseoperator= (ErrorBase &&)=default
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 Retrieve the current error. More...
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual void SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 
- Public Member Functions inherited from frc::SendableBase
 SendableBase (bool addLiveWindow=true)
 Creates an instance of the sensor base. More...
 
 SendableBase (SendableBase &&rhs)
 
SendableBaseoperator= (SendableBase &&rhs)
 
std::string GetName () const final
 Gets the name of this Sendable object. More...
 
void SetName (const wpi::Twine &name) final
 Sets the name of this Sendable object. More...
 
std::string GetSubsystem () const final
 Gets the subsystem name of this Sendable object. More...
 
void SetSubsystem (const wpi::Twine &subsystem) final
 Sets the subsystem name of this Sendable object. More...
 
- Public Member Functions inherited from frc::Sendable
 Sendable (Sendable &&)=default
 
Sendableoperator= (Sendable &&)=default
 
void SetName (const wpi::Twine &subsystem, const wpi::Twine &name)
 Sets both the subsystem name and device name of this Sendable object. More...
 
- Public Member Functions inherited from frc::CounterBase
 CounterBase (CounterBase &&)=default
 
CounterBaseoperator= (CounterBase &&)=default
 

Static Public Attributes

static constexpr double kGearToothThreshold = 55e-6
 

Additional Inherited Members

- Public Types inherited from frc::Counter
enum  Mode { kTwoPulse = 0, kSemiperiod = 1, kPulseLength = 2, kExternalDirection = 3 }
 
- Public Types inherited from frc::CounterBase
enum  EncodingType { k1X, k2X, k4X }
 
- Static Public Member Functions inherited from frc::ErrorBase
static void SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static void SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber)
 
static const ErrorGetGlobalError ()
 Retrieve the current global error.
 
- Protected Member Functions inherited from frc::SendableBase
void AddChild (std::shared_ptr< Sendable > child)
 Add a child component. More...
 
void AddChild (void *child)
 Add a child component. More...
 
void SetName (const wpi::Twine &moduleType, int channel)
 Sets the name of the sensor with a channel number. More...
 
void SetName (const wpi::Twine &moduleType, int moduleNumber, int channel)
 Sets the name of the sensor with a module and channel number. More...
 
- Protected Attributes inherited from frc::Counter
std::shared_ptr< DigitalSourcem_upSource
 
std::shared_ptr< DigitalSourcem_downSource
 
HAL_CounterHandle m_counter = HAL_kInvalidHandle
 
- Protected Attributes inherited from frc::ErrorBase
Error m_error
 

Detailed Description

Alias for counter class.

Implements the gear tooth sensor supplied by FIRST. Currently there is no reverse sensing on the gear tooth sensor, but in future versions we might implement the necessary timing in the FPGA to sense direction.

Constructor & Destructor Documentation

frc::GearTooth::GearTooth ( int  channel,
bool  directionSensitive = false 
)
explicit

Construct a GearTooth sensor given a channel.

Parameters
channelThe DIO channel that the sensor is connected to. 0-9 are on-board, 10-25 are on the MXP.
directionSensitiveTrue to enable the pulse length decoding in hardware to specify count direction.
frc::GearTooth::GearTooth ( DigitalSource source,
bool  directionSensitive = false 
)
explicit

Construct a GearTooth sensor given a digital input.

This should be used when sharing digital inputs.

Parameters
sourceA pointer to the existing DigitalSource object (such as a DigitalInput)
directionSensitiveTrue to enable the pulse length decoding in hardware to specify count direction.
frc::GearTooth::GearTooth ( std::shared_ptr< DigitalSource source,
bool  directionSensitive = false 
)
explicit

Construct a GearTooth sensor given a digital input.

This should be used when sharing digital inputs.

Parameters
sourceA reference to the existing DigitalSource object (such as a DigitalInput)
directionSensitiveTrue to enable the pulse length decoding in hardware to specify count direction.

Member Function Documentation

void frc::GearTooth::InitSendable ( SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements frc::Sendable.


The documentation for this class was generated from the following file: