diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-07-12 17:51:32 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-08-07 20:45:29 +0100 |
commit | e53270854b7fd6e4ca9d22fa447ca54ae803baac (patch) | |
tree | 77328abdc5193bbc9b1399c119495218d31f42d5 /daemon | |
parent | eabcface011478b24192736fa8e2ea7b0861c5db (diff) |
Add some compensation to the barometer
Here's the justification from the asteroid-toolwatch commit logs:
> The app includes a means of 'calibrating' the barometer reading. This is not a system level calibration and only affects the app (or any other apps that choose to use the value I'm setting in dconf). The mechanism was initially inspired by the same feature on Casio's watches: under WearOS, all of Casio's apps use a shared calibration offset for barometer.
> The calibration aims to rectify the infamous inaccuracy of the android barometer sensor. While the sensors are generally very precise and can sense small changes in air pressure, the sensors often lose calibraton and hence suffer from zero error. This can be somewhat helped by allowing the user to set a zero point - it seems this allowed Casio to make the sensor into an actually useful feature.
> There was discussion about making this calibration into a system-level feature (for example, as a patch to sensorfw or to QtSensors) but I think it's reasonable to expect the sensor to always return the raw value (even if it is wrong) and then have the calibration as a separate, opt-in feature.
The daemon uses the same dconf value as in toolwatch.
Diffstat (limited to '')
-rw-r--r-- | daemon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | daemon/sensorPlugins/barometerSensor.cpp | 4 | ||||
-rw-r--r-- | daemon/sensorPlugins/barometerSensor.h | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 9093b33..a11b7cb 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -13,7 +13,7 @@ add_executable(sensorlogd ) set_target_properties(sensorlogd PROPERTIES AUTOMOC ON) #add_compile_definitions(Q_DECLARE_PRIVATE_SUPPORTS_UNIQUE_PTR=${Q_DECLARE_PRIVATE_SUPPORTS_UNIQUE_PTR}) -target_link_libraries(sensorlogd PRIVATE Qt5::Core Qt5::DBus Qt5::Qml Qt5::Sensors) +target_link_libraries(sensorlogd PRIVATE Qt5::Core Qt5::DBus Qt5::Qml Qt5::Sensors Mlite5::Mlite5) install(TARGETS sensorlogd DESTINATION bin) install(FILES systemd/asteroid-sensorlogd.service DESTINATION /usr/lib/systemd/user) diff --git a/daemon/sensorPlugins/barometerSensor.cpp b/daemon/sensorPlugins/barometerSensor.cpp index 137ccd3..46f7e11 100644 --- a/daemon/sensorPlugins/barometerSensor.cpp +++ b/daemon/sensorPlugins/barometerSensor.cpp @@ -14,6 +14,7 @@ #include <QtSensors/QPressureSensor> #include <QDebug> #include <QString> +#include <MGConfItem> #include "../logger.h" #include "../../common.h" @@ -28,8 +29,10 @@ BarometerSensorPlugin::BarometerSensorPlugin(QObject *parent, int initInterval) connect(barometerSensor,SIGNAL(readingChanged()),this,SLOT(finishRecording())); setupFilePath(sensorPathPrefix); + setupFilePath(sensorPathPrefixCompensated); qDebug() << "barometer sensor is enabled. interval is (ms) " << interval; + m_barometerOffsetGconf = new MGConfItem("/org/asteroidos/sensors/barometer-offset"); recordIntervalTimer = new QTimer(this); connect(recordIntervalTimer,SIGNAL(timeout()),this,SLOT(triggerRecording())); recordIntervalTimer->setSingleShot(true); @@ -63,5 +66,6 @@ void BarometerSensorPlugin::finishRecording() { return; } fileAddRecord(sensorPathPrefix,QString::number(pressure)); + fileAddRecord(sensorPathPrefixCompensated,QString::number(pressure - m_barometerOffsetGconf->value(0).toInt())); barometerSensor->stop(); } diff --git a/daemon/sensorPlugins/barometerSensor.h b/daemon/sensorPlugins/barometerSensor.h index 0ec9fb2..0420aa8 100644 --- a/daemon/sensorPlugins/barometerSensor.h +++ b/daemon/sensorPlugins/barometerSensor.h @@ -16,6 +16,7 @@ #include <QDBusInterface> #include <QTimer> #include <QSettings> +#include <MGConfItem> #include <QtSensors/QPressureSensor> @@ -39,8 +40,10 @@ private: QTimer *recordIntervalTimer; QPressureSensor *barometerSensor; QSettings *m_settings; + MGConfItem *m_barometerOffsetGconf; const QString sensorPathPrefix = "barometer-raw"; + const QString sensorPathPrefixCompensated = "barometer-compensated"; }; #endif // BAROMETERSENSOR_H |