40 : MagCalibrated(false), GyroFilter(6000), GyroAutoTemperature(0)
62 for (
int i = 0; i < 3; i++)
73 LogError(
"Magnetometer calibration not found!\n");
79 LogText(
"TemperatureReports:\n");
86 LogText(
"[%d][%d]: Version=%3d, Bin=%d/%d, "
87 "Sample=%d/%d, TargetTemp=%3.1lf, "
89 "Offset=(%7.2lf, %7.2lf, %7.2lf), "
111 OVR_ASSERT(temperatureReports[0].GetSize() > 0);
143 for (
int i = 0; i < 3; i++)
155 const float alpha = 0.4f;
157 const float absLimit = 1.25f * 0.349066f;
158 const float noiseLimit = 1.25f * 0.03f;
183 const double maxDeltaT = 2.5;
184 const double minExtraDeltaT = 0.5;
185 const UInt32 minDelay = 24 * 3600;
196 UPInt newestIdx = 0, oldestIdx = 0;
212 bool writeSuccess =
false;
214 if (now - newestReport.
Time > minDelay)
219 oldestReport.
Time = now;
246 for (
int i = 0; i < 3; i++)
254 for (
unsigned i = 0; i < temperatureReportsBin.
GetSize(); i++)
255 if (temperatureReportsBin[i].ActualTemperature != 0)
256 values.
PushBack(temperatureReportsBin[i].Offset[coord]);
259 double med =
Median(values);
261 for (
unsigned i = 0; i < temperatureReportsBin.
GetSize(); i++)
262 if (temperatureReportsBin[i].Offset[coord] == med)
263 return temperatureReportsBin[i];
267 return temperatureReportsBin[0];
272 int bins = (int) temperatureReports.GetSize();
278 for (
int bin = 0; bin < bins; bin++)
280 OVR_ASSERT(temperatureReports[bin].GetSize() == temperatureReports[0].GetSize());
292 const double autoRangeExtra = 1.0;
293 const double minInterpolationDist = 0.5;
296 const double adjustedDeltaT =
Abs(autoTemperature - targetTemperature) - autoRangeExtra;
318 for (l = 1; l < count - 2; l++)
329 else if (u < count - 1)
349 return autoValue + slope * (targetTemperature - autoTemperature);
void Apply(MessageBodyFrame &msg)
void LogText(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
void PushBack(const ValueType &val)
void DebugPrintLocalTemperatureTable()
OffsetInterpolator Interpolators[3]
virtual bool IsFull() const
virtual void GetFactoryCalibration(Vector3f *AccelOffset, Vector3f *GyroOffset, Matrix4f *AccelMatrix, Matrix4f *GyroMatrix, float *Temperature)=0
static bool MSleep(unsigned msecs)
const TemperatureReport & median(const Array< TemperatureReport > &temperatureReportsBin, int coord)
void Initialize(Array< Array< TemperatureReport > > const &temperatureReports, int coord)
Array< double > Temperatures
SensorCalibration(SensorDevice *pSensor)
void AutocalibrateGyro(MessageBodyFrame const &msg)
double GetOffset(double targetTemperature, double autoTemperature, double autoValue)
virtual UPInt GetCapacity(void) const
float GyroAutoTemperature
virtual bool GetGyroOffsetReport(GyroOffsetReport *)
const UByte MAX_COMPAT_VERSION
void void LogError(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
void DebugClearHeadsetTemperatureReports()
Vector3< double > Vector3d
virtual UPInt GetSize(void) const
virtual bool SetTemperatureReport(const TemperatureReport &)
Array::ValueType & Median(Array &arr)
Array< Array< TemperatureReport > > TemperatureReports
virtual Elem & PeekBack(int count=0)
virtual bool GetMagCalibrationReport(MagCalibrationReport *)
void PushBack(const T &e)
void Reserve(UPInt newCapacity)
Vector3< float > Vector3f
OVR_FORCE_INLINE const T Abs(const T v)
Vector3< T > Transform(const Vector3< T > &v) const
virtual bool GetAllTemperatureReports(Array< Array< TemperatureReport > > *)