pub struct AdiAnalog { /* private fields */ }
Expand description

A struct which represents a V5 ADI port configured as an ADI encoder.

Implementations

Initializes an ADI analog reader on one ADI ports.

Safety

This function is unsafe because it allows the user to create multiple mutable references to the same ADI analog reader. You likely want to implement Robot::new() instead.

Calibrates the analog sensor on the specified channel. This method assumes that the true sensor value is not actively changing at this time and computes an average from approximately 500 samples, 1 ms apart, for a 0.5 s period of calibration. The average value thus calculated is returned and stored for later calls to the ext_adi_analog_read_calibrated and ext_adi_analog_read_calibrated_HR functions. These functions will return the difference between this value and the current sensor value when called. Do not use this function when the sensor value might be unstable (gyro rotation, accelerometer movement). Returns: The average sensor value computed by this function.

Reads an analog input channel and returns the 12-bit value. The value returned is undefined if the analog pin has been switched to a different mode. The meaning of the returned value varies depending on the sensor attached. Returns: The analog sensor value, where a value of 0 reflects an input voltage of nearly 0 V and a value of 4095 reflects an input voltage of nearly 5 V

Reads the calibrated value of an analog input channel. The AdiAnalog::read_calibrated()(crate::adi::analog::AdiAnalog:: read_calibrated()) function must be run first on that channel. This function is inappropriate for sensor values intended for integration, as round-off error can accumulate causing drift over time. Use AdiAnalog::read_calibrated_hr()(crate::adi::analog::AdiAnalog:: read_calibrated_hr()) instead. Returns: The difference of the sensor value from its calibrated default from -4095 to 4095.

Reads the calibrated value of an analog input channel 1-8 with enhanced precision. The AdiAnalog::read_calibrated()(crate::adi::analog::AdiAnalog:: read_calibrated()) function must be run first. This is intended for integrated sensor values such as gyros and accelerometers to reduce drift due to round-off, and should not be used on a sensor such as a line tracker or potentiometer. The value returned actually has 16 bits of “precision”, even though the ADC only reads 12 bits, so that errors induced by the average value being between two values come out in the wash when integrated over time. Think of the value as the true value times 16. Returns: The difference of the sensor value from its calibrated default from -16384 to 16384.

Trait Implementations

Converts a AdiPort into a AdiAnalog.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.