AnalogInput
- class wpilib.AnalogInput(channel: SupportsInt | SupportsIndex)
Bases:
SendableAnalog 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.
Construct an analog input.
- Parameters:
channel – The SmartIO channel to use.
- getChannel() int
Get the channel number.
- Returns:
The channel number.
- getValue() int
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() float
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(builder: wpiutil._wpiutil.SendableBuilder) None
- setSimDevice(device: SupportsInt | SupportsIndex) None
Indicates this input is used by a simulated device.
- Parameters:
device – simulated device handle