Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMI323 and BMM350 implementation #296

Closed
wants to merge 17 commits into from
Closed
887 changes: 887 additions & 0 deletions lib/bmi323/bmi323.cpp

Large diffs are not rendered by default.

459 changes: 459 additions & 0 deletions lib/bmi323/bmi323.h

Large diffs are not rendered by default.

702 changes: 702 additions & 0 deletions lib/bmm350/bmm350.cpp

Large diffs are not rendered by default.

442 changes: 442 additions & 0 deletions lib/bmm350/bmm350.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/configuration/CalibrationConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace SlimeVR {
return "NONE";
case BMI160:
return "BMI160";
case BMI323:
return "BMI323";
case MPU6050:
return "MPU6050";
case MPU9250:
Expand Down
19 changes: 18 additions & 1 deletion src/configuration/CalibrationConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ namespace SlimeVR {
float temperature;
};

struct BMI323CalibrationConfig {
// accelerometer offsets and gain
uint16_t G_O[3];
uint8_t G_G[3];

// magnetometer offsets and correction matrix
float M_B[3];
float M_Ainv[3][3];

// raw offsets, determined from gyro at rest
float G_off[3];

// calibration temperature for dynamic compensation
float temperature;
};

struct MPU6050CalibrationConfig {
// accelerometer offsets and correction matrix
float A_B[3];
Expand Down Expand Up @@ -89,7 +105,7 @@ namespace SlimeVR {
float G_off[3];
};

enum CalibrationConfigType { NONE, BMI160, MPU6050, MPU9250, ICM20948, ICM42688 };
enum CalibrationConfigType { NONE, BMI160, MPU6050, MPU9250, ICM20948, ICM42688, BMI323 };

const char* calibrationConfigTypeToString(CalibrationConfigType type);

Expand All @@ -98,6 +114,7 @@ namespace SlimeVR {

union {
BMI160CalibrationConfig bmi160;
BMI323CalibrationConfig bmi323;
MPU6050CalibrationConfig mpu6050;
MPU9250CalibrationConfig mpu9250;
ICM20948CalibrationConfig icm20948;
Expand Down
7 changes: 7 additions & 0 deletions src/configuration/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ namespace SlimeVR {

break;

case CalibrationConfigType::BMI323:
m_Logger.info(" G_O: %d, %d, %d", UNPACK_VECTOR_ARRAY(c.data.bmi323.G_O));

m_Logger.info(" G_G: %d, %d, %d", UNPACK_VECTOR_ARRAY(c.data.bmi323.G_G));

break;

case CalibrationConfigType::ICM20948:
m_Logger.info(" G: %d, %d, %d", UNPACK_VECTOR_ARRAY(c.data.icm20948.G));
m_Logger.info(" A: %d, %d, %d", UNPACK_VECTOR_ARRAY(c.data.icm20948.A));
Expand Down
1 change: 1 addition & 0 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define IMU_BMI160 8
#define IMU_ICM20948 9
#define IMU_ICM42688 10
#define IMU_BMI323 11
#define IMU_DEV_RESERVED 250 // Reserved, should not be used in any release firmware

#define BOARD_UNKNOWN 0
Expand Down
3 changes: 3 additions & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#define BIAS_DEBUG false // Printing BIAS Variables to serial (ICM20948 only)
#define ENABLE_TAP false // monitor accel for (triple) tap events and send them. Uses more cpu, disable if problems. Server does nothing with value so disabled atm
#define SEND_ACCELERATION true // send linear acceleration to the server
#define BMI323_USE_BMM350 false // Set to true to use the data of a BMM350 magnetometer in combination with a BMI323
#define BMI323_USE_TEMP_CAL true // Set to true to enable temperature compensation for BMI323
#define BMI323_USE_SENSCAL true // Set to true to enable spin scale compensation

//Debug information

Expand Down
4 changes: 4 additions & 0 deletions src/sensors/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "mpu9250sensor.h"
#include "mpu6050sensor.h"
#include "bmi160sensor.h"
#include "bmi323sensor.h"
#include "icm20948sensor.h"
#include "icm42688sensor.h"
#include "ErroneousSensor.h"
Expand Down Expand Up @@ -99,6 +100,9 @@ namespace SlimeVR
}
}
break;
case IMU_BMI323:
sensor = new BMI323Sensor(sensorID, address, rotation, sclPin, sdaPin);
break;
case IMU_MPU6500: case IMU_MPU6050:
sensor = new MPU6050Sensor(sensorID, imuType, address, rotation, sclPin, sdaPin);
break;
Expand Down
Loading
Loading