We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e30627 commit 3f89c53Copy full SHA for 3f89c53
framework_lib/src/power.rs
@@ -191,10 +191,13 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
191
let _events_ver = ec.read_memory(EC_MEMMAP_EVENTS_VERSION, 2).unwrap();
192
}
193
194
-pub fn print_sensors(ec: &CrosEc) {
195
- let als = ec.read_memory(EC_MEMMAP_ALS, 0x04).unwrap();
+pub fn get_als_reading(ec: &CrosEc) -> Option<u32> {
+ let als = ec.read_memory(EC_MEMMAP_ALS, 0x04)?;
196
+ Some(u32::from_le_bytes([als[0], als[1], als[2], als[3]]))
197
+}
198
- let als_int = u32::from_le_bytes([als[0], als[1], als[2], als[3]]);
199
+pub fn print_sensors(ec: &CrosEc) {
200
+ let als_int = get_als_reading(ec).unwrap();
201
println!("ALS: {:>4} Lux", als_int);
202
203
0 commit comments