MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / get_battery_status

Method get_battery_status

framework_lib/src/touchscreen.rs:121–148  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

119 }
120
121 fn get_battery_status(&self) -> Option<u8> {
122 let mut msg = [0u8; 0x40];
123 msg[0] = 0x0D;
124 self.device.read(&mut msg).ok()?;
125 // println!(" Tip Switch {}%", msg[12]);
126 // println!(" Barrell Switch: {}%", msg[12]);
127 // println!(" Eraser: {}%", msg[12]);
128 // println!(" Invert: {}%", msg[12]);
129 // println!(" In Range: {}%", msg[12]);
130 // println!(" 2nd Barrel Switch:{}%", msg[12]);
131 // println!(" X {}%", msg[12]);
132 // println!(" Y {}%", msg[12]);
133 // println!(" Tip Pressure: {}%", msg[12]);
134 // println!(" X Tilt: {}%", msg[12]);
135 // println!(" Y Tilt: {}%", msg[12]);
136 debug!(" Battery Strength: {}%", msg[12]);
137 debug!(
138 " Barrel Pressure: {}",
139 u16::from_le_bytes([msg[13], msg[14]])
140 );
141 debug!(" Transducer Index: {}", msg[15]);
142
143 if msg[12] == 0 {
144 None
145 } else {
146 Some(msg[12])
147 }
148 }
149
150 fn get_stylus_fw(&self) -> Option<()> {
151 let mut msg = [0u8; 0x40];

Callers 1

get_battery_levelFunction · 0.45

Calls 1

readMethod · 0.80

Tested by

no test coverage detected