FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
devices::sonar::SonarEvent< NTIMER_ > Struct Template Reference

This type holds information about events occurring within MultiHCSR04 handler. More...

#include <fastarduino/devices/sonar.h>

Public Types

using RTT = timer::RTT< NTIMER_ >
 The type of timer::RTT used by the MultiHCSR04 producing this SonarEvent. More...
 
using RAW_TIME = typename RTT::RAW_TIME
 The timer::RTTRawTime type used by the MultiHCSR04 producing this SonarEvent. More...
 

Public Member Functions

 SonarEvent ()
 Default constructor. More...
 
bool timeout () const
 Indicate if this event was produced by a timeout while waiting for echo pulses. More...
 
uint8_t started () const
 Indicate if this event was produced due to an echo pulse leading edge just received by the related MultiHCSR04. More...
 
uint8_t ready () const
 Indicate if this event was produced tdue to an echo pulse trailing edge just received by the related MultiHCSR04. More...
 
RAW_TIME time () const
 The timer::RTTRawTime at which this event occurred. More...
 

Friends

template<board::Timer , board::DigitalPin , board::Port , uint8_t >
class MultiHCSR04
 

Detailed Description

template<board::Timer NTIMER_>
struct devices::sonar::SonarEvent< NTIMER_ >

This type holds information about events occurring within MultiHCSR04 handler.

One event can contain information for up to 8 sonars.

You need to register callbacks to MultiHCSR04 in order to receive these events and process them. These events exist because MultiHCSR04 does not process them by itself i.e. it does not calculate or hold pulse information about all connected sonar sensors. It is the responsibility of callbacks to manage this information, based on all received SonarEvents.

Template Parameters
NTIMER_the AVR timer of the timer::RTT used by the MultiHCSR04 producing this SonarEvent
See also
MultiHCSR04
MultiHCSR04::EVENT

Definition at line 973 of file sonar.h.

Member Typedef Documentation

◆ RTT

template<board::Timer NTIMER_>
using devices::sonar::SonarEvent< NTIMER_ >::RTT = timer::RTT<NTIMER_>

The type of timer::RTT used by the MultiHCSR04 producing this SonarEvent.

See also
MultiHCSR04::RTT

Definition at line 985 of file sonar.h.

◆ RAW_TIME

template<board::Timer NTIMER_>
using devices::sonar::SonarEvent< NTIMER_ >::RAW_TIME = typename RTT::RAW_TIME

The timer::RTTRawTime type used by the MultiHCSR04 producing this SonarEvent.

See also
timer::RTTRawTime

Definition at line 992 of file sonar.h.

Constructor & Destructor Documentation

◆ SonarEvent()

template<board::Timer NTIMER_>
devices::sonar::SonarEvent< NTIMER_ >::SonarEvent ( )
inline

Default constructor.

This is here to allow direct declaration in your code:

...
This type holds information about events occurring within MultiHCSR04 handler.
Definition: sonar.h:974

Definition at line 1002 of file sonar.h.

Member Function Documentation

◆ timeout()

template<board::Timer NTIMER_>
bool devices::sonar::SonarEvent< NTIMER_ >::timeout ( ) const
inline

Indicate if this event was produced by a timeout while waiting for echo pulses.

If so, no other field in this SonarEvent is relevant. Hence this is the first method you should call on a SonarEvent you need to handle.

Definition at line 1010 of file sonar.h.

◆ started()

template<board::Timer NTIMER_>
uint8_t devices::sonar::SonarEvent< NTIMER_ >::started ( ) const
inline

Indicate if this event was produced due to an echo pulse leading edge just received by the related MultiHCSR04.

Each bit maps to one sonar handled by the producing MultHCSR04; when 1, the echo pulse just started on the matching sonar. time() will then provide the exact time at which the pulse egde occurred.

See also
time()

Definition at line 1025 of file sonar.h.

◆ ready()

template<board::Timer NTIMER_>
uint8_t devices::sonar::SonarEvent< NTIMER_ >::ready ( ) const
inline

Indicate if this event was produced tdue to an echo pulse trailing edge just received by the related MultiHCSR04.

Each bit maps to one sonar handled by the producing MultHCSR04; when 1, the echo pulse just ended on the matching sonar. time() will then provide the exact time at which the pulse egde occurred. For a given bit (sonar), the difference of time() between started() and ready() will determine the echo pulse duration.

See also
started()
time()

Definition at line 1043 of file sonar.h.

◆ time()

template<board::Timer NTIMER_>
RAW_TIME devices::sonar::SonarEvent< NTIMER_ >::time ( ) const
inline

The timer::RTTRawTime at which this event occurred.

This is not relevant when timeout() is true.

See also
started()
ready()

Definition at line 1055 of file sonar.h.

Friends And Related Function Documentation

◆ MultiHCSR04

template<board::Timer NTIMER_>
template<board::Timer , board::DigitalPin , board::Port , uint8_t >
friend class MultiHCSR04
friend

Definition at line 1071 of file sonar.h.


The documentation for this struct was generated from the following file: