diff --git a/services/bao-console/src/main.rs b/services/bao-console/src/main.rs index 593480592..5445cfd72 100644 --- a/services/bao-console/src/main.rs +++ b/services/bao-console/src/main.rs @@ -70,9 +70,19 @@ fn main() { log::set_max_level(log::LevelFilter::Debug); modals::tests::spawn_test(); } - + use cramium_api::I2cApi; + let mut i2c = cram_hal_service::I2c::new(); + use cramium_hal::axp2101::*; + let measurements = [("VBAT", REG_VBAT_H), ("VBUS", REG_VBUS_H), ("VSYS", REG_VSYS_H)]; + let mut buf = [0u8, 0u8]; loop { - // just sleep as this is the parent thread - tt.sleep_ms(120_000).ok(); + tt.sleep_ms(2_000).ok(); + for (name, offset) in measurements { + i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap(); + let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32; + log::info!("{}: {:0.3}V", name, v as f32 / 1000.0); + i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap(); + log::info!("SOC: {}%", buf[0]); + } } }