WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
wpi::AnalogInput Class Reference

Analog input class. More...

#include <wpi/hardware/discrete/AnalogInput.hpp>

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

Public Member Functions

 AnalogInput (int channel)
 Construct an analog input.
 AnalogInput (AnalogInput &&)=default
AnalogInputoperator= (AnalogInput &&)=default
 ~AnalogInput () override=default
int GetValue () const
 Get a sample straight from this channel.
double GetVoltage () const
 Get a scaled sample straight from this channel.
int GetChannel () const
 Get the channel number.
void SetSimDevice (HAL_SimDeviceHandle device)
 Indicates this input is used by a simulated device.
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< AnalogInput >
constexpr SendableHelper (const SendableHelper &rhs)=default
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default

Additional Inherited Members

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

Detailed Description

Analog input class.

Connected to each analog channel is an averaging and oversampling engine. This engine accumulates the specified ( by SetAverageBits() and SetOversampleBits() ) number of samples before returning a new value. This is not a sliding window average. The only difference between the oversampled samples and the averaged samples is that the oversampled samples are simply accumulated effectively increasing the resolution, while the averaged samples are divided by the number of samples to retain the resolution, but get more stable values.

Constructor & Destructor Documentation

◆ AnalogInput() [1/2]

wpi::AnalogInput::AnalogInput ( int channel)
explicit

Construct an analog input.

Parameters
channelThe SmartIO channel to use.

◆ AnalogInput() [2/2]

wpi::AnalogInput::AnalogInput ( AnalogInput && )
default

◆ ~AnalogInput()

wpi::AnalogInput::~AnalogInput ( )
overridedefault

Member Function Documentation

◆ GetChannel()

int wpi::AnalogInput::GetChannel ( ) const

Get the channel number.

Returns
The channel number.

◆ GetValue()

int wpi::AnalogInput::GetValue ( ) const

Get a sample straight from this channel.

The sample is a 12-bit value representing the 0V to 3.3V range of the A/D converter in the module. The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.

Returns
A sample straight from this channel.

◆ GetVoltage()

double wpi::AnalogInput::GetVoltage ( ) const

Get a scaled sample straight from this channel.

The value is scaled to units of Volts.

Returns
A scaled sample straight from this channel.

◆ InitSendable()

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

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::util::Sendable.

◆ operator=()

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

◆ SetSimDevice()

void wpi::AnalogInput::SetSimDevice ( HAL_SimDeviceHandle device)

Indicates this input is used by a simulated device.

Parameters
devicesimulated device handle

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