Crates.io | i2c-tpa2016 |
lib.rs | i2c-tpa2016 |
version | 0.1.0 |
source | src |
created_at | 2018-06-10 23:16:14.516497 |
updated_at | 2018-06-10 23:16:14.516497 |
description | i2c interface for a TPA2016 audio amplifier (https://www.adafruit.com/product/1712) |
homepage | https://github.com/querry43/rust-i2c-tpa2016 |
repository | https://github.com/querry43/rust-i2c-tpa2016 |
max_upload_size | |
id | 69538 |
size | 9,636 |
A rust crate for the communicating with the TPA2016 audio amplifier (https://www.adafruit.com/product/1712).
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();
}