Library for using HC-SR04 with some API Documentation added

Fork of HC_SR04_Ultrasonic_Library by EJ Teb

Revision:
2:cc1143d36567
Parent:
1:114e0698a5d2
Child:
5:182e800b81f0
--- a/ultrasonic.h	Sun Nov 23 20:34:26 2014 +0000
+++ b/ultrasonic.h	Mon Nov 24 17:10:44 2014 +0000
@@ -6,18 +6,27 @@
 class ultrasonic
 {
     public:
-        
+        /**iniates the class with the specified trigger pin, echo pin, update speed and timeout**/
         ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout);
-        ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout, void onUpdate(int), void onTrig(void),void onStartTimer(void)/*, Timer *t*/ );
+        /**iniates the class with the specified trigger pin, echo pin, update speed, timeout and method to call when the distance changes**/
+        ultrasonic(PinName trigPin, PinName echoPin, float updateSpeed, float timeout, void onUpdate(int));
+        /** returns the last measured distance**/
         int getCurrentDistance(void);
+        /**pauses measuring the distance**/
         void pauseUpdates(void);
+        /**starts mesuring the distance**/
         void startUpdates(void);
+        /**attachs the method to be called when the distances changes**/
         void attachOnUpdate(void method(int));
-        void attachOnTrigger(void method(void));
-        void attachOnStartTimer(void method(void));
+        /**changes the speed at which updates are made**/
         void changeUpdateSpeed(float updateSpeed);
+        /**gets whether the distance has been changed since the last call of isUpdated() or checkDistance()**/
         int isUpdated(void);
-        float getUpdateSpeed();
+        /**gets the speed at which updates are made**/
+        float getUpdateSpeed(void);
+        /**call this as often as possible in your code, eg. at the end of a while(1) loop,
+        and it will check whether the method you have attached needs to be called**/
+        void checkDistance(void);
     private:
         DigitalOut _trig;
         InterruptIn _echo;
@@ -29,16 +38,10 @@
         int end;
         volatile int done;
         void (*_onUpdateMethod)(int);
-        void (*_onTriggerMethod)(void);
-        void (*_onStartTimerMethod)(void);
         void _startT(void);
         void _updateDist(void);
         void _startTrig(void);
         float _timeout;
-
         int d;
-        /*unsigned int tickcount;
-        Ticker _ticker;
-        void ticktock(void);*/
 };
 #endif
\ No newline at end of file