JY901.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef JY901_h
  2. #define JY901_h
  3. #include "string.h"
  4. #include <iostream>
  5. #include <math.h>
  6. #define SAVE 0x00
  7. #define CALSW 0x01
  8. #define RSW 0x02
  9. #define RRATE 0x03
  10. #define BAUD 0x04
  11. #define AXOFFSET 0x05
  12. #define AYOFFSET 0x06
  13. #define AZOFFSET 0x07
  14. #define GXOFFSET 0x08
  15. #define GYOFFSET 0x09
  16. #define GZOFFSET 0x0a
  17. #define HXOFFSET 0x0b
  18. #define HYOFFSET 0x0c
  19. #define HZOFFSET 0x0d
  20. #define D0MODE 0x0e
  21. #define D1MODE 0x0f
  22. #define D2MODE 0x10
  23. #define D3MODE 0x11
  24. #define D0PWMH 0x12
  25. #define D1PWMH 0x13
  26. #define D2PWMH 0x14
  27. #define D3PWMH 0x15
  28. #define D0PWMT 0x16
  29. #define D1PWMT 0x17
  30. #define D2PWMT 0x18
  31. #define D3PWMT 0x19
  32. #define IICADDR 0x1a
  33. #define LEDOFF 0x1b
  34. #define GPSBAUD 0x1c
  35. #define YYMM 0x30
  36. #define DDHH 0x31
  37. #define MMSS 0x32
  38. #define MS 0x33
  39. #define AX 0x34
  40. #define AY 0x35
  41. #define AZ 0x36
  42. #define GX 0x37
  43. #define GY 0x38
  44. #define GZ 0x39
  45. #define HX 0x3a
  46. #define HY 0x3b
  47. #define HZ 0x3c
  48. #define Roll 0x3d
  49. #define Pitch 0x3e
  50. #define Yaw 0x3f
  51. #define TEMP 0x40
  52. #define D0Status 0x41
  53. #define D1Status 0x42
  54. #define D2Status 0x43
  55. #define D3Status 0x44
  56. #define PressureL 0x45
  57. #define PressureH 0x46
  58. #define HeightL 0x47
  59. #define HeightH 0x48
  60. #define LonL 0x49
  61. #define LonH 0x4a
  62. #define LatL 0x4b
  63. #define LatH 0x4c
  64. #define GPSHeight 0x4d
  65. #define GPSYAW 0x4e
  66. #define GPSVL 0x4f
  67. #define GPSVH 0x50
  68. #define DIO_MODE_AIN 0
  69. #define DIO_MODE_DIN 1
  70. #define DIO_MODE_DOH 2
  71. #define DIO_MODE_DOL 3
  72. #define DIO_MODE_DOPWM 4
  73. #define DIO_MODE_GPS 5
  74. struct STime
  75. {
  76. unsigned char ucYear;
  77. unsigned char ucMonth;
  78. unsigned char ucDay;
  79. unsigned char ucHour;
  80. unsigned char ucMinute;
  81. unsigned char ucSecond;
  82. unsigned short usMiliSecond;
  83. };
  84. struct SAcc
  85. {
  86. short a[3];
  87. short T;
  88. };
  89. struct SGyro
  90. {
  91. short w[3];
  92. short T;
  93. };
  94. struct SAngle
  95. {
  96. short Angle[3];
  97. short T;
  98. };
  99. struct SMag
  100. {
  101. short h[3];
  102. short T;
  103. };
  104. struct SDStatus
  105. {
  106. short sDStatus[4];
  107. };
  108. struct SPress
  109. {
  110. long lPressure;
  111. long lAltitude;
  112. };
  113. struct SLonLat
  114. {
  115. long lLon;
  116. long lLat;
  117. };
  118. struct SGPSV
  119. {
  120. short sGPSHeight;
  121. short sGPSYaw;
  122. long lGPSVelocity;
  123. };
  124. class CJY901
  125. {
  126. public:
  127. struct STime stcTime;
  128. struct SAcc stcAcc, lastAcc;
  129. struct SGyro stcGyro, lastGyro;
  130. struct SAngle stcAngle, lastAngle;
  131. struct SMag stcMag;
  132. struct SDStatus stcDStatus;
  133. struct SPress stcPress;
  134. struct SLonLat stcLonLat;
  135. struct SGPSV stcGPSV;
  136. CJY901 ();
  137. bool CopeSerialData(char ucData[], int& start, int& end,unsigned short usLength);
  138. private:
  139. bool checkData();
  140. private:
  141. double accInitLimit, gyroInitLimit, angleInitLimit;
  142. double accDiffLimit, gyroDiffLimit, angleDiffLimit;
  143. };
  144. #endif