adc-interpolator

Crates.ioadc-interpolator
lib.rsadc-interpolator
version0.2.0
sourcesrc
created_at2021-11-14 13:30:04.445589
updated_at2021-11-18 20:20:15.984865
descriptionAn interpolator for analog-to-digital converters
homepage
repositoryhttps://github.com/peterstuart/adc-interpolator/
max_upload_size
id481720
size14,877
Peter Stuart (peterstuart)

documentation

README

adc-interpolator

An interpolator for analog-to-digital converters.

Convert voltage readings from an ADC into meaningful values using linear interpolation.

Examples

use adc_interpolator::{AdcInterpolator, Config};

let config = Config {
    max_voltage: 1000, // 1000 mV maximum voltage
    precision: 12,     // 12-bit precision
    voltage_to_values: [
        (100, 40), // 100 mV -> 40
        (200, 30), // 200 mV -> 30
        (300, 10), // 300 mV -> 10
    ],
};

let mut interpolator = AdcInterpolator::new(pin, config);

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

License: MIT

Commit count: 15

cargo fmt