diff --git a/examples/QMI8658_CalibrationExample/QMI8658_CalibrationExample.ino b/examples/QMI8658_CalibrationExample/QMI8658_CalibrationExample.ino index 39d13db..8156a4d 100644 --- a/examples/QMI8658_CalibrationExample/QMI8658_CalibrationExample.ino +++ b/examples/QMI8658_CalibrationExample/QMI8658_CalibrationExample.ino @@ -175,6 +175,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_0); @@ -209,6 +210,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_3); diff --git a/examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino b/examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino index 8ad67da..c72bb58 100644 --- a/examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino +++ b/examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino @@ -135,6 +135,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_0); @@ -169,6 +170,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_3); @@ -177,7 +179,8 @@ void setup() // In 6DOF mode (accelerometer and gyroscope are both enabled), // the output data rate is derived from the nature frequency of gyroscope - qmi.enableGyroscope(); + // qmi.enableGyroscope(); + qmi.disableGyroscope(); qmi.enableAccelerometer(); // Print register configuration information diff --git a/examples/QMI8658_InterruptBlockExample/QMI8658_InterruptBlockExample.ino b/examples/QMI8658_InterruptBlockExample/QMI8658_InterruptBlockExample.ino index 16f2027..e51d6b0 100644 --- a/examples/QMI8658_InterruptBlockExample/QMI8658_InterruptBlockExample.ino +++ b/examples/QMI8658_InterruptBlockExample/QMI8658_InterruptBlockExample.ino @@ -145,10 +145,9 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_0, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_0); qmi.configGyroscope( @@ -161,7 +160,7 @@ void setup() * GYR_RANGE_512DPS * GYR_RANGE_1024DPS * */ - SensorQMI8658::GYR_RANGE_256DPS, + SensorQMI8658::GYR_RANGE_64DPS, /* * GYR_ODR_7174_4Hz * GYR_ODR_3587_2Hz @@ -179,10 +178,9 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_3, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_3); // In 6DOF mode (accelerometer and gyroscope are both enabled), diff --git a/examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino b/examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino index 265d2ad..f735430 100644 --- a/examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino +++ b/examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino @@ -126,10 +126,9 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_0, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_0); qmi.configGyroscope( @@ -160,10 +159,9 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_3, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_3); // In 6DOF mode (accelerometer and gyroscope are both enabled), diff --git a/examples/QMI8658_LockingMechanismExample/QMI8658_LockingMechanismExample.ino b/examples/QMI8658_LockingMechanismExample/QMI8658_LockingMechanismExample.ino index 1e0b054..9ccebe7 100644 --- a/examples/QMI8658_LockingMechanismExample/QMI8658_LockingMechanismExample.ino +++ b/examples/QMI8658_LockingMechanismExample/QMI8658_LockingMechanismExample.ino @@ -161,10 +161,11 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_0, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_0); + + qmi.configGyroscope( @@ -195,10 +196,9 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ - SensorQMI8658::LPF_MODE_3, - // selfTest enable - true); + SensorQMI8658::LPF_MODE_3); // In 6DOF mode (accelerometer and gyroscope are both enabled), // the output data rate is derived from the nature frequency of gyroscope diff --git a/examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino b/examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino index 9f23b15..a57caed 100644 --- a/examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino +++ b/examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino @@ -111,6 +111,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_0); @@ -143,6 +144,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_3); diff --git a/examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino b/examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino index 51b0259..e52108a 100644 --- a/examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino +++ b/examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino @@ -105,19 +105,22 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_0); + + qmi.configGyroscope( /* - * GYR_RANGE_16DPS - * GYR_RANGE_32DPS - * GYR_RANGE_64DPS - * GYR_RANGE_128DPS - * GYR_RANGE_256DPS - * GYR_RANGE_512DPS - * GYR_RANGE_1024DPS + * GYR_RANGE_16DPS + * GYR_RANGE_32DPS + * GYR_RANGE_64DPS + * GYR_RANGE_128DPS + * GYR_RANGE_256DPS + * GYR_RANGE_512DPS + * GYR_RANGE_1024DPS * */ SensorQMI8658::GYR_RANGE_64DPS, /* @@ -130,13 +133,14 @@ void setup() * GYR_ODR_112_1Hz * GYR_ODR_56_05Hz * GYR_ODR_28_025H - * */ + * */ SensorQMI8658::GYR_ODR_112_1Hz, /* * LPF_MODE_0 //2.66% of ODR * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_3); diff --git a/examples/QMI8658_ReadFromFifoExample/QMI8658_ReadFromFifoExample.ino b/examples/QMI8658_ReadFromFifoExample/QMI8658_ReadFromFifoExample.ino index 948739a..f5986b9 100644 --- a/examples/QMI8658_ReadFromFifoExample/QMI8658_ReadFromFifoExample.ino +++ b/examples/QMI8658_ReadFromFifoExample/QMI8658_ReadFromFifoExample.ino @@ -112,6 +112,7 @@ void setup() * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_0); @@ -137,13 +138,14 @@ void setup() * GYR_ODR_112_1Hz * GYR_ODR_56_05Hz * GYR_ODR_28_025H - * */ + * */ SensorQMI8658::GYR_ODR_896_8Hz, /* * LPF_MODE_0 //2.66% of ODR * LPF_MODE_1 //3.63% of ODR * LPF_MODE_2 //5.39% of ODR * LPF_MODE_3 //13.37% of ODR + * LPF_OFF // OFF Low-Pass Fitter * */ SensorQMI8658::LPF_MODE_3); diff --git a/src/SensorQMI8658.hpp b/src/SensorQMI8658.hpp index 005646f..9458e78 100644 --- a/src/SensorQMI8658.hpp +++ b/src/SensorQMI8658.hpp @@ -99,6 +99,7 @@ class SensorQMI8658 : LPF_MODE_1, //3.63% of ODR LPF_MODE_2, //5.39% of ODR LPF_MODE_3, //13.37% of ODR + LPF_OFF, //OFF Low-Pass Filter }; enum MotionEvent { @@ -332,8 +333,7 @@ class SensorQMI8658 : * @param selfTest: * @retval */ - int configAccelerometer(AccelRange range, AccelODR odr, LpfMode lpfOdr = LPF_MODE_0, - bool lpf = true) + int configAccelerometer(AccelRange range, AccelODR odr, LpfMode lpfOdr = LPF_MODE_0) { bool en = isEnableAccelerometer(); @@ -362,12 +362,16 @@ class SensorQMI8658 : return DEV_WIRE_ERR; } - // setAccelLowPassFitter - lpf ? setRegisterBit(QMI8658_REG_CTRL5, 0) : clrRegisterBit(QMI8658_REG_CTRL5, 0); - - // setAccelLowPassFitterOdr - if (writeRegister(QMI8658_REG_CTRL5, QMI8658_ACCEL_LPF_MASK, (lpfOdr << 1)) != DEV_WIRE_NONE) { - return DEV_WIRE_ERR; + if (lpfOdr != LPF_OFF) { + // setAccelLowPassFitterOdr + if (writeRegister(QMI8658_REG_CTRL5, QMI8658_ACCEL_LPF_MASK, (lpfOdr << 1)) != DEV_WIRE_NONE) { + return DEV_WIRE_ERR; + } + // Enable Low-Pass Fitter + setRegisterBit(QMI8658_REG_CTRL5, 0); + } else { + // Disable Low-Pass Fitter + clrRegisterBit(QMI8658_REG_CTRL5, 0); } // setAccelSelfTest @@ -389,8 +393,7 @@ class SensorQMI8658 : * @param lpf (Low-Pass Filter Mode): see LpfMode * @retval */ - int configGyroscope(GyroRange range, GyroODR odr, LpfMode lpfOdr = LPF_MODE_0, - bool lpf = true) + int configGyroscope(GyroRange range, GyroODR odr, LpfMode lpfOdr = LPF_MODE_0) { bool en = isEnableGyroscope(); @@ -422,13 +425,16 @@ class SensorQMI8658 : return DEV_WIRE_ERR; } - // setGyroLowPassFitter - lpf ? setRegisterBit(QMI8658_REG_CTRL5, 4) : clrRegisterBit(QMI8658_REG_CTRL5, 4); - - // setGyroLowPassFitterOdr - if (writeRegister(QMI8658_REG_CTRL5, QMI8658_GYRO_LPF_MASK, (lpfOdr << 5)) != DEV_WIRE_NONE) { - return DEV_WIRE_ERR; + if (lpfOdr != LPF_OFF) { + if (writeRegister(QMI8658_REG_CTRL5, QMI8658_GYRO_LPF_MASK, (lpfOdr << 5)) != DEV_WIRE_NONE) { + return DEV_WIRE_ERR; + } + // Enable Low-Pass Fitter + setRegisterBit(QMI8658_REG_CTRL5, 4); + } else { + // Disable Low-Pass Fitter + clrRegisterBit(QMI8658_REG_CTRL5, 4); } // setGyroSelfTest