pub struct AnalogInput { /* private fields */ }
Expand description
An analog input on the RoboRIO
Implementations§
Source§impl AnalogInput
impl AnalogInput
Sourcepub fn new(channel: i32) -> HalResult<AnalogInput>
pub fn new(channel: i32) -> HalResult<AnalogInput>
Create a new analog input on the specified channel, returning an error if initialization fails.
§Errors
Returns Err(HalError(0))
if the channel is invalid.
Sourcepub fn average_value(&self) -> HalResult<i32>
pub fn average_value(&self) -> HalResult<i32>
Read the average value of the analog input over some defined time period.
Sourcepub fn average_voltage(&self) -> HalResult<f64>
pub fn average_voltage(&self) -> HalResult<f64>
Read the average raw value of the analog input in volts over some defined time period.
Sourcepub fn set_average_bits(&mut self, bits: i32) -> HalResult<()>
pub fn set_average_bits(&mut self, bits: i32) -> HalResult<()>
Set the number of bits to use in averaging. Averaging will sample 2^bits actual reads.
Sourcepub fn average_bits(&self) -> HalResult<i32>
pub fn average_bits(&self) -> HalResult<i32>
Get the previously-set number of average bits.
Sourcepub fn set_oversample_bits(&mut self, bits: i32) -> HalResult<()>
pub fn set_oversample_bits(&mut self, bits: i32) -> HalResult<()>
Set the number of bits to use in oversampling to improve resolution with a slower rate. Oversampling will use 2^bits actual reads.
Sourcepub fn oversample_bits(&self) -> HalResult<i32>
pub fn oversample_bits(&self) -> HalResult<i32>
Get the previously-set number of oversample bits.
Sourcepub fn lsb_weight(&self) -> HalResult<i32>
pub fn lsb_weight(&self) -> HalResult<i32>
Get the factory scaling LSB weight constant: voltage = ((lsb_weight * 1e-9) * raw) - (offset * 1e-9)
Sourcepub fn offset(&self) -> HalResult<i32>
pub fn offset(&self) -> HalResult<i32>
Get the factory scaling offset constant: voltage = ((lsb_weight * 1e-9) * raw) - (offset * 1e-9)
Sourcepub fn is_accumulator_channel(&self) -> HalResult<bool>
pub fn is_accumulator_channel(&self) -> HalResult<bool>
Returns true if this analog input is attached to an accumulator
Sourcepub fn init_accumulator(&mut self) -> HalResult<()>
pub fn init_accumulator(&mut self) -> HalResult<()>
Initialize an accumulator on this channel.
Sourcepub fn set_accumulator_offset(&mut self, value: i64)
pub fn set_accumulator_offset(&mut self, value: i64)
Set the offset for the accumulator.
Sourcepub fn reset_accumulator(&mut self) -> HalResult<()>
pub fn reset_accumulator(&mut self) -> HalResult<()>
Reset the accumulator and wait for the next sample. This blocks until new values are potentially available.
Sourcepub fn set_accumulator_center(&mut self, center: i32) -> HalResult<()>
pub fn set_accumulator_center(&mut self, center: i32) -> HalResult<()>
Set the center of the accumulator. This value will be subtracted from all accumulated reads.
Sourcepub fn set_accumulator_deadband(&self, deadband: i32) -> HalResult<()>
pub fn set_accumulator_deadband(&self, deadband: i32) -> HalResult<()>
Set the deadband for the accumulator. Anything within deadband
of the accumulator center
will be ignored in the accumulator.
Sourcepub fn accumulator_value(&self) -> HalResult<i64>
pub fn accumulator_value(&self) -> HalResult<i64>
Get a value from the accumulator.
Sourcepub fn accumulator_count(&self) -> HalResult<i64>
pub fn accumulator_count(&self) -> HalResult<i64>
Get the number of accumulated values.
Sourcepub fn accumulator_output(&self) -> HalResult<(i64, i64)>
pub fn accumulator_output(&self) -> HalResult<(i64, i64)>
Read the accumulator’s value and the count of samples at the same time.
Returns a tuple of (value, count)
.
Sourcepub fn set_sample_rate(samples_per_second: f64) -> HalResult<()>
pub fn set_sample_rate(samples_per_second: f64) -> HalResult<()>
Set the sample rate for analog inputs.
Sourcepub fn sample_rate() -> HalResult<f64>
pub fn sample_rate() -> HalResult<f64>
Get the sample rate for analog inputs.