Better support for different Bosch sensors, easy swap between 055/080/085 with one define, added compilation error just in case

This commit is contained in:
Eiren Rain
2021-03-14 15:17:48 +03:00
parent d9035bcc9f
commit 7309173bc5
3 changed files with 27 additions and 4 deletions

View File

@@ -24,6 +24,7 @@
#include "BNO080.h"
#include "sensor.h"
#include "udpclient.h"
#include "defines.h"
void BNO080Sensor::motionSetup(DeviceConfig * config)
{
@@ -39,7 +40,10 @@ void BNO080Sensor::motionSetup(DeviceConfig * config)
}
Serial.println("Connected to BNO08X");
Wire.setClock(400000);
imu.enableARVRStabilizedGameRotationVector(10);
if(BNO_HASARVR_STABILIZATION)
imu.enableARVRStabilizedGameRotationVector(10);
else
imu.enableGameRotationVector(10);
}
void BNO080Sensor::motionLoop()

View File

@@ -24,14 +24,29 @@
#define IMU_MPU9250 1
#define IMU_MPU6500 2
#define IMU_BNO080 3
#define IMU_BNO085 4
#define IMU_BNO055 5
#define IMU IMU_BNO080
#define IMU IMU_BNO085
#if IMU == IMU_BNO080
#if IMU == IMU_BNO085
#define IMU_NAME "BNO085"
#define IMU_HAS_ACCELL true
#define IMU_HAS_GYRO true
#define IMU_HAS_MAG true
#define BNO_HASARVR_STABILIZATION true
#elif IMU == IMU_BNO080
#define IMU_NAME "BNO080"
#define IMU_HAS_ACCELL true
#define IMU_HAS_GYRO true
#define IMU_HAS_MAG true
#define BNO_HASARVR_STABILIZATION false
#elif IMU == IMU_BNO055
#define IMU_NAME "BNO055"
#define IMU_HAS_ACCELL true
#define IMU_HAS_GYRO true
#define IMU_HAS_MAG true
#define BNO_HASARVR_STABILIZATION false
#elif IMU == IMU_MPU9250
#define IMU_NAME "MPU9250"
#define IMU_HAS_ACCELL true
@@ -42,6 +57,8 @@
#define IMU_HAS_ACCELL true
#define IMU_HAS_GYRO true
#define IMU_HAS_MAG false
#else
#error Select IMU in defines.h
#endif
//Debug information

View File

@@ -29,12 +29,14 @@
#include "defines.h"
#include "credentials.h"
#if IMU == IMU_BNO080
#if IMU == IMU_BNO080 || IMU == IMU_BNO085 || IMU == IMU_BNO055
BNO080Sensor sensor{};
#elif IMU == IMU_MPU9250
MPU9250Sensor sensor{};
#elif IMU == IMU_MPU6500
MPU6050Sensor sensor{};
#else
#error Unsupported IMU
#endif
DeviceConfig config{};