pub struct PulseWidthEncoder<F, H> { /* private fields */ }Expand description
Datagram to configure pulse width encoder table.
The pulse width encoder table is a table to determine the pulse width (or duty ratio) from the intensity. In the firmware, the intensity (0-255) is used as the index of the table to determine the pulse width. The period of the ultrasound is mapped to 512, therefore, the ultrasound output becomes maximum when the pulse width is 256 (50% in duty ratio).
The default table is set by the arcsin function so that Intensity is linearly proportional to output ultrasound pressure; that is, table[i] = round(T*arcsin(i/255)/π) where T is the period of the ultrasound.
§Example
To set the pulse width encoder table, please specify a function that takes the index of the table as an argument and returns the pulse width for each device.
The following example sets the pulse width to be linearly proportional to the intensity for all devices.
PulseWidthEncoder::new(|_dev| |i| PulseWidth::from_duty(i.0 as f32 / 510.));Implementations§
Source§impl<'a, H: Fn(Intensity) -> PulseWidth, F: Fn(&'a Device) -> H> PulseWidthEncoder<F, H>
impl<'a, H: Fn(Intensity) -> PulseWidth, F: Fn(&'a Device) -> H> PulseWidthEncoder<F, H>
Sourcepub const fn new(f: F) -> Self
pub const fn new(f: F) -> Self
Creates a new PulseWidthEncoder.
Trait Implementations§
Source§impl<F: Clone, H: Clone> Clone for PulseWidthEncoder<F, H>
impl<F: Clone, H: Clone> Clone for PulseWidthEncoder<F, H>
Source§fn clone(&self) -> PulseWidthEncoder<F, H>
fn clone(&self) -> PulseWidthEncoder<F, H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, H: Fn(Intensity) -> PulseWidth, F: Fn(&'a Device) -> H> Datagram<'_> for PulseWidthEncoder<F, H>
impl<'a, H: Fn(Intensity) -> PulseWidth, F: Fn(&'a Device) -> H> Datagram<'_> for PulseWidthEncoder<F, H>
Source§fn option(&self) -> DatagramOption
fn option(&self) -> DatagramOption
Auto Trait Implementations§
impl<F, H> Freeze for PulseWidthEncoder<F, H>where
F: Freeze,
impl<F, H> RefUnwindSafe for PulseWidthEncoder<F, H>where
F: RefUnwindSafe,
H: RefUnwindSafe,
impl<F, H> Send for PulseWidthEncoder<F, H>
impl<F, H> Sync for PulseWidthEncoder<F, H>
impl<F, H> Unpin for PulseWidthEncoder<F, H>
impl<F, H> UnwindSafe for PulseWidthEncoder<F, H>where
F: UnwindSafe,
H: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.