diff options
author | Mathias Agopian <mathias@google.com> | 2010-12-01 03:38:00 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-12-01 03:38:00 -0800 |
commit | 56b6e17a31b642d98bdbcbc4599d6f6cc54114aa (patch) | |
tree | e2b87400d630631d6c8947cf76f2efcd0a1799b2 /services | |
parent | 20c2c4b2bcab89e193a51a66105d4a2a0b43bf01 (diff) | |
parent | 4b7de2c8de1427f27fc4b362c0c5997932826c16 (diff) | |
download | frameworks_base-56b6e17a31b642d98bdbcbc4599d6f6cc54114aa.zip frameworks_base-56b6e17a31b642d98bdbcbc4599d6f6cc54114aa.tar.gz frameworks_base-56b6e17a31b642d98bdbcbc4599d6f6cc54114aa.tar.bz2 |
am 4b7de2c8: am 66cff624: Merge "Uses 4-th order low-pass for extracting gravity." into gingerbread
* commit '4b7de2c8de1427f27fc4b362c0c5997932826c16':
Uses 4-th order low-pass for extracting gravity.
Diffstat (limited to 'services')
-rw-r--r-- | services/sensorservice/GravitySensor.cpp | 2 | ||||
-rw-r--r-- | services/sensorservice/GravitySensor.h | 2 | ||||
-rw-r--r-- | services/sensorservice/SecondOrderLowPassFilter.cpp | 19 | ||||
-rw-r--r-- | services/sensorservice/SecondOrderLowPassFilter.h | 12 |
4 files changed, 33 insertions, 2 deletions
diff --git a/services/sensorservice/GravitySensor.cpp b/services/sensorservice/GravitySensor.cpp index 18bd359..da72f9c 100644 --- a/services/sensorservice/GravitySensor.cpp +++ b/services/sensorservice/GravitySensor.cpp @@ -30,7 +30,7 @@ namespace android { GravitySensor::GravitySensor(sensor_t const* list, size_t count) : mSensorDevice(SensorDevice::getInstance()), mEnabled(false), mAccTime(0), - mLowPass(M_SQRT1_2, 1), + mLowPass(M_SQRT1_2, 1.5f), mX(mLowPass), mY(mLowPass), mZ(mLowPass) { diff --git a/services/sensorservice/GravitySensor.h b/services/sensorservice/GravitySensor.h index f9850b7..ff3bea7 100644 --- a/services/sensorservice/GravitySensor.h +++ b/services/sensorservice/GravitySensor.h @@ -37,7 +37,7 @@ class GravitySensor : public SensorInterface { double mAccTime; SecondOrderLowPassFilter mLowPass; - BiquadFilter mX, mY, mZ; + CascadedBiquadFilter mX, mY, mZ; public: GravitySensor(sensor_t const* list, size_t count); diff --git a/services/sensorservice/SecondOrderLowPassFilter.cpp b/services/sensorservice/SecondOrderLowPassFilter.cpp index e13e136..eeb6d1e 100644 --- a/services/sensorservice/SecondOrderLowPassFilter.cpp +++ b/services/sensorservice/SecondOrderLowPassFilter.cpp @@ -67,4 +67,23 @@ float BiquadFilter::operator()(float x) } // --------------------------------------------------------------------------- + +CascadedBiquadFilter::CascadedBiquadFilter(const SecondOrderLowPassFilter& s) + : mA(s), mB(s) +{ +} + +float CascadedBiquadFilter::init(float x) +{ + mA.init(x); + mB.init(x); + return x; +} + +float CascadedBiquadFilter::operator()(float x) +{ + return mB(mA(x)); +} + +// --------------------------------------------------------------------------- }; // namespace android diff --git a/services/sensorservice/SecondOrderLowPassFilter.h b/services/sensorservice/SecondOrderLowPassFilter.h index 998ca35..85698ca 100644 --- a/services/sensorservice/SecondOrderLowPassFilter.h +++ b/services/sensorservice/SecondOrderLowPassFilter.h @@ -54,6 +54,18 @@ public: float operator()(float in); }; +/* + * Two cascaded biquad IIR filters + * (4-poles IIR) + */ +class CascadedBiquadFilter { + BiquadFilter mA; + BiquadFilter mB; +public: + CascadedBiquadFilter(const SecondOrderLowPassFilter& s); + float init(float in); + float operator()(float in); +}; // --------------------------------------------------------------------------- }; // namespace android |