1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
use table::table; pub struct Voltage(pub u32); impl Voltage { pub fn is_critical(&self) -> bool { self.0 < 3550 } pub fn is_low(&self) -> bool { self.0 < 3650 } pub fn is_ok(&self) -> bool { self.0 >= 3650 } pub fn is_full(&self) -> bool { self.0 >= 4120 } } pub fn get_voltage() -> Voltage { Voltage((table().GetVoltage)()) }