pub struct Configuration {
pub range_number: u8,
pub conversion_time: ConversionTime,
pub mode: Mode,
pub overflow: bool,
pub conversion_ready: bool,
pub flag_high: bool,
pub flag_low: bool,
pub latch: Latch,
pub polarity: Polarity,
pub mask_exponent: bool,
pub fault_count: FaultCount,
}Expand description
A decoded OPT3001 configuration register.
Build one, set the fields, and turn it into the 16-bit register value with
bits; or parse a register read with
from_bits. Configuration::default is the power-on
state, CONFIGURATION_RESET. The four status fields are read-only on the part
and are ignored by bits.
§Examples
use pamoja_sensors::opt3001::{Configuration, Mode};
// Convert continuously with the range set automatically, everything else default.
let config = Configuration {
mode: Mode::Continuous,
..Configuration::default()
};
assert_eq!(config.bits(), 0xCC10);
assert_eq!(Configuration::from_bits(0xCC10), config);Fields§
§range_number: u8The range number (bits 15:12): 0 to 11 for a fixed full-scale range, or
RANGE_AUTOMATIC to let the part choose and report its choice in the
result’s exponent.
conversion_time: ConversionTimeThe conversion time.
mode: ModeThe mode of conversion operation.
overflow: boolRead-only: the last conversion overflowed its full-scale range.
conversion_ready: boolRead-only: a conversion has completed since the register was last read or written with a non-shutdown mode.
flag_high: boolRead-only: the result exceeded the high limit for the fault count.
flag_low: boolRead-only: the result fell below the low limit for the fault count.
latch: LatchThe interrupt reporting style.
polarity: PolarityThe INT pin polarity.
mask_exponent: boolForce the result’s exponent to zero on a fixed range, so the mantissa alone is the reading at that range’s LSB.
fault_count: FaultCountThe consecutive faults required to trigger a report.
Implementations§
Source§impl Configuration
impl Configuration
Sourcepub fn bits(self) -> u16
pub fn bits(self) -> u16
Assembles the 16-bit configuration register value.
The read-only status bits are written as zero, and the range number is truncated to its four bits.
§Returns
The register value to write, most significant byte first.
Sourcepub fn from_bits(bits: u16) -> Configuration
pub fn from_bits(bits: u16) -> Configuration
Sourcepub fn is_automatic_range(&self) -> bool
pub fn is_automatic_range(&self) -> bool
Returns whether the range number selects automatic full-scale setting.
Trait Implementations§
Source§impl Clone for Configuration
impl Clone for Configuration
Source§fn clone(&self) -> Configuration
fn clone(&self) -> Configuration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Configuration
Source§impl Debug for Configuration
impl Debug for Configuration
Source§impl Default for Configuration
impl Default for Configuration
impl Eq for Configuration
Source§impl PartialEq for Configuration
impl PartialEq for Configuration
Source§fn eq(&self, other: &Configuration) -> bool
fn eq(&self, other: &Configuration) -> bool
self and other values to be equal, and is used by ==.