Skip to content

Commit

Permalink
Merge branch 'main' into glove
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirenliel committed Jan 2, 2025
2 parents 2800d39 + c29b7bd commit 9fc58c5
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 48 deletions.
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Global code owner
* @Eirenliel

# Make Loucas code owner of the defines to keep fw tool compatibility
/src/defines.h @loucass003
/src/consts.h @loucass003
/src/debug.h @loucass003

# Sfusion framework
/src/sensors/softfusion/ @gorbit99 @l0ud
/srs/sensors/SensorFusion* @gorbit99 @l0ud
/srs/sensors/motionprocessing/ @gorbit99 @l0ud
/lib/vqf/
5 changes: 5 additions & 0 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
#if BOARD != BOARD_GLOVE_IMU_SLIMEVR_DEV
#define MAX_SENSORS_COUNT 2
#define TRACKER_TYPE TRACKER_TYPE_SVR_ROTATION
// Set I2C address here or directly in IMU_DESC_ENTRY for each IMU used
// If not set, default address is used based on the IMU and Sensor ID
// #define PRIMARY_IMU_ADDRESS_ONE 0x4a
// #define SECONDARY_IMU_ADDRESS_TWO 0x4b

// Axis mapping example
/*
#include "sensors/axisremap.h"
Expand Down
1 change: 0 additions & 1 deletion src/sensors/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "icm20948sensor.h"
#include "mpu6050sensor.h"
#include "mpu9250sensor.h"
#include "sensoraddresses.h"
#include "sensorinterface/I2CPCAInterface.h"
#include "sensorinterface/MCP23X17PinInterface.h"
#include "softfusion/drivers/bmi270.h"
Expand Down
27 changes: 18 additions & 9 deletions src/sensors/SensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#ifndef SLIMEVR_SENSORMANAGER
#define SLIMEVR_SENSORMANAGER

#ifndef PRIMARY_IMU_ADDRESS_ONE
#define PRIMARY_IMU_ADDRESS_ONE std::nullopt
#endif

#ifndef SECONDARY_IMU_ADDRESS_TWO
#define SECONDARY_IMU_ADDRESS_TWO std::nullopt
#endif

#include <i2cscan.h>

#include <memory>
#include <optional>

#include "EmptySensor.h"
#include "ErroneousSensor.h"
Expand Down Expand Up @@ -66,20 +74,20 @@ class SensorManager {
template <typename ImuType>
std::unique_ptr<Sensor> buildSensor(
uint8_t sensorID,
int addrSuppl,
std::optional<uint8_t> imuAddress,
float rotation,
SensorInterface* sensorInterface,
bool optional = false,
PinInterface* intPin = nullptr,
int extraParam = 0
) {
const uint8_t address = ImuType::Address + addrSuppl;
uint8_t i2cAddress = imuAddress.value_or(ImuType::Address + sensorID);
m_Logger.trace(
"Building IMU with: id=%d,\n\
address=0x%02X, rotation=%f,\n\
interface=%s, int=%s, extraParam=%d, optional=%d",
sensorID,
address,
i2cAddress,
rotation,
sensorInterface,
intPin,
Expand All @@ -94,21 +102,22 @@ class SensorManager {
sensorInterface->init();
sensorInterface->swapIn();

if (I2CSCAN::hasDevOnBus(address)) {
m_Logger.trace("Sensor %d found at address 0x%02X", sensorID + 1, address);
if (I2CSCAN::hasDevOnBus(i2cAddress)) {
m_Logger
.trace("Sensor %d found at address 0x%02X", sensorID + 1, i2cAddress);
} else {
if (!optional) {
m_Logger.error(
"Mandatory sensor %d not found at address 0x%02X",
sensorID + 1,
address
i2cAddress
);
sensor = std::make_unique<ErroneousSensor>(sensorID, ImuType::TypeID);
} else {
m_Logger.debug(
"Optional sensor %d not found at address 0x%02X",
sensorID + 1,
address
i2cAddress
);
sensor = std::make_unique<EmptySensor>(sensorID);
}
Expand All @@ -117,7 +126,7 @@ class SensorManager {

sensor = std::make_unique<ImuType>(
sensorID,
addrSuppl,
i2cAddress,
rotation,
sensorInterface,
intPin,
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/bmi160sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class BMI160Sensor : public Sensor {

BMI160Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface*,
Expand All @@ -148,7 +148,7 @@ class BMI160Sensor : public Sensor {
"BMI160Sensor",
ImuID::BMI160,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
)
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/bno055sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BNO055Sensor : public Sensor {

BNO055Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface*,
Expand All @@ -45,7 +45,7 @@ class BNO055Sensor : public Sensor {
"BNO055Sensor",
ImuID::BNO055,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
){};
Expand Down
16 changes: 8 additions & 8 deletions src/sensors/bno080sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BNO080Sensor : public Sensor {

BNO080Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface* intPin,
Expand All @@ -47,7 +47,7 @@ class BNO080Sensor : public Sensor {
"BNO080Sensor",
ImuID::BNO080,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
)
Expand All @@ -68,13 +68,13 @@ class BNO080Sensor : public Sensor {
const char* sensorName,
ImuID imuId,
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface* intPin,
int
)
: Sensor(sensorName, imuId, id, Address + addrSuppl, rotation, sensorInterface)
: Sensor(sensorName, imuId, id, i2cAddress, rotation, sensorInterface)
, m_IntPin(intPin){};

private:
Expand All @@ -101,7 +101,7 @@ class BNO085Sensor : public BNO080Sensor {
static constexpr auto TypeID = ImuID::BNO085;
BNO085Sensor(
uint8_t id,
uint8_t address,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface* intPin,
Expand All @@ -111,7 +111,7 @@ class BNO085Sensor : public BNO080Sensor {
"BNO085Sensor",
ImuID::BNO085,
id,
address,
i2cAddress,
rotation,
sensorInterface,
intPin,
Expand All @@ -124,7 +124,7 @@ class BNO086Sensor : public BNO080Sensor {
static constexpr auto TypeID = ImuID::BNO086;
BNO086Sensor(
uint8_t id,
uint8_t address,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface* intPin,
Expand All @@ -134,7 +134,7 @@ class BNO086Sensor : public BNO080Sensor {
"BNO086Sensor",
ImuID::BNO086,
id,
address,
i2cAddress,
rotation,
sensorInterface,
intPin,
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/icm20948sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ICM20948Sensor : public Sensor {

ICM20948Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface*,
Expand All @@ -45,7 +45,7 @@ class ICM20948Sensor : public Sensor {
"ICM20948Sensor",
ImuID::ICM20948,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
) {}
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/mpu6050sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MPU6050Sensor : public Sensor {

MPU6050Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface*,
Expand All @@ -46,7 +46,7 @@ class MPU6050Sensor : public Sensor {
"MPU6050Sensor",
ImuID::MPU6050,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
){};
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/mpu9250sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MPU9250Sensor : public Sensor {

MPU9250Sensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
SlimeVR::SensorInterface* sensorInterface,
PinInterface*,
Expand All @@ -59,7 +59,7 @@ class MPU9250Sensor : public Sensor {
"MPU9250Sensor",
ImuID::MPU9250,
id,
Address + addrSuppl,
i2cAddress,
rotation,
sensorInterface
)
Expand Down
7 changes: 0 additions & 7 deletions src/sensors/sensoraddresses.h

This file was deleted.

14 changes: 3 additions & 11 deletions src/sensors/softfusion/softfusionsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,15 @@ class SoftFusionSensor : public Sensor {

SoftFusionSensor(
uint8_t id,
uint8_t addrSuppl,
uint8_t i2cAddress,
float rotation,
uint8_t sclPin,
uint8_t sdaPin,
uint8_t
)
: Sensor(
imu::Name,
imu::Type,
id,
imu::Address + addrSuppl,
rotation,
sclPin,
sdaPin
)
: Sensor(imu::Name, imu::Type, id, i2cAddress, rotation, sclPin, sdaPin)
, m_fusion(imu::GyrTs, imu::AccTs, imu::MagTs)
, m_sensor(I2CImpl(imu::Address + addrSuppl), m_Logger) {}
, m_sensor(I2CImpl(i2cAddress), m_Logger) {}
~SoftFusionSensor() {}

void motionLoop() override final {
Expand Down
4 changes: 2 additions & 2 deletions src/serial/serialcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void printState() {
}

#if ESP32
char* getEncryptionTypeName(wifi_auth_mode_t type) {
String getEncryptionTypeName(wifi_auth_mode_t type) {
switch (type) {
case WIFI_AUTH_OPEN:
return "OPEN";
Expand All @@ -197,7 +197,7 @@ char* getEncryptionTypeName(wifi_auth_mode_t type) {
return "WPA3_ENT_192";
}
#else
char* getEncryptionTypeName(uint8_t type) {
String getEncryptionTypeName(uint8_t type) {
switch (type) {
case ENC_TYPE_NONE:
return "OPEN";
Expand Down

0 comments on commit 9fc58c5

Please sign in to comment.