Solved Invalid Calibration Level of Magnetometer on Android
-
Hi,
I want to read the calibrationLevel() of the Magnetometer to show the user the current accuracy. According to Qt docu this value should be always between 0..1, the higher the more precise and provided the geomagnetic flux density is selected.calibrationLevel : const qreal This property holds the accuracy of the reading. Measured as a value from 0 to 1 with higher values being better. Note that this only changes when measuring geomagnetic flux density. Raw magnetic flux readings will always have a value of 1.
My code:
SMag::SMag(QObject *parent) : QObject(parent) { m_pQMag = new QMagnetometer(this); m_pQMag->addFilter(this); m_pQMag->setReturnGeoValues(true); m_stMag = m_pQMag->start(); connect(m_pQMag,SIGNAL(sensorError(int)),this,SLOT(err(int))); } bool SMag::filter(QMagnetometerReading* reading) { qDebug() << reading->calibrationLevel(); // 2 - 3 }
The result of calibrationLevel() varies between 2 and 3 and thus out of range. So this means I do not get a valid accuracy value and can not really trust the correction between the raw and geomagnetic flux. Additionally on http://doc.qt.io/qt-5/qmagnetometerreading.html#calibrationLevel-prop the link
See also CS001671 - Calibrating the magnetometer sensor.
does not work. I did my tests with a LG G2 and Honor 6, Android 5 and 6.
Does maybe someone has an idea?
Thxs in andvance...
-
For who is interested, find the answer under https://bugreports.qt.io/browse/QTBUG-57184