Skip to main content

Status

Struct Status 

Source
pub struct Status { /* private fields */ }
Expand description

The status register, read with command::READ_STATUS as one CRC-protected word.

It reports the heater, the alert state, whether a reset has happened, and how the last command and write were received. The flag bits (alert pending, the two tracking alerts, and reset detected) are cleared by command::CLEAR_STATUS.

Implementations§

Source§

impl Status

Source

pub const ALERT_PENDING: u16

Bit 15: at least one alert is pending.

Source

pub const HEATER_ON: u16

Bit 13: the heater is on.

Source

pub const HUMIDITY_TRACKING_ALERT: u16

Bit 11: a relative-humidity tracking alert.

Source

pub const TEMPERATURE_TRACKING_ALERT: u16

Bit 10: a temperature tracking alert.

Source

pub const RESET_DETECTED: u16

Bit 4: a hard reset, soft reset, or supply failure happened since the register was last cleared.

Source

pub const COMMAND_FAILED: u16

Bit 1: the last command was not processed, being invalid or failing the command checksum.

Source

pub const WRITE_CHECKSUM_FAILED: u16

Bit 0: the checksum of the last write transfer failed.

Source

pub const DEFAULT: u16

The register’s value after power-up (0x8010): alert pending and reset detected set, everything else clear. The datasheet leaves bits 9:5 unspecified; they are zero here.

Source

pub fn from_bits(bits: u16) -> Status

Wraps a raw status word.

§Arguments
  • bits - the 16-bit register value, for example the Self::DEFAULT word or a combination of the bit constants.
§Returns

The status holding those bits.

Source

pub fn parse(bytes: &[u8; 3]) -> Result<Status, SensorError>

Parses and CRC-checks the three bytes returned by command::READ_STATUS.

§Arguments
  • bytes - the register most-significant byte first, then its CRC.
§Returns

The decoded status.

§Errors

Returns SensorError::Crc if the CRC byte does not match the register bytes.

Source

pub fn to_bytes(&self) -> [u8; 3]

Returns the three bytes a part in this state answers a status read with.

The inverse of parse.

§Returns

The register most-significant byte first, then its CRC.

Source

pub fn bits(&self) -> u16

Returns the raw register value.

Source

pub fn alert_pending(&self) -> bool

Returns whether at least one alert is pending (bit 15).

Source

pub fn heater_on(&self) -> bool

Returns whether the heater is on (bit 13).

Source

pub fn humidity_tracking_alert(&self) -> bool

Returns whether a relative-humidity tracking alert is raised (bit 11).

Source

pub fn temperature_tracking_alert(&self) -> bool

Returns whether a temperature tracking alert is raised (bit 10).

Source

pub fn reset_detected(&self) -> bool

Returns whether a reset has happened since the register was last cleared (bit 4).

Source

pub fn command_failed(&self) -> bool

Returns whether the last command was rejected (bit 1).

Source

pub fn write_checksum_failed(&self) -> bool

Returns whether the last write transfer failed its checksum (bit 0).

Trait Implementations§

Source§

impl Clone for Status

Source§

fn clone(&self) -> Status

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Status

Source§

impl Debug for Status

Source§

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

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

impl Eq for Status

Source§

impl PartialEq for Status

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Status

Auto Trait Implementations§

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.