@@ -110,20 +110,20 @@ fn main() {
110
110
111
111
#[ cfg( feature = "battery-readout" ) ]
112
112
{
113
- // use cramium_api::I2cApi;
114
- // let mut i2c = cram_hal_service::I2c::new();
115
- // use cramium_hal::axp2101::*;
116
- // let measurements = [("VBAT", REG_VBAT_H), ("VBUS", REG_VBUS_H), ("VSYS", REG_VSYS_H)];
117
- // let mut buf = [0u8, 0u8];
113
+ use cramium_api:: I2cApi ;
114
+ let mut i2c = cram_hal_service:: I2c :: new ( ) ;
115
+ use cramium_hal:: axp2101:: * ;
116
+ let measurements = [ ( "VBAT" , REG_VBAT_H ) , ( "VBUS" , REG_VBUS_H ) , ( "VSYS" , REG_VSYS_H ) ] ;
117
+ let mut buf = [ 0u8 , 0u8 ] ;
118
118
loop {
119
119
tt. sleep_ms ( 2_000 ) . ok ( ) ;
120
- // for (name, offset) in measurements {
121
- // i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap();
122
- // let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32;
123
- // log::info!("{}: {:0.3}V", name, v as f32 / 1000.0);
124
- // i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap();
125
- // log::info!("SOC: {}%", buf[0]);
126
- // }
120
+ for ( name, offset) in measurements {
121
+ i2c. i2c_read ( AXP2101_DEV , offset, & mut buf, false ) . unwrap ( ) ;
122
+ let v: u32 = ( ( ( buf[ 0 ] as u32 ) & 0x3F ) << 8 ) | buf[ 1 ] as u32 ;
123
+ log:: info!( "{}: {:0.3}V" , name, v as f32 / 1000.0 ) ;
124
+ i2c. i2c_read ( AXP2101_DEV , REG_SOC , & mut buf[ 0 ..1 ] , false ) . unwrap ( ) ;
125
+ log:: info!( "SOC: {}%" , buf[ 0 ] ) ;
126
+ }
127
127
}
128
128
}
129
129
#[ cfg( any( feature = "hosted-baosec" , not( feature = "battery-readout" ) ) ) ]
0 commit comments