Sharp GP2 familly distance sensor library
Dependents: FRC_2018 0hackton_08_06_18 0hackton_08_06_18_publish Kenya_2019 ... more
Diff: GP2A.h
- Revision:
- 5:49fb7016797c
- Parent:
- 4:4f443a6a6843
- Child:
- 6:36744d1b3127
--- a/GP2A.h Thu May 31 17:25:25 2018 +0000 +++ b/GP2A.h Sun Oct 13 13:35:59 2019 +0000 @@ -50,8 +50,10 @@ * Slope definitions for common GP2A sensors */ -#define GP2Y0A02YK0F 55.0 -#define GP2Y0A21YK0F 10 +#define GP2Y0A02YK0F_SLOPE 60.0 +#define GP2Y0A21YK0F_SLOPE 0.23625 +#define GP2Y0A02YK0F_ORIGIN 0.0 +#define GP2Y0A21YK0F_ORIGIN -0.297 /** * Includes : Mbed library @@ -73,9 +75,10 @@ * @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 + * @param origin (double) : the origin (Y for X=0) of the linear pat of the graph V = f(1/d) + * @note you better use slope and origin value that I've put above as sybolic constants */ - GP2A(PinName vmes, float dMin, float dMax, float slope); + GP2A(PinName vmes, float dMin, float dMax, float slope, float origin = 0); /** * Return the distance to target mesured by sensor in cm @@ -101,7 +104,7 @@ private : - float m_dMin, m_dMax, m_slope; + float m_dMin, m_dMax, m_slope, m_origin; protected :