i2c-tpa2016

Crates.ioi2c-tpa2016
lib.rsi2c-tpa2016
version0.1.0
sourcesrc
created_at2018-06-10 23:16:14.516497
updated_at2018-06-10 23:16:14.516497
descriptioni2c interface for a TPA2016 audio amplifier (https://www.adafruit.com/product/1712)
homepagehttps://github.com/querry43/rust-i2c-tpa2016
repositoryhttps://github.com/querry43/rust-i2c-tpa2016
max_upload_size
id69538
size9,636
Matt Harrington (querry43)

documentation

https://github.com/querry43/rust-i2c-tpa2016/blob/master/README.md

README

rust-i2c-tpa2016

Build status License crates.io Documentation

A rust crate for the communicating with the TPA2016 audio amplifier (https://www.adafruit.com/product/1712).

Synopsys

extern crate i2cdev;
extern crate i2c_tpa2016;

use i2cdev::linux::LinuxI2CDevice;

fn main() {
    let i2cdev = LinuxI2CDevice::new("/dev/i2c-1", 0x58).unwrap();
    let mut tpa2016 = i2c_tpa2016::I2CTPA2016::new(i2cdev).unwrap();

    tpa2016.set_gain(10).unwrap();
    println!("gain = {:?}", tpa2016.get_gain().unwrap());

    tpa2016.enable_channel(true, true).unwrap();

    tpa2016.set_agc_compression(0).unwrap();

    tpa2016.set_release_control(0).unwrap();
    tpa2016.set_attack_control(0).unwrap();
    tpa2016.set_hold_control(0).unwrap();

    tpa2016.set_limit_level_on().unwrap();
    tpa2016.set_limit_level(10).unwrap();

    tpa2016.set_limit_level_off().unwrap();

    tpa2016.set_agc_max_gain(12).unwrap();
}
Commit count: 1

cargo fmt