From a2ca2c1497e45ff324b2f48999870e15a544b578 Mon Sep 17 00:00:00 2001 From: Kiveisha Yevgeniy Date: Tue, 10 Jun 2014 07:24:56 +0000 Subject: [PATCH] doxygen: Added documentation to ultrasonic sensor Signed-off-by: Kiveisha Yevgeniy --- examples/hcsr04.cxx | 2 ++ src/hcsr04/hcsr04.h | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/examples/hcsr04.cxx b/examples/hcsr04.cxx index 4cf454c..63b3ab1 100644 --- a/examples/hcsr04.cxx +++ b/examples/hcsr04.cxx @@ -41,6 +41,7 @@ sig_handler(int signo) } } +//! [Interesting] void interrupt (void) { sonar->ackEdgeDetected (); @@ -59,3 +60,4 @@ main(int argc, char **argv) return 0; } +//! [Interesting] diff --git a/src/hcsr04/hcsr04.h b/src/hcsr04/hcsr04.h index f94776c..549ee02 100644 --- a/src/hcsr04/hcsr04.h +++ b/src/hcsr04/hcsr04.h @@ -37,15 +37,48 @@ namespace upm { +/** + * @brief C++ API for HCSR04 (ultrasonic ranging module) component + * + * This file defines the HCSR04 C++ interface for libhcsr04 + * + * @snippet hcsr04.cxx Interesting + * + */ class HCSR04 { public: + /** + * Instanciates a HCSR04 object + * + * @param triggerPin pin for triggering the sensor for distance + * @param echoPin pulse response to triggering + * @param fptr function pointer for handling raising and + * falling interrupts + */ HCSR04 (uint8_t triggerPin, uint8_t echoPin, void (*fptr)(void)); + + /** + * HCSR04 object destructor. + */ ~HCSR04 (); + + /** + * Get the distance from the sensor. + */ int getDistance (); + + /** + * On each interrupt this function will detect if the interrupt + * was falling edge or rising. + * Should be called from the interrupt handler. + */ void ackEdgeDetected (); - uint8_t m_doWork; + uint8_t m_doWork; /**< Flag to controll blocking function while waiting for falling edge interrupt */ + /** + * Return name of the component + */ std::string name() { return m_name; -- 2.7.4