BrickUp API Service for Docker version.

ITG3200.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*****************************************************************************/
  2. // Function: Header file for ITG3200
  3. // Hardware: Grove - 3-Axis Digital Gyro
  4. // Arduino IDE: Arduino-1.0
  5. // Author: Frankie.Chu
  6. // Date: Jan 11,2013
  7. // Version: v1.0
  8. // by www.seeedstudio.com
  9. //
  10. // This library is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU Lesser General Public
  12. // License as published by the Free Software Foundation; either
  13. // version 2.1 of the License, or (at your option) any later version.
  14. //
  15. // This library is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. // Lesser General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU Lesser General Public
  21. // License along with this library; if not, write to the Free Software
  22. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. //
  24. /*******************************************************************************/
  25. #ifndef __ITG3200_H__
  26. #define __ITG3200_H__
  27. #define GYRO_ADDRESS 0x68
  28. // ITG3200 Register Defines
  29. #define ITG3200_WHO 0x00
  30. #define ITG3200_SMPL 0x15
  31. #define ITG3200_DLPF 0x16
  32. #define ITG3200_INT_C 0x17
  33. #define ITG3200_INT_S 0x1A
  34. #define ITG3200_TMP_H 0x1B
  35. #define ITG3200_TMP_L 0x1C
  36. #define ITG3200_GX_H 0x1D
  37. #define ITG3200_GX_L 0x1E
  38. #define ITG3200_GY_H 0x1F
  39. #define ITG3200_GY_L 0x20
  40. #define ITG3200_GZ_H 0x21
  41. #define ITG3200_GZ_L 0x22
  42. #define ITG3200_PWR_M 0x3E
  43. class ITG3200
  44. {
  45. private:
  46. int8_t read(uint8_t _register);
  47. int16_t x_offset;
  48. int16_t y_offset;
  49. int16_t z_offset;
  50. public:
  51. void init();
  52. int16_t read(uint8_t addressh, uint8_t addressl);
  53. void write(uint8_t _register, uint8_t _data);
  54. double getTemperature();
  55. void getXYZ(int16_t *x,int16_t *y,int16_t *z);
  56. void getAngularVelocity(float *ax,float *ay,float *az);
  57. void zeroCalibrate(unsigned int samples, unsigned int sampleDelayMS);
  58. };
  59. #endif