Function adc_interpolator::pair[][src]

pub fn pair<Word>(
    max_voltage: u32,
    precision: u32,
    voltage: u32,
    value: u32
) -> (Word, u32) where
    Word: TryFrom<u32>,
    <Word as TryFrom<u32>>::Error: Debug
Expand description

Converts a voltage and corresponding value into a pair of (adc_value, value).

Use to create a table to be used by an AdcInterpolator.

Arguments

  • max_voltage: The voltage corresponding to the largest value possible for the ADC (mV)
  • precision: The precision of the ADC in bits (eg. for 10-bit precision, use 10)
  • voltage: The voltage to convert (mV)
  • value: The value to use in the pair

Examples

use adc_interpolator::pair;

pair::<u16>(
    3300, // 3.3 V max voltage
    10,   // 10 bits of precision
    420,  // 0.42 V
    80,   // value
);