ZSharpIR.h 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. SharpIR
  3. Arduino library for retrieving distance (in cm) from the analog GP2Y0A21Y and GP2Y0A02YK
  4. From an original version of Dr. Marcal Casas-Cartagena (marcal.casas@gmail.com)
  5. Version : 1.0 : Guillaume Rico
  6. https://github.com/guillaume-rico/SharpIR
  7. */
  8. #ifndef SharpIR_h
  9. #define SharpIR_h
  10. #define NB_SAMPLE 10
  11. #include "Arduino.h"
  12. //#include <sensor_msgs/Range.h>
  13. class ZSharpIR
  14. {
  15. public:
  16. ZSharpIR (int irPin, const uint32_t _sensorType);
  17. int distance();
  18. static const uint32_t GP2Y0A41SK0F = 430 ;
  19. static const uint32_t GP2Y0A21YK0F = 1080 ;
  20. static const uint32_t GP2D12_24 = 1081 ;
  21. static const uint32_t GP2Y0A02YK0F = 20150 ;
  22. static const uint32_t GP2Y0A710K0F = 100500 ;
  23. void setARefVoltage(int refV);
  24. void SetAnalogReadResolution(int res);
  25. private:
  26. int _Adcres;
  27. int _refVoltage;
  28. void sort(int a[], int size);
  29. int _irPin;
  30. long _model;
  31. };
  32. #endif