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

Adafruit NXP Precision Support #183

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions src/configuration/CalibrationConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@

#include <stdint.h>

namespace SlimeVR {
namespace Configuration {
struct BMI160CalibrationConfig {
namespace SlimeVR
{
namespace Configuration
{
struct BMI160CalibrationConfig
{
// accelerometer offsets and correction matrix
float A_B[3];
float A_Ainv[3][3];
Expand All @@ -40,15 +43,17 @@ namespace SlimeVR {
float temperature;
};

struct MPU6050CalibrationConfig {
struct MPU6050CalibrationConfig
{
// accelerometer offsets and correction matrix
float A_B[3];

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

struct MPU9250CalibrationConfig {
struct MPU9250CalibrationConfig
{
// accelerometer offsets and correction matrix
float A_B[3];
float A_Ainv[3][3];
Expand All @@ -61,7 +66,22 @@ namespace SlimeVR {
float G_off[3];
};

struct ICM20948CalibrationConfig {
struct NXPCalibrationConfig
{
// accelerometer offsets and correction matrix
float A_B[3];
float A_Ainv[3][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];
};

struct ICM20948CalibrationConfig
{
// gyroscope bias
int32_t G[3];

Expand All @@ -72,18 +92,29 @@ namespace SlimeVR {
int32_t C[3];
};

enum CalibrationConfigType { NONE, BMI160, MPU6050, MPU9250, ICM20948 };
enum CalibrationConfigType
{
NONE,
BMI160,
MPU6050,
MPU9250,
ICM20948,
NXP
};

const char* calibrationConfigTypeToString(CalibrationConfigType type);
const char *calibrationConfigTypeToString(CalibrationConfigType type);

struct CalibrationConfig {
struct CalibrationConfig
{
CalibrationConfigType type;

union {
union
{
BMI160CalibrationConfig bmi160;
MPU6050CalibrationConfig mpu6050;
MPU9250CalibrationConfig mpu9250;
ICM20948CalibrationConfig icm20948;
NXPCalibrationConfig nxp;
} data;
};
}
Expand Down
15 changes: 8 additions & 7 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define IMU_BNO086 7
#define IMU_BMI160 8
#define IMU_ICM20948 9
#define IMU_NXP 10

#define BOARD_SLIMEVR_LEGACY 1
#define BOARD_SLIMEVR_DEV 2
Expand All @@ -54,23 +55,23 @@

#define LED_OFF 255

#define POWER_SAVING_LEGACY 0 // No sleeping, but PS enabled
#define POWER_SAVING_NONE 1 // No sleeping, no PS => for connection issues
#define POWER_SAVING_MINIMUM 2 // Sleeping and PS => default
#define POWER_SAVING_LEGACY 0 // No sleeping, but PS enabled
#define POWER_SAVING_NONE 1 // No sleeping, no PS => for connection issues
#define POWER_SAVING_MINIMUM 2 // Sleeping and PS => default
#define POWER_SAVING_MODERATE 3 // Sleeping and better PS => might miss broadcasts, use at own risk
#define POWER_SAVING_MAXIMUM 4 // Actual CPU sleeping, currently has issues with disconnecting
#define POWER_SAVING_MAXIMUM 4 // Actual CPU sleeping, currently has issues with disconnecting

#define DEG_0 0.f
#define DEG_90 -PI / 2
#define DEG_180 PI
#define DEG_270 PI / 2

#ifdef ESP8266
#define HARDWARE_MCU 1
#define HARDWARE_MCU 1
#elif defined(ESP32)
#define HARDWARE_MCU 2
#define HARDWARE_MCU 2
#else
#define HARDWARE_MCU 0
#define HARDWARE_MCU 0
#endif

#define CURRENT_CONFIGURATION_VERSION 1
Expand Down
Loading