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

An abstract base class for some sonar classes defined as part of this API. More...

#include <fastarduino/devices/sonar.h>

Inheritance diagram for devices::sonar::AbstractSonar< NTIMER_ >:

Public Types

using RTT = timer::RTT< NTIMER_ >
 The type of timer::RTT used by this sonar instance. More...
 

Public Member Functions

bool ready () const
 Indicate if an echo pulse measure is ready to read. More...
 
uint16_t latest_echo_us () const
 Get the latest measured echo pulse duration. More...
 

Detailed Description

template<board::Timer NTIMER_>
class devices::sonar::AbstractSonar< NTIMER_ >

An abstract base class for some sonar classes defined as part of this API.

You should not need to subclass AbstractSonar yourself in general.

Template Parameters
NTIMER_the AVR timer of the timer::RTT to use for this sonar
See also
board::Timer
timer::RTT
HCSR04

Definition at line 599 of file sonar.h.

Member Typedef Documentation

◆ RTT

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

The type of timer::RTT used by this sonar instance.

Definition at line 603 of file sonar.h.

Member Function Documentation

◆ ready()

template<board::Timer NTIMER_>
bool devices::sonar::AbstractSonar< NTIMER_ >::ready ( ) const
inline

Indicate if an echo pulse measure is ready to read.

This can be useful when using asynchronous modes, and checking from time to time if, after a trigger pulse, an echo pulse has already been received or not yet.

Return values
truean echo pulse duration is available
falsean echo pulse duration is not yet available
See also
latest_echo_us()

Definition at line 614 of file sonar.h.

◆ latest_echo_us()

template<board::Timer NTIMER_>
uint16_t devices::sonar::AbstractSonar< NTIMER_ >::latest_echo_us ( ) const
inline

Get the latest measured echo pulse duration.

If a trigger pulse was sent but no echo received yet, then the method immediataly returns 0. It also returns 0, as a convention, if a timeout occurred, i.e. no echo pulse was received in expected time.

Returns
the latest measured echo pulse duration in microseconds
See also
HCSR04::echo_us()
HCSR04::await_echo_us()

Definition at line 629 of file sonar.h.


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