power: implement asmilliwatts for sized arrays

This commit is contained in:
Victoria Fischer 2024-11-16 16:25:32 +01:00
parent cc8377484e
commit c53a9e27ae

View File

@ -25,6 +25,13 @@ impl<T> AsMilliwatts for [T] where T: AsMilliwatts {
}
}
impl<T, const S: usize> AsMilliwatts for [T; S] where T: AsMilliwatts {
fn as_milliwatts(&self) -> u32 {
self.iter().map(|p| { p.as_milliwatts() }).sum()
}
}
pub fn brightness_for_mw(total_mw : u32, target : u8, max_power: u32) -> u8 {
let target32 = target as u32;
let requested_mw = (total_mw * target32) / 256;