Struct AnalogInput

Source
pub struct AnalogInput { /* private fields */ }
Expand description

An analog input on the RoboRIO

Implementations§

Source§

impl AnalogInput

Source

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.

Source

pub fn value(&self) -> HalResult<i32>

Read a value from the analog input.

Source

pub fn average_value(&self) -> HalResult<i32>

Read the average value of the analog input over some defined time period.

Source

pub fn voltage(&self) -> HalResult<f64>

Read the raw value of the analog input in volts.

Source

pub fn average_voltage(&self) -> HalResult<f64>

Read the average raw value of the analog input in volts over some defined time period.

Source

pub fn channel(&self) -> i32

Get the channel number for this analog input.

Source

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.

Source

pub fn average_bits(&self) -> HalResult<i32>

Get the previously-set number of average bits.

Source

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.

Source

pub fn oversample_bits(&self) -> HalResult<i32>

Get the previously-set number of oversample bits.

Source

pub fn lsb_weight(&self) -> HalResult<i32>

Get the factory scaling LSB weight constant: voltage = ((lsb_weight * 1e-9) * raw) - (offset * 1e-9)

Source

pub fn offset(&self) -> HalResult<i32>

Get the factory scaling offset constant: voltage = ((lsb_weight * 1e-9) * raw) - (offset * 1e-9)

Source

pub fn is_accumulator_channel(&self) -> HalResult<bool>

Returns true if this analog input is attached to an accumulator

Source

pub fn init_accumulator(&mut self) -> HalResult<()>

Initialize an accumulator on this channel.

Source

pub fn set_accumulator_offset(&mut self, value: i64)

Set the offset for the accumulator.

Source

pub fn reset_accumulator(&mut self) -> HalResult<()>

Reset the accumulator and wait for the next sample. This blocks until new values are potentially available.

Source

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.

Source

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.

Source

pub fn accumulator_value(&self) -> HalResult<i64>

Get a value from the accumulator.

Source

pub fn accumulator_count(&self) -> HalResult<i64>

Get the number of accumulated values.

Source

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).

Source

pub fn set_sample_rate(samples_per_second: f64) -> HalResult<()>

Set the sample rate for analog inputs.

Source

pub fn sample_rate() -> HalResult<f64>

Get the sample rate for analog inputs.

Trait Implementations§

Source§

impl Debug for AnalogInput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for AnalogInput

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.