Skip to content

Commit

Permalink
power: Add function to get ALS data
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <dhs@frame.work>
  • Loading branch information
JohnAZoidberg committed Oct 21, 2024
1 parent 2e30627 commit 3f89c53
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions framework_lib/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
let _events_ver = ec.read_memory(EC_MEMMAP_EVENTS_VERSION, 2).unwrap();
}

pub fn print_sensors(ec: &CrosEc) {
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)?;
Some(u32::from_le_bytes([als[0], als[1], als[2], als[3]]))
}

let als_int = u32::from_le_bytes([als[0], als[1], als[2], als[3]]);
pub fn print_sensors(ec: &CrosEc) {
let als_int = get_als_reading(ec).unwrap();
println!("ALS: {:>4} Lux", als_int);
}

Expand Down

0 comments on commit 3f89c53

Please sign in to comment.