Sharp GP2 familly distance sensor library

Dependents:   FRC_2018 0hackton_08_06_18 0hackton_08_06_18_publish Kenya_2019 ... more

Revision:
4:4f443a6a6843
Parent:
3:dcd04d9d0eb7
Child:
5:49fb7016797c
diff -r dcd04d9d0eb7 -r 4f443a6a6843 GP2A.h
--- a/GP2A.h	Tue May 22 17:15:37 2018 +0000
+++ b/GP2A.h	Thu May 31 17:25:25 2018 +0000
@@ -33,8 +33,8 @@
  *                      axis.
  *  The slope parameter must be computed by user unless the GP2 reference is
  *  listed in the list below :
- *      - GP2Y0A02YK0F (Min = 30cm, Max = 150cm, Slope = 60)
- *      - GP2Y0A21YK0F (Min =  7cm, Max =  80cm, Slope = 20.88)
+ *      - GP2Y0A02YK0F (Min = 30cm, Max = 150cm, Slope = 55)
+ *      - GP2Y0A21YK0F (Min =  7cm, Max =  80cm, Slope = 10)
  *
  *  You may add others sensors if you wish it
  *
@@ -50,8 +50,8 @@
  * Slope definitions for common GP2A sensors
  */
  
-#define GP2Y0A02YK0F    60.0
-#define GP2Y0A21YK0F    20.888
+#define GP2Y0A02YK0F    55.0
+#define GP2Y0A21YK0F    10
 
 /**
  * Includes : Mbed library
@@ -69,10 +69,11 @@
     /**
      * Constructor of a Sharp GP2 Familly object.
      *
-     * @param vmes : the Mbed pin used to connect with GP2A sensor
-     * @param dMin : the GP2A sensor min distance to mesure
-     * @param dMax : the GP2A sensor max distance to mesure
-     * @param slope : the slope of the linear part of the graph V = f(1/d)
+     * @param vmes (PinName) : the Mbed pin used to connect with GP2A sensor
+     * @param dMin (double) : the GP2A sensor min distance to mesure
+     * @param dMax (double) : the GP2A sensor max distance to mesure
+     * @param slope (double) : the slope of the linear part of the graph V = f(1/d)
+     * @note you better use slope value that I've put above
      */
     GP2A(PinName vmes, float dMin, float dMax, float slope);
 
@@ -80,6 +81,8 @@
      * Return the distance to target mesured by sensor in cm
      *
      * @return Distance in cm
+     * @note Distance is (very) approximative, to have a better mesurment I recommand an averaging of at least 5 measures
+     * @note you may get a new mesurment every 50ms 
      */
     double getDistance (void);