Skip to content

Commit

Permalink
[QMI,QMC]Change log output to macro definition #16
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Dec 7, 2024
1 parent e3579bc commit 558c4dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
17 changes: 1 addition & 16 deletions src/SensorQMC6310.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,8 @@ class SensorQMC6310 :
uint8_t buffer[2];
readRegister(QMC6310_REG_CMD1, buffer, 2);
for (int i = 0; i < 2; ++i) {
#if defined(ARDUINO)
Serial.printf("CMD%d: 0x%02x", i + 1, buffer[i]);
#else
printf("CTRL%d: 0x%02x", i + 1, buffer[i]);
#endif
#if defined(ARDUINO)
Serial.print("\t\t BIN:");
Serial.println(buffer[i], BIN);
#else
LOG("\n");
#endif
log_d("CMD%d: 0x%02x", i + 1, buffer[i]);
}
#if defined(ARDUINO)
Serial.println();
#else
printf("\n");
#endif
}

private:
Expand Down
21 changes: 6 additions & 15 deletions src/SensorQMI8658.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,20 +918,11 @@ class SensorQMI8658 :
uint8_t buffer[9];
readRegister(QMI8658_REG_CTRL1, buffer, 9);
for (int i = 0; i < 9; ++i) {
#if defined(ARDUINO)
Serial.printf("CTRL%d: REG:0x%02X HEX:0x%02X\n", i + 1, QMI8658_REG_CTRL1 + i, buffer[i]);
#else
printf("CTRL%d: 0x%02x\n", i + 1, buffer[i]);
#endif
log_d("CTRL%d: REG:0x%02X HEX:0x%02X\n", i + 1, QMI8658_REG_CTRL1 + i, buffer[i]);
}

buffer[0] = readRegister(QMI8658_REG_FIFO_CTRL);
#if defined(ARDUINO)
Serial.printf("FIFO_CTRL: REG:0x%02X HEX:0x%02X\n", QMI8658_REG_FIFO_CTRL, buffer[0]);
#else
printf("FIFO_CTRL: REG:0x%02X HEX:0x%02X\n", QMI8658_REG_FIFO_CTRL, buffer[0]);
#endif

log_d("FIFO_CTRL: REG:0x%02X HEX:0x%02X\n", QMI8658_REG_FIFO_CTRL, buffer[0]);
}

void powerDown()
Expand Down Expand Up @@ -1761,9 +1752,9 @@ class SensorQMI8658 :
// If the absolute results of all three axes are higher than 200mg, the accelerometer can be considered functional.
// Otherwise, the accelerometer cannot be considered functional.
if (abs(dVX_mg) > 200 && abs(dVY_mg) > 200 && abs(dVZ_mg) > 200) {
Serial.println("Accelerometer is working properly.");
log_d("Accelerometer is working properly.");
} else {
Serial.println("Accelerometer is not working properly.");
log_d("Accelerometer is not working properly.");
return false;
}
return true;
Expand Down Expand Up @@ -1837,9 +1828,9 @@ class SensorQMI8658 :
// If the absolute results of all three axes are higher than 300dps, the gyroscope can be considered functional.
// Otherwise, the gyroscope cannot be considered functional.
if (abs(dVX) > 300 && abs(dVY) > 300 && abs(dVZ) > 300) {
Serial.println("Gyro is working properly.");
log_d("Gyro is working properly.");
} else {
Serial.println("Gyro is not working properly.");
log_d("Gyro is not working properly.");
return false;
}

Expand Down

0 comments on commit 558c4dd

Please sign in to comment.