Skip to content

Commit

Permalink
Update QMI8658 example
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Sep 23, 2024
1 parent 85c662e commit 1dcd8c1
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 54 deletions.
12 changes: 4 additions & 8 deletions examples/QMI8658_BlockExample/QMI8658_BlockExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 defalut spi pin
//Use LilyGo-T-Beam-S3 default spi pin
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -102,7 +102,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down Expand Up @@ -148,9 +148,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_0,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_0);


qmi.configGyroscope(
Expand Down Expand Up @@ -182,9 +180,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_3,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_3);


// In 6DOF mode (accelerometer and gyroscope are both enabled),
Expand Down
61 changes: 43 additions & 18 deletions examples/QMI8658_GetDataExample/QMI8658_GetDataExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
#include <SPI.h>
#include "SensorQMI8658.hpp"

#define USE_WIRE

// #define USE_WIRE

#if defined(USE_WIRE)
#ifndef SENSOR_SDA
#define SENSOR_SDA 17
#endif
Expand All @@ -46,8 +48,31 @@
#define SENSOR_IRQ -1
#endif

#else

//USE SPI
#ifndef SPI_MOSI
#define SPI_MOSI (35)
#endif

#ifndef SPI_SCK
#define SPI_SCK (36)
#endif

#ifndef SPI_MISO
#define SPI_MISO (37)
#endif

#ifndef IMU_CS
#define IMU_CS (34)
#endif

#ifndef IMU_INT
#define IMU_INT (33)
#endif

#endif

#define IMU_CS 5

SensorQMI8658 qmi;

Expand All @@ -72,7 +97,7 @@ void setup()
}
}
#else
if (!qmi.begin(IMU_CS)) {
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {
Serial.println("Failed to find QMI8658 - check your wiring!");
while (1) {
delay(1000);
Expand Down Expand Up @@ -111,9 +136,9 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_0,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_0);




qmi.configGyroscope(
Expand Down Expand Up @@ -145,9 +170,9 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_3,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_3);




// In 6DOF mode (accelerometer and gyroscope are both enabled),
Expand All @@ -168,23 +193,23 @@ void loop()
if (qmi.getDataReady()) {

if (qmi.getAccelerometer(acc.x, acc.y, acc.z)) {
Serial.print("{ACCEL: ");
Serial.print("ACCEL.x:");
Serial.print(acc.x);
Serial.print(",");
Serial.print(",ACCEL.y:");
Serial.print(acc.y);
Serial.print(",");
Serial.print(",ACCEL.z:");
Serial.print(acc.z);
Serial.println("}");
Serial.println("");
}

if (qmi.getGyroscope(gyr.x, gyr.y, gyr.z)) {
Serial.print("{GYRO: ");
Serial.print("GYRO.x:");
Serial.print(gyr.x);
Serial.print(",");
Serial.print(gyr.y );
Serial.print(",");
Serial.print(",GYRO.y:");
Serial.print(gyr.y);
Serial.print(",GYRO.z:");
Serial.print(gyr.z);
Serial.println("}");
Serial.println("");
}
Serial.print("\t\t\t\t > ");
Serial.print(qmi.getTimestamp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 defalut spi pin
//Use LilyGo-T-Beam-S3 default spi pin
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -101,7 +101,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 defalut spi pin
//Use LilyGo-T-Beam-S3 default spi pin
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -83,7 +83,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 default spi pin
//Use LilyGo-T-Beam-S3 default spi pin
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -118,7 +118,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down
8 changes: 2 additions & 6 deletions examples/QMI8658_MadgwickAHRS/QMI8658_MadgwickAHRS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_0,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_0);


qmi.configGyroscope(
Expand Down Expand Up @@ -146,9 +144,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
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 @@ -106,9 +106,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_0,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_0);


qmi.configGyroscope(
Expand Down Expand Up @@ -140,9 +138,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
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 @@ -113,9 +113,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_0,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_0);


qmi.configGyroscope(
Expand Down Expand Up @@ -147,9 +145,7 @@ void setup()
* LPF_MODE_2 //5.39% of ODR
* LPF_MODE_3 //13.37% of ODR
* */
SensorQMI8658::LPF_MODE_3,
// selfTest enable
true);
SensorQMI8658::LPF_MODE_3);

qmi.configFIFO(
/**
Expand Down
4 changes: 2 additions & 2 deletions examples/QMI8658_WakeOnMotion/QMI8658_WakeOnMotion.ino
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 defalut spi pinz
//Use LilyGo-T-Beam-S3 default spi pinz
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -92,7 +92,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void setup()
#else

#ifndef CONFIG_IDF_TARGET_ESP32
//Use tbeams3 defalut spi pinz
//Use LilyGo-T-Beam-S3 default spi pinz
#define SPI_MOSI (35)
#define SPI_SCK (36)
#define SPI_MISO (37)
Expand All @@ -97,7 +97,7 @@ void setup()
if (!qmi.begin(IMU_CS, SPI_MOSI, SPI_MISO, SPI_SCK)) {

#else
//Use esp32dev module defalut spi pin
//Use esp32dev module default spi pin
#define IMU_CS (5)
#define IMU_INT1 (15)
#define IMU_INT2 (22)
Expand Down

0 comments on commit 1dcd8c1

Please sign in to comment.