This template class supports up to 8 HC-SR04 sonars (or equivalent sensors), with their trigger pins gathered and connected to only one MCU pin, and all echo pins connected to the same MCU board::Port
.
More...
|
| MultiHCSR04 (RTT &rtt) |
| Construct a new a multi-sonar sensors handler. More...
|
|
void | trigger (uint16_t timeout_ms) |
| Start ranging on all sonars connected to this MultiHCSR04 . More...
|
|
bool | active () const |
| Tell if a ranging is under way on any sonar managed by this MultiHCSR04 instance. More...
|
|
uint8_t | ready () const |
| Tell, for which of the connected sonars, the latest ranging, started by trigger() , is finished, ie the echo pulse has been received. More...
|
|
bool | all_ready () const |
| Tell if the latest ranging, started by trigger() , is finished for all connected sonars, ie the echo pulse has been received. More...
|
|
void | set_ready () |
| Force readiness of all connected sensors, ie the end of current ranging. More...
|
|
This template class supports up to 8 HC-SR04 sonars (or equivalent sensors), with their trigger pins gathered and connected to only one MCU pin, and all echo pins connected to the same MCU board::Port
.
With this class, all connected sonars start ranging at the same time. This method works exclusively in asynchronous mode.
Note that, contrarily to the HCSR04
class, this class does not handle calculation or storeage of echo pulse duration for all connected sonars; instead, it produces SonarEvent
s upon each sonar event occurring:
- echo pulse leading edge received
- echo pulse trailing edge received
- timeout occurred while waiting for echo pulse reception You need to register proper callbacks in order to receive these events and process them. It is the responsibility your callbacks to calculate (and optionally store) echo pulse duration, based on all received
SonarEvent
s.
- Template Parameters
-
NTIMER_ | the AVR timer of the timer::RTT to use for this MultiHCSR04 |
TRIGGER_ | the board::DigitalPin connected to the sensors trigger pins; that can be any available pin. |
ECHO_PORT_ | the MCU port to which all echo pins of sonars handled by this class are connected; this port must support PCINT interrupts. |
ECHO_MASK_ | the mask determining which pins of ECHO_PORT_ are actually connected to a real sonar echo pin; for each bit set, the matching pin must be able to generate a PCINT interrupt when its level changes. |
- See also
- SonarEvent
-
REGISTER_MULTI_HCSR04_PCI_ISR_METHOD()
-
REGISTER_MULTI_HCSR04_RTT_TIMEOUT_METHOD()
-
REGISTER_MULTI_HCSR04_PCI_ISR_FUNCTION()
-
REGISTER_MULTI_HCSR04_RTT_TIMEOUT_FUNCTION()
Definition at line 1107 of file sonar.h.