Struct adc_interpolator::AdcInterpolator[][src]

pub struct AdcInterpolator<Pin, Word, const LENGTH: usize> { /* fields omitted */ }

Implementations

Returns an interpolator using the provided table.

The values in the table must be in ascending order by voltage or this function will panic. (ie. If you are using pair to create the pairs in the table, the voltage parameter must increase with each pair.)

Examples

Use pair to create the pairs in table:

use adc_interpolator::{AdcInterpolator, pair};

let interpolator = AdcInterpolator::new(
    pin,
    [
        pair::<u16>(1000, 12, 100, 40),
        pair(1000, 12, 200, 30),
        pair(1000, 12, 300, 10),
    ],
);

Destroys the interpolator and returns the Pin.

Returns a value based on the table, using linear interpolation between values in the table if necessary. If adc_value falls outside the range of the table, returns Ok(None).

Examples
use adc_interpolator::{AdcInterpolator, pair};

let mut interpolator = AdcInterpolator::new(
    pin,
    [
        pair(1000, 12, 100, 40),
        pair(1000, 12, 200, 30),
        pair(1000, 12, 300, 10),
    ],
);

// With voltage at 150 mV, the value is 35
assert_eq!(interpolator.read(&mut adc), Ok(Some(35)));

Returns the smallest value that can be returned by read.

Returns the largest value that can be returned by read.

Trait Implementations

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

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.