| Crates.io | register_derive |
| lib.rs | register_derive |
| version | 0.1.1 |
| created_at | 2022-03-26 23:44:44.227712+00 |
| updated_at | 2022-03-27 00:12:56.792437+00 |
| description | Helper proc macro for the pac194x crate |
| homepage | |
| repository | https://github.com/kiranshila/pac194x |
| max_upload_size | |
| id | 557054 |
| size | 2,225 |
A platform-agnostic driver crate for the Microchip PAC194X single/multi channel power monitor using the embedded-hal traits.
This driver allows you to:
f32sTo use this driver, import this crate and an embedded_hal implementation,
then instantiate the appropriate device.
use linux_embedded_hal::I2cdev;
use pac194x::{PAC194X, AddrSelect};
const SENSE_RESISTOR: f32 = 0.5;
fn main() {
let i2c = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = PAC194X::new(i2c, AddrSelect::GND).unwrap();
loop {
let bus_voltage_1 = sensor.read_bus_voltage_n(1).unwrap();
let sense_voltage_1 = sensor.read_sense_voltage_n(1).unwrap();
println!("Channel 1 has a bus voltage of: {:.2} V", bus_voltage_1);
println!("Channel 1 is pulling a current of: {:.2} A", sense_voltage_1 / SENSE_RESISTOR);
}
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.