![]() |
WPILibC++ 2027.0.0-alpha-5
|
Analog input class. More...
#include <wpi/hardware/discrete/AnalogInput.hpp>
Public Member Functions | |
| AnalogInput (int channel) | |
| Construct an analog input. | |
| AnalogInput (AnalogInput &&)=default | |
| AnalogInput & | operator= (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 SendableHelper & | operator= (const SendableHelper &rhs)=default |
Additional Inherited Members | |
| Protected Member Functions inherited from wpi::util::SendableHelper< AnalogInput > | |
| constexpr | ~SendableHelper () |
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.
|
explicit |
Construct an analog input.
| channel | The SmartIO channel to use. |
|
default |
|
overridedefault |
| int wpi::AnalogInput::GetChannel | ( | ) | const |
Get the channel number.
| 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.
| double wpi::AnalogInput::GetVoltage | ( | ) | const |
Get a scaled sample straight from this channel.
The value is scaled to units of Volts.
|
overridevirtual |
Initializes this Sendable object.
| builder | sendable builder |
Implements wpi::util::Sendable.
|
default |
| void wpi::AnalogInput::SetSimDevice | ( | HAL_SimDeviceHandle | device | ) |
Indicates this input is used by a simulated device.
| device | simulated device handle |