Skip to content

Commit

Permalink
Add announcement of magnetometer not supported (SlimeVR#356)
Browse files Browse the repository at this point in the history
* Add announcement of magnetometer not supported

* undo platformio config

* remove debug line
  • Loading branch information
ImUrX authored and gorbit99 committed Nov 12, 2024
1 parent 3ad8ba2 commit 90b22ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/configuration/SensorConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/SensorConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct SensorConfig {
} data;
};

uint16_t configDataToNumber(SensorConfig sensorConfig);
uint16_t configDataToNumber(SensorConfig* sensorConfig, bool magSupported);
} // namespace Configuration
} // namespace SlimeVR

Expand Down
5 changes: 4 additions & 1 deletion src/sensors/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ void Sensor::resetTemperatureCalibrationState() {
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) {
Expand Down

0 comments on commit 90b22ec

Please sign in to comment.