diff --git a/src/configuration/SensorConfig.cpp b/src/configuration/SensorConfig.cpp index cff2415d..28af04d4 100644 --- a/src/configuration/SensorConfig.cpp +++ b/src/configuration/SensorConfig.cpp @@ -46,11 +46,14 @@ const char* calibrationConfigTypeToString(SensorConfigType type) { } } -uint16_t configDataToNumber(SensorConfig sensorConfig) { +// 1st bit specifies if magnetometer is enabled or disabled +// 2nd bit specifies if magnetometer is supported +uint16_t configDataToNumber(SensorConfig* sensorConfig, bool magSupported) { uint16_t data = 0; - switch (sensorConfig.type) { + data += magSupported << 1; + switch (sensorConfig->type) { case SensorConfigType::BNO0XX: { - auto config = &sensorConfig.data.bno0XX; + auto config = &sensorConfig->data.bno0XX; data += config->magEnabled; break; } diff --git a/src/configuration/SensorConfig.h b/src/configuration/SensorConfig.h index f63c5db6..24b9477c 100644 --- a/src/configuration/SensorConfig.h +++ b/src/configuration/SensorConfig.h @@ -25,6 +25,7 @@ #define SLIMEVR_CONFIGURATION_SENSORCONFIG_H #include + #include "consts.h" namespace SlimeVR { @@ -148,7 +149,7 @@ struct SensorConfig { } data; }; -uint16_t configDataToNumber(SensorConfig sensorConfig); +uint16_t configDataToNumber(SensorConfig* sensorConfig, bool magSupported); } // namespace Configuration } // namespace SlimeVR diff --git a/src/sensors/sensor.cpp b/src/sensors/sensor.cpp index f5aa53f0..deaccfc9 100644 --- a/src/sensors/sensor.cpp +++ b/src/sensors/sensor.cpp @@ -71,7 +71,10 @@ void Sensor::resetTemperatureCalibrationState() { printTemperatureCalibrationUns uint16_t Sensor::getSensorConfigData() { SlimeVR::Configuration::SensorConfig sensorConfig = configuration.getSensor(sensorId); - return SlimeVR::Configuration::configDataToNumber(sensorConfig); + return SlimeVR::Configuration::configDataToNumber( + &sensorConfig, + magStatus != MagnetometerStatus::MAG_NOT_SUPPORTED + ); } const char * getIMUNameByType(ImuID imuType) {