Skip to main content

Model

Enum Model 

Source
pub enum Model {
    Xy7025,
    Custom {
        current_scale: u16,
        power_scale: u16,
        opp_scale: u16,
    },
}
Expand description

Hardware variant. Selected at construction (Xy::new) and used to scale the registers whose resolution differs across the family — I-SET, IOUT, S-OCP, POWER, S-OPP. See DATASHEET.md §3 for the scale table.

Cross-check by reading MODEL (0x0016): 0x6500 is XY7025 (newer firmware revision observed in 2024+ batches; older vendor docs cite 0x6100 for the same protocol). The crate does not probe automatically — pick the variant that matches your hardware.

Variants§

§

Xy7025

§

Custom

Escape hatch for hardware not covered by the preset variants. Each scale is the integer denominator the firmware uses on the wire — e.g. current_scale = 100 means a raw register value of 1234 represents 12.34 A. The XY firmware uses integer denominators on every known variant; cross-check against the vendor docs for your unit.

Fields

§current_scale: u16
§power_scale: u16
§opp_scale: u16

Implementations§

Source§

impl Model

Source

pub const fn current_scale(self) -> f32

Scale for I-SET, IOUT, S-OCP. 100 on XY7025 (10 mA).

Source

pub const fn power_scale(self) -> f32

Scale for POWER (0x0004). 10 on XY7025 (100 mW).

Source

pub const fn opp_scale(self) -> f32

Scale for S-OPP in memory groups (0x0055). 1 W on XY7025.

Source

pub const fn expected_model_code(self) -> Option<u16>

Expected value of the device’s MODEL register (0x0016) for this variant, if known. Used by crate::Xy::verify_model to catch wrong-scale-family misconfiguration.

XY7025 returns 0x6500. Custom returns None (no canonical code).

Trait Implementations§

Source§

impl Clone for Model

Source§

fn clone(&self) -> Model

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Model

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Format for Model

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl Hash for Model

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Model

Source§

fn eq(&self, other: &Model) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Model

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Model

Source§

impl Eq for Model

Source§

impl StructuralPartialEq for Model

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,