diff --git a/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp b/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp index ac767460..054ea1e2 100644 --- a/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp +++ b/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp @@ -22,8 +22,6 @@ #include "datatypes/utils.h" #include "config.h" -#define GRAVITY_RECIPROCAL_THOUSANDS 101.971621298 - HybrisAccelerometerAdaptor::HybrisAccelerometerAdaptor(const QString& id) : HybrisAdaptor(id,SENSOR_TYPE_ACCELEROMETER) { @@ -77,9 +75,3 @@ void HybrisAccelerometerAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -//void HybrisAccelerometerAdaptor::init() -//{ -//// introduceAvailableDataRange(DataRange(-HybrisAdaptor::maxRange, HybrisAdaptor::maxRange , 1)); -//// introduceAvailableInterval(DataRange(10, 586, 0)); -//} diff --git a/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.h b/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.h index f965476a..23888e26 100644 --- a/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.h +++ b/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.h @@ -51,7 +51,6 @@ class HybrisAccelerometerAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - // void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp b/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp index 70aefa8b..d41cfaa9 100644 --- a/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp +++ b/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp @@ -136,7 +136,3 @@ void HybrisAlsAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisAlsAdaptor::init() -{ -} diff --git a/adaptors/hybrisalsadaptor/hybrisalsadaptor.h b/adaptors/hybrisalsadaptor/hybrisalsadaptor.h index 7fe2e8b8..d26aa4e3 100644 --- a/adaptors/hybrisalsadaptor/hybrisalsadaptor.h +++ b/adaptors/hybrisalsadaptor/hybrisalsadaptor.h @@ -56,7 +56,6 @@ class HybrisAlsAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.cpp b/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.cpp index c3f5bb3d..8f672d06 100644 --- a/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.cpp +++ b/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.cpp @@ -27,8 +27,6 @@ #include #include -#define RADIANS_TO_DEGREES 57.2957795 - /* * azimuth: angle between the magnetic north direction and the Y axis, around * the Z axis (0<=azimuth<360). @@ -112,7 +110,3 @@ void HybrisGeoRotationAdaptor::processSample(const sensors_event_t& data) m_buffer->commit(); m_buffer->wakeUpReaders(); } - -void HybrisGeoRotationAdaptor::init() -{ -} diff --git a/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.h b/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.h index d1aa932d..450cd8b2 100644 --- a/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.h +++ b/adaptors/hybrisgeorotationadaptor/hybrisgeorotationadaptor.h @@ -49,7 +49,6 @@ class HybrisGeoRotationAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* m_buffer; diff --git a/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp b/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp index 406125ba..f2d9f997 100644 --- a/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp +++ b/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp @@ -23,9 +23,6 @@ #include "config.h" #include -#define RADIANS_TO_DEGREESECONDS 57295.7795 -#define RADIANS_TO_DEGREES 57.2957795 - HybrisGyroscopeAdaptor::HybrisGyroscopeAdaptor(const QString& id) : HybrisAdaptor(id,SENSOR_TYPE_GYROSCOPE) { @@ -83,9 +80,3 @@ void HybrisGyroscopeAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - - -void HybrisGyroscopeAdaptor::init() -{ - -} diff --git a/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.h b/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.h index ea896e3d..77818a0c 100644 --- a/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.h +++ b/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.h @@ -51,7 +51,6 @@ class HybrisGyroscopeAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp b/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp index f29cd6e1..225663f5 100644 --- a/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp +++ b/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp @@ -94,7 +94,3 @@ void HybrisMagnetometerAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisMagnetometerAdaptor::init() -{ -} diff --git a/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.h b/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.h index e06da96d..a1b98b68 100644 --- a/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.h +++ b/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.h @@ -51,7 +51,6 @@ class HybrisMagnetometerAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp b/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp index bff77ea6..f79bcd4a 100644 --- a/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp +++ b/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp @@ -94,7 +94,3 @@ void HybrisOrientationAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisOrientationAdaptor::init() -{ -} diff --git a/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.h b/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.h index dbcce755..382c4fd3 100644 --- a/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.h +++ b/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.h @@ -49,7 +49,6 @@ class HybrisOrientationAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp b/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp index 8c19b7c7..7078d422 100644 --- a/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp +++ b/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp @@ -75,7 +75,3 @@ void HybrisPressureAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisPressureAdaptor::init() -{ -} diff --git a/adaptors/hybrispressureadaptor/hybrispressureadaptor.h b/adaptors/hybrispressureadaptor/hybrispressureadaptor.h index bd509905..86573386 100644 --- a/adaptors/hybrispressureadaptor/hybrispressureadaptor.h +++ b/adaptors/hybrispressureadaptor/hybrispressureadaptor.h @@ -55,7 +55,6 @@ class HybrisPressureAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp b/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp index f79b9f4f..5d91d903 100644 --- a/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp +++ b/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp @@ -153,7 +153,3 @@ void HybrisProximityAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisProximityAdaptor::init() -{ -} diff --git a/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.h b/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.h index ca4bd208..f615b14e 100644 --- a/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.h +++ b/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.h @@ -55,7 +55,6 @@ class HybrisProximityAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.cpp b/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.cpp index a46d5a14..64c2b8c7 100644 --- a/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.cpp +++ b/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.cpp @@ -110,7 +110,3 @@ void HybrisRotationAdaptor::processSample(const sensors_event_t& data) m_buffer->commit(); m_buffer->wakeUpReaders(); } - -void HybrisRotationAdaptor::init() -{ -} diff --git a/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.h b/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.h index a1492f93..2a0e7d60 100644 --- a/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.h +++ b/adaptors/hybrisrotationadaptor/hybrisrotationadaptor.h @@ -49,7 +49,6 @@ class HybrisRotationAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* m_buffer; diff --git a/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp b/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp index ecd6ca6d..f77b290d 100644 --- a/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp +++ b/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp @@ -91,7 +91,3 @@ void HybrisStepCounterAdaptor::processSample(const sensors_event_t& data) buffer->commit(); buffer->wakeUpReaders(); } - -void HybrisStepCounterAdaptor::init() -{ -} diff --git a/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.h b/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.h index 1e8ca4c9..7b50e67a 100644 --- a/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.h +++ b/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.h @@ -58,7 +58,6 @@ class HybrisStepCounterAdaptor : public HybrisAdaptor protected: void processSample(const sensors_event_t& data); - void init(); private: DeviceAdaptorRingBuffer* buffer; diff --git a/core/hybrisadaptor.cpp b/core/hybrisadaptor.cpp index 8486c86d..bfcec1d3 100644 --- a/core/hybrisadaptor.cpp +++ b/core/hybrisadaptor.cpp @@ -619,6 +619,37 @@ void HybrisManager::registerAdaptor(HybrisAdaptor *adaptor) } } +float HybrisManager::scaleSensorValue(const float value, const int type) const +{ + float outValue; + switch (type) { + case SENSOR_TYPE_ACCELEROMETER: + case SENSOR_TYPE_GRAVITY: + case SENSOR_TYPE_LINEAR_ACCELERATION: + //sensorfw wants milli-G' + outValue = value * GRAVITY_RECIPROCAL_THOUSANDS; + break; + case SENSOR_TYPE_MAGNETIC_FIELD: + case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: + // uT to nT + outValue = value * 1000; + break; + case SENSOR_TYPE_GYROSCOPE: + case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: + // From rad/s to mdeg/s + outValue = value * RADIANS_TO_DEGREES * 1000; + break; + case SENSOR_TYPE_PRESSURE: + // From hPa to Pa + outValue = value * 100; + break; + default: + outValue = value; + break; + } + return outValue; +} + float HybrisManager::getMaxRange(int handle) const { float range = 0; @@ -627,7 +658,7 @@ float HybrisManager::getMaxRange(int handle) const if (index != -1) { const struct sensor_t *sensor = &m_sensorArray[index]; - range = sensor->maxRange; + range = scaleSensorValue(sensor->maxRange, sensor->type); sensordLogT("HYBRIS CTL getMaxRange(%d=%s) -> %g", sensor->handle, sensorTypeName(sensor->type), range); } @@ -643,7 +674,7 @@ float HybrisManager::getResolution(int handle) const if (index != -1) { const struct sensor_t *sensor = &m_sensorArray[index]; - resolution = sensor->resolution; + resolution = scaleSensorValue(sensor->resolution, sensor->type); sensordLogT("HYBRIS CTL getResolution(%d=%s) -> %g", sensor->handle, sensorTypeName(sensor->type), resolution); } diff --git a/core/hybrisadaptor.h b/core/hybrisadaptor.h index 99f112dc..498d6609 100644 --- a/core/hybrisadaptor.h +++ b/core/hybrisadaptor.h @@ -126,6 +126,10 @@ #define SENSOR_TYPE_WRIST_TILT_GESTURE (26) #endif +#define GRAVITY_RECIPROCAL_THOUSANDS 101.971621298 +#define RADIANS_TO_DEGREESECONDS 57295.7795 +#define RADIANS_TO_DEGREES 57.2957795 + #define SENSORFW_MCE_WATCHER class HybrisAdaptor; @@ -221,6 +225,7 @@ class HybrisManager : public QObject private: static void *halEventReaderThread(void *aptr); #endif + float scaleSensorValue(const float value, const int type) const; void processEvents(const sensors_event_t *buffer, int numberOfEvents, bool &blockSuspend, bool &errorInInput); }; diff --git a/debian/changelog b/debian/changelog index 0a9b0818..35a54310 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,21 +1,35 @@ +sensorfw-qt5 (0.12.4) unstable; urgency=medium + + * [sensorfw] Remove /usr/include/filters from pkgconfig file as it is not installed + + -- Matti Lehtimäki Thu, 26 Aug 2021 16:52:00 +0300 + +sensorfw-qt5 (0.12.3) unstable; urgency=medium + + * [sensorfw] Discard any old sensor data before starting sensor + * [hybrisadaptor] Fix initialization of ranges and intervals + * [hybrisadaptor] Fix scaling of data ranges + + -- Matti Lehtimäki Thu, 22 Jul 2021 01:18:00 +0300 + sensorfw-qt5 (0.12.2) unstable; urgency=medium -[sensorfw] Move sensord.sock to /run -[sensorfw] Properly handle angle rollover in built-in compass support -[sensorfw] Cleanup Qt project files -[packaging] Refine systemd unit install and test cleanup + * [sensorfw] Move sensord.sock to /run + * [sensorfw] Properly handle angle rollover in built-in compass support + * [sensorfw] Cleanup Qt project files + * [packaging] Refine systemd unit install and test cleanup -- Matti Lehtimäki Thu, 21 Jan 2021 22:34:31 +0300 sensorfw-qt5 (0.12.1) unstable; urgency=medium -[hybrisadaptor] Fix building rotation vector adaptors with old Android versions + * [hybrisadaptor] Fix building rotation vector adaptors with old Android versions -- Matti Lehtimäki Wed, 09 Sep 2020 16:14:31 +0300 sensorfw-qt5 (0.12.0) unstable; urgency=medium -[hybrisadaptor] Use of hybris rotation vectors for compass + * [hybrisadaptor] Use of hybris rotation vectors for compass -- Simo Piiroinen Wed, 02 Sep 2020 15:12:31 +0300 diff --git a/qt-api/abstractsensor_i.cpp b/qt-api/abstractsensor_i.cpp index c2a1deca..d7c6758e 100644 --- a/qt-api/abstractsensor_i.cpp +++ b/qt-api/abstractsensor_i.cpp @@ -131,6 +131,11 @@ QDBusReply AbstractSensorChannelInterface::start(int sessionId) } pimpl_->running_ = true; + // Discard any old data already in the socket + if (pimpl_->socketReader_.socket()->bytesAvailable() > 0) { + pimpl_->socketReader_.socket()->readAll(); + } + connect(pimpl_->socketReader_.socket(), SIGNAL(readyRead()), this, SLOT(dataReceived())); QList argumentList; diff --git a/rpm/sensorfw-qt5-binder.spec b/rpm/sensorfw-qt5-binder.spec index b1502332..9ffca6ce 100644 --- a/rpm/sensorfw-qt5-binder.spec +++ b/rpm/sensorfw-qt5-binder.spec @@ -1,5 +1,5 @@ Name: hybris-libsensorfw-qt5-binder -Version: 0.12.2 +Version: 0.12.4 Release: 0 Provides: hybris-libsensorfw-qt5 = %{version}-%{release} Conflicts: hybris-libsensorfw-qt5 <= 0.10.9 diff --git a/rpm/sensorfw-qt5-hybris.spec b/rpm/sensorfw-qt5-hybris.spec index 5c705a5a..c14cadb5 100644 --- a/rpm/sensorfw-qt5-hybris.spec +++ b/rpm/sensorfw-qt5-hybris.spec @@ -1,5 +1,5 @@ Name: hybris-libsensorfw-qt5-hal -Version: 0.12.2 +Version: 0.12.4 Release: 0 Provides: hybris-libsensorfw-qt5 = %{version}-%{release} Conflicts: hybris-libsensorfw-qt5 <= 0.10.9 diff --git a/rpm/sensorfw-qt5.spec b/rpm/sensorfw-qt5.spec index edce9b0c..567f177a 100644 --- a/rpm/sensorfw-qt5.spec +++ b/rpm/sensorfw-qt5.spec @@ -1,9 +1,9 @@ Name: sensorfw-qt5 Summary: Sensor Framework Qt5 -Version: 0.12.2 +Version: 0.12.4 Release: 0 License: LGPLv2+ -URL: https://git.sailfishos.org/mer-core/sensorfw +URL: https://github.com/sailfishos/sensorfw Source0: %{name}-%{version}.tar.bz2 Source1: sensorfwd.service Source2: sensorfw-qt5-hybris.inc diff --git a/sensord-qt5.pc.in b/sensord-qt5.pc.in index b17c48b3..5e136ee7 100644 --- a/sensord-qt5.pc.in +++ b/sensord-qt5.pc.in @@ -4,7 +4,7 @@ libdir=${prefix}/@LIB@ Name: Sensorfw-qt5 Description: Sensord for Qt 5 -Version: 0.12.2 +Version: 0.12.4 Requires: Libs: -L${libdir} -lsensorclient-qt5 -lsensordatatypes-qt5 -Cflags: -I${includedir} -I${includedir}/datatypes -I${includedir}/filters +Cflags: -I${includedir} -I${includedir}/datatypes