pub struct Sample {
pub raw: i16,
pub pga: Pga,
}Expand description
One conversion result with the gain it was taken at, so it converts to volts.
Fields§
§raw: i16The signed 16-bit conversion register value.
pga: PgaThe full-scale range the conversion ran at.
Implementations§
Source§impl Sample
impl Sample
Sourcepub fn nanovolts(&self) -> i64
pub fn nanovolts(&self) -> i64
Returns the measured voltage in nanovolts, exact in integer arithmetic.
Sourcepub fn clipped(&self) -> bool
pub fn clipped(&self) -> bool
Reports whether the conversion sits at either end code, 7FFFh or 8000h, where the output clips for a signal beyond the full-scale range (datasheet section 7.5.4 and Table 7-3).
A clipped sample means the input is at or past the range the gain selects, so its voltage is a bound rather than the reading; a wider range reads it.
§Returns
true at either end code.
§Examples
use pamoja_sensors::ads1115::{Pga, Sample};
let pinned = Sample { raw: i16::MAX, pga: Pga::Fsr2_048 };
assert!(pinned.clipped());
assert!(!Sample { raw: 18_800, pga: Pga::Fsr4_096 }.clipped());Trait Implementations§
impl Copy for Sample
impl Eq for Sample
impl StructuralPartialEq for Sample
Auto Trait Implementations§
impl Freeze for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnsafeUnpin for Sample
impl UnwindSafe for Sample
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more