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

Add announcement of magnetometer not supported #356

Merged
merged 3 commits into from
Oct 31, 2024
Merged
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
9 changes: 6 additions & 3 deletions src/configuration/SensorConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/configuration/SensorConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define SLIMEVR_CONFIGURATION_SENSORCONFIG_H

#include <stdint.h>

#include "consts.h"

namespace SlimeVR {
Expand Down Expand Up @@ -148,7 +149,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 @@ -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) {
Expand Down