diff options
Diffstat (limited to 'src/plugins')
4 files changed, 38 insertions, 9 deletions
diff --git a/src/plugins/sensors/generic/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp index af2800c..af2c3cf 100644 --- a/src/plugins/sensors/generic/genericrotationsensor.cpp +++ b/src/plugins/sensors/generic/genericrotationsensor.cpp @@ -82,8 +82,8 @@ bool genericrotationsensor::filter(QSensorReading *reading) // Note that the formula used come from this document: // http://www.freescale.com/files/sensors/doc/app_note/AN3461.pdf - pitch = qAtan(y / sqrt(x*x + z*z)) * RADIANS_TO_DEGREES; - roll = qAtan(x / sqrt(y*y + z*z)) * RADIANS_TO_DEGREES; + pitch = qAtan(y / qSqrt(x*x + z*z)) * RADIANS_TO_DEGREES; + roll = qAtan(x / qSqrt(y*y + z*z)) * RADIANS_TO_DEGREES; // Roll is a left-handed rotation but we need right-handed rotation roll = -roll; @@ -92,7 +92,7 @@ bool genericrotationsensor::filter(QSensorReading *reading) // Note that theta is defined as the angle of the Z axis relative // to gravity (see referenced document). It's negative when the // face of the device points downward. - qreal theta = qAtan(sqrt(x*x + y*y) / z) * RADIANS_TO_DEGREES; + qreal theta = qAtan(qSqrt(x*x + y*y) / z) * RADIANS_TO_DEGREES; if (theta < 0) { if (roll > 0) roll = 180 - roll; diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp index f6dafb4..a2525a8 100644 --- a/src/plugins/sensors/generic/generictiltsensor.cpp +++ b/src/plugins/sensors/generic/generictiltsensor.cpp @@ -80,7 +80,7 @@ void GenericTiltSensor::stop() */ static inline qreal calcPitch(double Ax, double Ay, double Az) { - return -qAtan2(Ax, sqrt(Ay * Ay + Az * Az)); + return -qAtan2(Ax, qSqrt(Ay * Ay + Az * Az)); } /* @@ -91,7 +91,7 @@ static inline qreal calcPitch(double Ax, double Ay, double Az) */ static inline qreal calcRoll(double Ax, double Ay, double Az) { - return qAtan2(Ay, (sqrt(Ax * Ax + Az * Az))); + return qAtan2(Ay, (qSqrt(Ax * Ax + Az * Az))); } void GenericTiltSensor::calibrate() @@ -132,15 +132,15 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading) qreal xrot = roll - calibratedRoll; qreal yrot = pitch - calibratedPitch; //get angle between 0 and 180 or 0 -180 - qreal aG = 1 * sin(xrot); - qreal aK = 1 * cos(xrot); + qreal aG = 1 * qSin(xrot); + qreal aK = 1 * qCos(xrot); xrot = qAtan2(aG, aK); if (xrot > M_PI_2) xrot = M_PI - xrot; else if (xrot < -M_PI_2) xrot = -(M_PI + xrot); - aG = 1 * sin(yrot); - aK = 1 * cos(yrot); + aG = 1 * qSin(yrot); + aK = 1 * qCos(yrot); yrot = qAtan2(aG, aK); if (yrot > M_PI_2) yrot = M_PI - yrot; diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp index b85dbb0..82302ac 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp @@ -65,6 +65,7 @@ SensorfwSensorBase::SensorfwSensorBase(QSensor *sensor) connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(sensordUnregistered())); + connect(sensor, SIGNAL(alwaysOnChanged()),this,SLOT(standyOverrideChanged())); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("com.nokia.SensorService"); if (m_available) @@ -290,3 +291,29 @@ bool SensorfwSensorBase::initSensorInterface(QString const &name) setRanges(); return true; } + +void SensorfwSensorBase::standyOverrideChanged() +{ + m_sensorInterface->setStandbyOverride(sensor()->isAlwaysOn()); +} + +bool SensorfwSensorBase::isFeatureSupported(QSensor::Feature feature) const +{ + switch (feature) { + case QSensor::AlwaysOn: + return true; + case QSensor::AxesOrientation: + case QSensor::Buffering: + case QSensor::AccelerationMode: + case QSensor::SkipDuplicates: + case QSensor::PressureSensorTemperature: + case QSensor::GeoValues: + case QSensor::Reserved: + case QSensor::FieldOfView: + return false; + break; + }; + + return false; +} + diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h index 48f44ec..385c550 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h @@ -95,6 +95,7 @@ protected: int bufferSize() const; virtual qreal correctionFactor() const; bool reinitIsNeeded; + bool isFeatureSupported(QSensor::Feature feature) const; private: bool initSensorInterface(QString const &); @@ -109,6 +110,7 @@ private: private slots: void connectToSensord(); void sensordUnregistered(); + void standyOverrideChanged(); }; #endif |