Skip to content

Commit

Permalink
[SensorQMI8658] Optimizing configuration parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Sep 24, 2024
1 parent 360a183 commit 4607930
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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),
Expand Down
10 changes: 4 additions & 6 deletions examples/QMI8658_InterruptExample/QMI8658_InterruptExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
20 changes: 12 additions & 8 deletions examples/QMI8658_PedometerExample/QMI8658_PedometerExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/*
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
38 changes: 22 additions & 16 deletions src/SensorQMI8658.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4607930

Please sign in to comment.