Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __HTGYRO_H__
00013 #define __HTGYRO_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #pragma systemFile
00043
00044 #ifndef __COMMON_H__
00045 #include "common.h"
00046 #endif
00047
00048 int HTGYROreadRot(tSensors link);
00049 int HTGYROstartCal(tSensors link);
00050 int HTGYROreadCal(tSensors link);
00051 void HTGYROsetCal(tSensors link, int offset);
00052
00053 #ifdef __HTSMUX_SUPPORT__
00054 int HTGYROreadRot(tMUXSensor muxsensor);
00055 int HTGYROstartCal(tMUXSensor muxsensor);
00056 int HTGYROreadCal(tMUXSensor muxsensor);
00057 void HTGYROsetCal(tMUXSensor muxsensor, int offset);
00058 #endif // __HTSMUX_SUPPORT__
00059
00060 int HTGYRO_offsets[][] = {{620, 620, 620, 620},
00061 {620, 620, 620, 620},
00062 {620, 620, 620, 620},
00063 {620, 620, 620, 620}};
00064
00065
00066
00067
00068
00069
00070 int HTGYROreadRot(tSensors link) {
00071
00072 if (SensorType[link] != sensorAnalogInactive) {
00073 SetSensorType(link, sensorAnalogInactive);
00074 wait1Msec(100);
00075 }
00076
00077 return (SensorValue[link] - HTGYRO_offsets[link][0]);
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 #ifdef __HTSMUX_SUPPORT__
00087 int HTGYROreadRot(tMUXSensor muxsensor) {
00088 return HTSMUXreadAnalogue(muxsensor) - HTGYRO_offsets[SPORT(muxsensor)][MPORT(muxsensor)];
00089 }
00090 #endif // __HTSMUX_SUPPORT__
00091
00092
00093
00094
00095
00096
00097
00098 int HTGYROstartCal(tSensors link) {
00099 long _avgdata = 0;
00100
00101
00102 if (SensorType[link] != sensorAnalogInactive) {
00103 SetSensorType(link, sensorAnalogInactive);
00104 wait1Msec(100);
00105 }
00106
00107
00108 for (int i = 0; i < 50; i++) {
00109 _avgdata += SensorValue[link];
00110 wait1Msec(5);
00111 }
00112
00113
00114 HTGYRO_offsets[link][0] = (_avgdata / 50);
00115
00116
00117 return HTGYRO_offsets[link][0];
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 #ifdef __HTSMUX_SUPPORT__
00127 int HTGYROstartCal(tMUXSensor muxsensor) {
00128 int _avgdata = 0;
00129
00130
00131 for (int i = 0; i < 5; i++) {
00132 _avgdata += HTSMUXreadAnalogue(muxsensor);
00133 wait1Msec(50);
00134 }
00135
00136
00137 HTGYRO_offsets[SPORT(muxsensor)][MPORT(muxsensor)] = (_avgdata / 5);
00138
00139
00140 return HTGYRO_offsets[SPORT(muxsensor)][MPORT(muxsensor)];
00141 }
00142 #endif // __HTSMUX_SUPPORT__
00143
00144
00145
00146
00147
00148
00149
00150 void HTGYROsetCal(tSensors link, int offset) {
00151 HTGYRO_offsets[link][0] = offset;
00152 }
00153
00154
00155
00156
00157
00158
00159
00160 #ifdef __HTSMUX_SUPPORT__
00161 void HTGYROsetCal(tMUXSensor muxsensor, int offset) {
00162 HTGYRO_offsets[SPORT(muxsensor)][MPORT(muxsensor)] = offset;
00163 }
00164 #endif // __HTSMUX_SUPPORT__
00165
00166
00167
00168
00169
00170
00171
00172 int HTGYROreadCal(tSensors link) {
00173 return HTGYRO_offsets[link][0];
00174 }
00175
00176
00177
00178
00179
00180
00181
00182 #ifdef __HTSMUX_SUPPORT__
00183 int HTGYROreadCal(tMUXSensor muxsensor) {
00184 return HTGYRO_offsets[SPORT(muxsensor)][MPORT(muxsensor)];
00185 }
00186 #endif // __HTSMUX_SUPPORT__
00187
00188 #endif // __HTGYRO_H__
00189
00190
00191
00192
00193
00194