pub struct PulseWidthEncoder<H: Fn(u8) -> u8 + Send + Sync, F: Fn(&Device) -> 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 instensity. In the firmware, the intensity (0-255) is used as the index of the table to determine the pulse width (0-255). The period of the ultrasound is mapped to 256, and therefore, the ultrasound output is the ultrasound is maximum when the pulse width is 128 (50% in duty ratio).
The default table is set by the arcsin function so that EmitIntensity is linear; that is, table[i] = round(256*arcsin(i/255)/π).
§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| (i as f32 / 255. * 128.).round() as u8);Implementations§
Trait Implementations§
Source§impl<H: Clone + Fn(u8) -> u8 + Send + Sync, F: Clone + Fn(&Device) -> H> Clone for PulseWidthEncoder<H, F>
impl<H: Clone + Fn(u8) -> u8 + Send + Sync, F: Clone + Fn(&Device) -> H> Clone for PulseWidthEncoder<H, F>
Source§fn clone(&self) -> PulseWidthEncoder<H, F>
fn clone(&self) -> PulseWidthEncoder<H, F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<H: Fn(u8) -> u8 + Send + Sync, F: Fn(&Device) -> H> Datagram for PulseWidthEncoder<H, F>
impl<H: Fn(u8) -> u8 + Send + Sync, F: Fn(&Device) -> H> Datagram for PulseWidthEncoder<H, F>
Auto Trait Implementations§
impl<H, F> Freeze for PulseWidthEncoder<H, F>where
F: Freeze,
impl<H, F> RefUnwindSafe for PulseWidthEncoder<H, F>where
F: RefUnwindSafe,
impl<H, F> Send for PulseWidthEncoder<H, F>where
F: Send,
impl<H, F> Sync for PulseWidthEncoder<H, F>where
F: Sync,
impl<H, F> Unpin for PulseWidthEncoder<H, F>where
F: Unpin,
impl<H, F> UnwindSafe for PulseWidthEncoder<H, F>where
F: 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> IntoDatagramWithParallelThreshold<D> for Dwhere
D: Datagram,
impl<D> IntoDatagramWithParallelThreshold<D> for Dwhere
D: Datagram,
Source§fn with_parallel_threshold(
self,
threshold: Option<usize>,
) -> DatagramWithParallelThreshold<D>
fn with_parallel_threshold( self, threshold: Option<usize>, ) -> DatagramWithParallelThreshold<D>
Datagram to DatagramWithParallelThreshold.Source§impl<D> IntoDatagramWithTimeout<D> for Dwhere
D: Datagram,
impl<D> IntoDatagramWithTimeout<D> for Dwhere
D: Datagram,
Source§fn with_timeout(self, timeout: Option<Duration>) -> DatagramWithTimeout<D>
fn with_timeout(self, timeout: Option<Duration>) -> DatagramWithTimeout<D>
Datagram to DatagramWithTimeout.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.