Skip to content

Commit

Permalink
Merge pull request #62 from FrameworkComputer/als
Browse files Browse the repository at this point in the history
power: Add function to get ALS data
  • Loading branch information
JohnAZoidberg authored Oct 21, 2024
2 parents 8ff67b6 + 3f89c53 commit fee9f43
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 fee9f43

Please sign in to comment.