#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Model {
Xy7025,
Custom {
current_scale: u16,
power_scale: u16,
opp_scale: u16,
},
}
impl Model {
pub const fn current_scale(self) -> f32 {
match self {
Self::Xy7025 => 100.0,
Self::Custom { current_scale, .. } => current_scale as f32,
}
}
pub const fn power_scale(self) -> f32 {
match self {
Self::Xy7025 => 10.0,
Self::Custom { power_scale, .. } => power_scale as f32,
}
}
pub const fn opp_scale(self) -> f32 {
match self {
Self::Xy7025 => 1.0,
Self::Custom { opp_scale, .. } => opp_scale as f32,
}
}
pub const fn expected_model_code(self) -> Option<u16> {
match self {
Self::Xy7025 => Some(0x6500),
Self::Custom { .. } => None,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ModelCheck {
Match { device_code: u16 },
Mismatch {
expected_code: u16,
device_code: u16,
},
Inconclusive { device_code: u16 },
}