src: rewrite display to have generic surface implementations

This commit is contained in:
2024-10-28 22:22:03 +01:00
parent ed034046e8
commit e475d66842
4 changed files with 146 additions and 78 deletions

View File

@ -1,16 +1,5 @@
use embedded_graphics::pixelcolor::RgbColor;
pub fn color_to_mw<T: RgbColor>(color : &T) -> u32 {
const RED_MW : u32 = 16 * 5; //< 16mA @ 5v = 80mW
const GREEN_MW : u32 = 11 * 5; //< 11mA @ 5v = 55mW
const BLUE_MW : u32 = 15 * 5; //< 15mA @ 5v = 75mW
const DARK_MW : u32 = 1 * 5; //< 1mA @ 5v = 5mW
let red = (color.r() as u32 * RED_MW).wrapping_shr(8);
let green = (color.g() as u32 * GREEN_MW).wrapping_shr(8);
let blue = (color.b() as u32 * BLUE_MW).wrapping_shr(8);
return red + green + blue + DARK_MW;
pub trait AsMilliwatts {
fn as_milliwatts(&self) -> u32;
}
pub fn brightness_for_mw(total_mw : u32, target : u8, max_power: u32) -> u8 {