GPYX sensor library
Fork of Sharp by
Revision 2:e9ab384ccbab, committed 2016-02-17
- Comitter:
- j_j205
- Date:
- Wed Feb 17 16:48:05 2016 +0000
- Parent:
- 1:a5ced48cfedc
- Commit message:
- 2/17/16 JJ
Changed in this revision
diff -r a5ced48cfedc -r e9ab384ccbab Gp2x.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gp2x.cpp Wed Feb 17 16:48:05 2016 +0000 @@ -0,0 +1,15 @@ +#include "Gp2x.h" +#include "mbed.h" +#include "math.h" + +Gp2x::Gp2x( PinName voutPin ): +vout(voutPin) +{ +} + +double Gp2x::getIRDistance(void) +{ + float dist = vout.read(); + + return 37.115*dist*dist-73.021*dist+43.451; +} \ No newline at end of file
diff -r a5ced48cfedc -r e9ab384ccbab Gp2x.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gp2x.h Wed Feb 17 16:48:05 2016 +0000 @@ -0,0 +1,16 @@ +#ifndef GP2X_H +#define GP2X_H + +#include "mbed.h" + +class Gp2x +{ +public: + Gp2x( PinName voutPin ); + double getIRDistance(void); + + private: + AnalogIn vout; +}; + +#endif \ No newline at end of file
diff -r a5ced48cfedc -r e9ab384ccbab Sharp.cpp --- a/Sharp.cpp Fri Mar 28 15:31:40 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -#include "Sharp.h" -#include "mbed.h" -#include "math.h" - -Sharp::Sharp( PinName voutPin ): -vout(voutPin) -{ -} - -double Sharp::getIRDistance(void) -{ - float dist = vout.read(); - - return 37.115*dist*dist-73.021*dist+43.451; -} \ No newline at end of file
diff -r a5ced48cfedc -r e9ab384ccbab Sharp.h --- a/Sharp.h Fri Mar 28 15:31:40 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#ifndef __SHARP_H__ -#define __SHARP_H__ - -#include "mbed.h" - -class Sharp -{ -public: - Sharp( PinName voutPin ); - double getIRDistance(void); - - private: - AnalogIn vout; -}; - -#endif \ No newline at end of file