pcf8591-hal

Crates.iopcf8591-hal
lib.rspcf8591-hal
version0.1.0
sourcesrc
created_at2021-01-07 18:02:45.848303
updated_at2021-01-07 18:02:45.848303
descriptionEmbedded-HAL driver for interfacing with the PCF8591 8-bit A/D and D/A converter
homepage
repositoryhttps://github.com/hamaluik/pcf8591
max_upload_size
id333884
size21,051
Kenton Hamaluik (hamaluik)

documentation

README

Rust Embedded-HAL PCF8591 Driver

For interfacing with the PCF8591 8-bit A/D and D/A converter. Currently only handles reading a single single-ended ADC at a time.

Example

With the PCF8591 connected to a raspberry pi:

use linux_embedded_hal::I2cdev;
use pcf8591::*;

pub fn main() {
    let i2c = I2cdev::new("/dev/i2c-1").expect("can open i2c device");
    let mut adc = PCF8591::new(i2c, PCF8591_DEFAULT_ADDRESS);

    loop {
        let a0 = adc.read(PCFADCNum::A0).expect("can read ADC0");
        println!("a0: {}", a0);
        std::thread::sleep(std::time::Duration::from_secs(1));
    }
}
Commit count: 3

cargo fmt