power: implement AsMilliwatts for slices
This commit is contained in:
parent
7e90dd5a22
commit
a23b2e8e94
@ -19,6 +19,12 @@ impl AsMilliwatts for RGB8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> AsMilliwatts for [T] 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 {
|
pub fn brightness_for_mw(total_mw : u32, target : u8, max_power: u32) -> u8 {
|
||||||
let target32 = target as u32;
|
let target32 = target as u32;
|
||||||
let requested_mw = (total_mw * target32) / 256;
|
let requested_mw = (total_mw * target32) / 256;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user