WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::AnalogEncoder Class Reference

Class for supporting continuous analog encoders, such as the US Digital MA3. More...

#include <wpi/hardware/rotation/AnalogEncoder.hpp>

Inheritance diagram for wpi::AnalogEncoder:
wpi::util::Sendable wpi::util::SendableHelper< AnalogEncoder >

Public Member Functions

 AnalogEncoder (int channel)
 Construct a new AnalogEncoder attached to a specific AnalogIn channel.
 AnalogEncoder (AnalogInput &analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 AnalogEncoder (AnalogInput *analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 AnalogEncoder (std::shared_ptr< AnalogInput > analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 AnalogEncoder (int channel, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogIn channel.
 AnalogEncoder (AnalogInput &analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 AnalogEncoder (AnalogInput *analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 AnalogEncoder (std::shared_ptr< AnalogInput > analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 ~AnalogEncoder () override
 AnalogEncoder (AnalogEncoder &&)=default
AnalogEncoderoperator= (AnalogEncoder &&)=default
double Get () const
 Get the encoder value.
void SetVoltagePercentageRange (double min, double max)
 Set the encoder voltage percentage range.
void SetInverted (bool inverted)
 Set if this encoder is inverted.
int GetChannel () const
 Get the channel number.
void InitSendable (wpi::util::SendableBuilder &builder) override
 Initializes this Sendable object.
Public Member Functions inherited from wpi::util::Sendable
virtual constexpr ~Sendable ()=default
Public Member Functions inherited from wpi::util::SendableHelper< AnalogEncoder >
constexpr SendableHelper (const SendableHelper &rhs)=default
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default

Additional Inherited Members

Protected Member Functions inherited from wpi::util::SendableHelper< AnalogEncoder >
constexpr ~SendableHelper ()

Detailed Description

Class for supporting continuous analog encoders, such as the US Digital MA3.

Constructor & Destructor Documentation

◆ AnalogEncoder() [1/9]

wpi::AnalogEncoder::AnalogEncoder ( int channel)
explicit

Construct a new AnalogEncoder attached to a specific AnalogIn channel.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
channelthe analog input channel to attach to

◆ AnalogEncoder() [2/9]

wpi::AnalogEncoder::AnalogEncoder ( AnalogInput & analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [3/9]

wpi::AnalogEncoder::AnalogEncoder ( AnalogInput * analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [4/9]

wpi::AnalogEncoder::AnalogEncoder ( std::shared_ptr< AnalogInput > analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [5/9]

wpi::AnalogEncoder::AnalogEncoder ( int channel,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogIn channel.

Parameters
channelthe analog input channel to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [6/9]

wpi::AnalogEncoder::AnalogEncoder ( AnalogInput & analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [7/9]

wpi::AnalogEncoder::AnalogEncoder ( AnalogInput * analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [8/9]

wpi::AnalogEncoder::AnalogEncoder ( std::shared_ptr< AnalogInput > analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ ~AnalogEncoder()

wpi::AnalogEncoder::~AnalogEncoder ( )
override

◆ AnalogEncoder() [9/9]

wpi::AnalogEncoder::AnalogEncoder ( AnalogEncoder && )
default

Member Function Documentation

◆ Get()

double wpi::AnalogEncoder::Get ( ) const

Get the encoder value.

Returns
the encoder value scaled by the full range input

◆ GetChannel()

int wpi::AnalogEncoder::GetChannel ( ) const

Get the channel number.

Returns
The channel number.

◆ InitSendable()

void wpi::AnalogEncoder::InitSendable ( wpi::util::SendableBuilder & builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::util::Sendable.

◆ operator=()

AnalogEncoder & wpi::AnalogEncoder::operator= ( AnalogEncoder && )
default

◆ SetInverted()

void wpi::AnalogEncoder::SetInverted ( bool inverted)

Set if this encoder is inverted.

Parameters
invertedtrue to invert the encoder, false otherwise

◆ SetVoltagePercentageRange()

void wpi::AnalogEncoder::SetVoltagePercentageRange ( double min,
double max )

Set the encoder voltage percentage range.

Analog sensors are not always fully stable at the end of their travel ranges. Shrinking this range down can help mitigate issues with that.

Parameters
minminimum voltage percentage (0-1 range)
maxmaximum voltage percentage (0-1 range)

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