Skip to content

Commit

Permalink
[SensorQMI8658]:Remove the default self-test #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Sep 23, 2024
1 parent 96e1f36 commit 85c662e
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/SensorQMI8658.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class SensorQMI8658 :
ACC_ODR_125Hz,
ACC_ODR_62_5Hz,
ACC_ODR_31_25Hz,
ACC_ODR_LOWPOWER_128Hz = 12,
ACC_ODR_LOWPOWER_21Hz,
ACC_ODR_LOWPOWER_11Hz,
ACC_ODR_LOWPOWER_3Hz
ACC_ODR_LOWPOWER_128Hz = 12, //The accelerometer low power mode is only available when the gyroscope is disabled
ACC_ODR_LOWPOWER_21Hz, //The accelerometer low power mode is only available when the gyroscope is disabled
ACC_ODR_LOWPOWER_11Hz, //The accelerometer low power mode is only available when the gyroscope is disabled
ACC_ODR_LOWPOWER_3Hz //The accelerometer low power mode is only available when the gyroscope is disabled
};

enum GyroODR {
Expand Down Expand Up @@ -175,6 +175,15 @@ class SensorQMI8658 :
STATUS1_TAP_MOTION = _BV(10),
};

enum TagPriority {
PRIORITY0, // (X > Y> Z)
PRIORITY1, // (X > Z > Y)
PRIORITY2, // (Y > X > Z)
PRIORITY3, // (Y > Z > X)
PRIORITY4, // (Z > X > Y)
PRIORITY5, // (Z > Y > X)
};

#if defined(ARDUINO)
SensorQMI8658(PLATFORM_WIRE_TYPE &w, int sda = DEFAULT_SDA, int scl = DEFAULT_SCL, uint8_t addr = QMI8658_L_SLAVE_ADDRESS)
{
Expand Down Expand Up @@ -324,7 +333,7 @@ class SensorQMI8658 :
* @retval
*/
int configAccelerometer(AccelRange range, AccelODR odr, LpfMode lpfOdr = LPF_MODE_0,
bool lpf = true, bool selfTest = true)
bool lpf = true)
{
bool en = isEnableAccelerometer();

Expand Down Expand Up @@ -362,7 +371,7 @@ class SensorQMI8658 :
}

// setAccelSelfTest
selfTest ? setRegisterBit(QMI8658_REG_CTRL2, 7) : clrRegisterBit(QMI8658_REG_CTRL2, 7);
// selfTest ? setRegisterBit(QMI8658_REG_CTRL2, 7) : clrRegisterBit(QMI8658_REG_CTRL2, 7);

if (en) {
enableAccelerometer();
Expand All @@ -378,11 +387,10 @@ class SensorQMI8658 :
* @param odr(Output data rate): see GyroODR
* @param lpfOdr(Low-Pass Filter Output data rate):
* @param lpf (Low-Pass Filter Mode): see LpfMode
* @param selfTest:
* @retval
*/
int configGyroscope(GyroRange range, GyroODR odr, LpfMode lpfOdr = LPF_MODE_0,
bool lpf = true, bool selfTest = true)
bool lpf = true)
{
bool en = isEnableGyroscope();

Expand Down Expand Up @@ -424,8 +432,7 @@ class SensorQMI8658 :
}

// setGyroSelfTest
selfTest ? setRegisterBit(QMI8658_REG_CTRL3, 7) : clrRegisterBit(QMI8658_REG_CTRL3, 7);

// selfTest ? setRegisterBit(QMI8658_REG_CTRL3, 7) : clrRegisterBit(QMI8658_REG_CTRL3, 7);

if (en) {
enableGyroscope();
Expand Down Expand Up @@ -642,6 +649,7 @@ class SensorQMI8658 :

bool getAccelRaw(int16_t *rawBuffer)
{
if (!accelEn)return false;
uint8_t buffer[6] = {0};
if (readRegister(QMI8658_REG_AX_L, buffer, 6) != DEV_WIRE_ERR) {
rawBuffer[0] = (int16_t)(buffer[1] << 8) | (buffer[0]);
Expand All @@ -655,6 +663,7 @@ class SensorQMI8658 :

bool getAccelerometer(float &x, float &y, float &z)
{
if (!accelEn)return false;
int16_t raw[3];
if (getAccelRaw(raw)) {
x = raw[0] * accelScales;
Expand All @@ -677,6 +686,7 @@ class SensorQMI8658 :

bool getGyroRaw(int16_t *rawBuffer)
{
if (!gyroEn)return false;
uint8_t buffer[6] = {0};
if (readRegister(QMI8658_REG_GX_L, buffer, 6) != DEV_WIRE_ERR) {
rawBuffer[0] = (int16_t)(buffer[1] << 8) | (buffer[0]);
Expand All @@ -690,6 +700,7 @@ class SensorQMI8658 :

int getGyroscope(float &x, float &y, float &z)
{
if (!gyroEn)return false;
int16_t raw[3];
if (getGyroRaw(raw)) {
x = raw[0] * gyroScales;
Expand Down Expand Up @@ -900,14 +911,7 @@ class SensorQMI8658 :
return clrRegisterBit(QMI8658_REG_CTRL8, 4);
}

enum TagPriority {
PRIORITY0, // (X > Y> Z)
PRIORITY1, // (X > Z > Y)
PRIORITY2, // (Y > X > Z)
PRIORITY3, // (Y > Z > X)
PRIORITY4, // (Z > X > Y)
PRIORITY5, // (Z > Y > X)
};


/**
* @brief configTap
Expand Down

0 comments on commit 85c662e

Please sign in to comment.