Struct manchester_code::InfraredEmitter
source · [−]pub struct InfraredEmitter<P, C, I> { /* private fields */ }Expand description
Control sending of datagrams, manage infrared radiation pollution
The InfraredEmitter behaves socially by enforcing a pause time between subsequent Required resources:
- A configured PWM - typically at a frequency of 36..38 kHz (RC5 protocol)
- A facility that periodically runs half bit sending, e.g. a timer ISR typically at a period of 889 µs (half bit time, RC5 protocol)
Example
TODO
Implementations
sourceimpl<P, C, D, I> InfraredEmitter<P, C, I> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
I: Iterator<Item = bool>,
impl<P, C, D, I> InfraredEmitter<P, C, I> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
I: Iterator<Item = bool>,
sourcepub fn new(pause_cycles: u8, pwm: P, channel: C) -> Self
pub fn new(pause_cycles: u8, pwm: P, channel: C) -> Self
Create a new infrared Emitter
Arguments
pause_cycles- configures the time between subsequent datagram emissions. The total duration is half-bit-time (889 µs) times number of pause bit cycles. In the pause time no infrared radiation is emitted and other participants can occupy the radiation space.pwm- the PWM to be used for ir pulse emissionchannel- the channel to be used by the PWM
sourcepub fn send_half_bit(&mut self)
pub fn send_half_bit(&mut self)
Progress on sending a datagram by emitting a half bit
This function needs to be called every half-bit period, i.e. each 889 µs. The periodically required call is most likely delegated to a timer ISR.
half-bit emitting happens by enabling/disabling a a properly configured PWM.
sourceimpl<P, C, D> InfraredEmitter<P, C, DatagramBigEndianIterator> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
impl<P, C, D> InfraredEmitter<P, C, DatagramBigEndianIterator> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
sourcepub fn send_if_possible(&mut self, datagram: Datagram, sending_power: D) -> bool
pub fn send_if_possible(&mut self, datagram: Datagram, sending_power: D) -> bool
Immediately start sending a datagram if possible
Sending is possible iff there is no sending procedure in progress. A call to this function is not blocking
Arguments
datagram- The datagram to be sendsending_power- The duty cycle of the pwm in percent should be less than or equal 25 (percent) Is reduced to 25 if a higher value is given. Lower sending power is appropriate for pairing datagrams.
Returns
- true - if sending was initiated
- false - if sending was not possible to initiate
sourceimpl<P, C, D> InfraredEmitter<P, C, DatagramLittleEndianIterator> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
impl<P, C, D> InfraredEmitter<P, C, DatagramLittleEndianIterator> where
P: Pwm + Pwm<Channel = C> + Pwm<Duty = D>,
C: Copy,
D: Mul<Output = D> + Div<Output = D>,
sourcepub fn send_if_possible(&mut self, datagram: Datagram, sending_power: D) -> bool
pub fn send_if_possible(&mut self, datagram: Datagram, sending_power: D) -> bool
Immediately start sending a datagram if possible
Sending is possible iff there is no sending procedure in progress. A call to this function is not blocking
Arguments
datagram- The datagram to be sendsending_power- The duty cycle of the pwm in percent should be less than or equal 25 (percent) Is reduced to 25 if a higher value is given. Lower sending power is appropriate for pairing datagrams.
Returns
- true - if sending was initiated
- false - if sending was not possible to initiate
Trait Implementations
Auto Trait Implementations
impl<P, C, I> RefUnwindSafe for InfraredEmitter<P, C, I> where
C: RefUnwindSafe,
I: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, C, I> Send for InfraredEmitter<P, C, I> where
C: Send,
I: Send,
P: Send,
impl<P, C, I> Sync for InfraredEmitter<P, C, I> where
C: Sync,
I: Sync,
P: Sync,
impl<P, C, I> Unpin for InfraredEmitter<P, C, I> where
C: Unpin,
I: Unpin,
P: Unpin,
impl<P, C, I> UnwindSafe for InfraredEmitter<P, C, I> where
C: UnwindSafe,
I: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more