From 752dcb1dfa4d2233c452e1719a7671fa1f977c7f Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:58:39 +0200 Subject: [PATCH 01/16] Add compare operator to SensorConfig Co-Authored-By: Sapphire --- src/configuration/SensorConfig.cpp | 27 +++++++++++++++++++++++++++ src/configuration/SensorConfig.h | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/configuration/SensorConfig.cpp b/src/configuration/SensorConfig.cpp index aee7ae720..827116e56 100644 --- a/src/configuration/SensorConfig.cpp +++ b/src/configuration/SensorConfig.cpp @@ -47,6 +47,33 @@ const char* calibrationConfigTypeToString(SensorConfigType type) { } } +bool SensorConfig::operator==(const SensorConfig& rhs) const { + if (type != rhs.type) { + return false; + } + + switch (type) { + case SensorConfigType::NONE: + return true; + case SensorConfigType::BMI160: + return data.bmi160 == rhs.data.bmi160; + case SensorConfigType::MPU6050: + return data.mpu6050 == rhs.data.mpu6050; + case SensorConfigType::MPU9250: + return data.mpu9250 == rhs.data.mpu9250; + case SensorConfigType::ICM20948: + return data.icm20948 == rhs.data.icm20948; + case SensorConfigType::SFUSION: + return data.sfusion == rhs.data.sfusion; + case SensorConfigType::BNO0XX: + return data.bno0XX == rhs.data.bno0XX; + case SensorConfigType::RUNTIME_CALIBRATION: + return data.runtimeCalibration == rhs.data.runtimeCalibration; + default: + return false; + } +} + bool SensorConfigBits::operator==(const SensorConfigBits& rhs) const { return magEnabled == rhs.magEnabled && magSupported == rhs.magSupported && calibrationEnabled == rhs.calibrationEnabled diff --git a/src/configuration/SensorConfig.h b/src/configuration/SensorConfig.h index 4e197253e..c3c5e495d 100644 --- a/src/configuration/SensorConfig.h +++ b/src/configuration/SensorConfig.h @@ -43,6 +43,8 @@ struct BMI160SensorConfig { // calibration temperature for dynamic compensation float temperature; + + constexpr bool operator==(const BMI160SensorConfig& rhs) const = default; }; struct SoftFusionSensorConfig { @@ -75,6 +77,8 @@ struct SoftFusionSensorConfig { // temperature sampling rate (placed at the end to not break existing configs) float T_Ts; + + constexpr bool operator==(const SoftFusionSensorConfig& rhs) const = default; }; struct RuntimeCalibrationSensorConfig { @@ -98,6 +102,9 @@ struct RuntimeCalibrationSensorConfig { bool accelCalibrated[3]; float A_off[3]; + + constexpr bool operator==(const RuntimeCalibrationSensorConfig& rhs) const + = default; }; struct MPU6050SensorConfig { @@ -106,6 +113,8 @@ struct MPU6050SensorConfig { // raw offsets, determined from gyro at rest float G_off[3]; + + constexpr bool operator==(const MPU6050SensorConfig& rhs) const = default; }; struct MPU9250SensorConfig { @@ -119,6 +128,8 @@ struct MPU9250SensorConfig { // raw offsets, determined from gyro at rest float G_off[3]; + + constexpr bool operator==(const MPU9250SensorConfig& rhs) const = default; }; struct ICM20948SensorConfig { @@ -130,6 +141,8 @@ struct ICM20948SensorConfig { // compass bias int32_t C[3]; + + constexpr bool operator==(const ICM20948SensorConfig& rhs) const = default; }; struct ICM42688SensorConfig { @@ -143,10 +156,14 @@ struct ICM42688SensorConfig { // raw offsets, determined from gyro at rest float G_off[3]; + + constexpr bool operator==(const ICM42688SensorConfig& rhs) const = default; }; struct BNO0XXSensorConfig { bool magEnabled; + + constexpr bool operator==(const BNO0XXSensorConfig& rhs) const = default; }; enum class SensorConfigType { @@ -174,6 +191,8 @@ struct SensorConfig { BNO0XXSensorConfig bno0XX; RuntimeCalibrationSensorConfig runtimeCalibration; } data; + + bool operator==(const SensorConfig& rhs) const; }; struct SensorConfigBits { From aa9b1f6ea6944e3017a89fcc886eb751652b2595 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:49:12 +0200 Subject: [PATCH 02/16] Add loghex template --- src/logging/Logger.cpp | 7 +++++++ src/logging/Logger.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/logging/Logger.cpp b/src/logging/Logger.cpp index b696afaaf..2509db7f8 100644 --- a/src/logging/Logger.cpp +++ b/src/logging/Logger.cpp @@ -51,6 +51,13 @@ void Logger::fatal(const char* format, ...) const { va_end(args); } +void Logger::print(Level level, const char* format, ...) const { + va_list args; + va_start(args, format); + log(level, format, args); + va_end(args); +} + void Logger::log(Level level, const char* format, va_list args) const { if (level < LOG_LEVEL) { return; diff --git a/src/logging/Logger.h b/src/logging/Logger.h index 26aba82ea..4e5aef148 100644 --- a/src/logging/Logger.h +++ b/src/logging/Logger.h @@ -35,7 +35,35 @@ class Logger { static void tick(); + template + void loghex(Level level, const T* data, size_t elements) const { + if (level < LOG_LEVEL) { + return; + } + const size_t linelength = 80; + const uint8_t* tData = reinterpret_cast(data); + size_t tDataSize = sizeof(T) * elements; + size_t pos = 0; + char line[linelength + 1]; + size_t linesize = sizeof(line); + for (size_t i = 0; i < tDataSize; i++) { + snprintf( + line + pos, + linesize - pos, + "%02X ", + static_cast(tData[i]) + ); + pos = pos + 3; + if ((pos + 1 >= linesize - 1) || (i >= tDataSize - 1)) { + print(level, "%s", line); + pos = 0; + } + } + } + private: + void print(Level level, const char* str, ...) const + __attribute__((format(printf, 3, 4))); void log(Level level, const char* str, va_list args) const; const char* const m_Prefix; From f04a09f7fd68c0385d7800c27b2de4bf9aae8668 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:50:14 +0200 Subject: [PATCH 03/16] add compare operator to SensorToggleValues --- src/sensors/SensorToggles.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sensors/SensorToggles.h b/src/sensors/SensorToggles.h index a7e4cdfe6..ce75f76b7 100644 --- a/src/sensors/SensorToggles.h +++ b/src/sensors/SensorToggles.h @@ -40,6 +40,7 @@ struct SensorToggleValues { bool calibrationEnabled = true; bool tempGradientCalibrationEnabled = false; // disable by default, it is not clear that it really helps + bool operator==(const SensorToggleValues&) const = default; }; class SensorToggleState { From 757b0bb203a6ed9ec3b91ad47d19268a67178428 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:53:02 +0200 Subject: [PATCH 04/16] add comment that magEnabled has been replaced. --- src/configuration/SensorConfig.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/configuration/SensorConfig.h b/src/configuration/SensorConfig.h index c3c5e495d..7bb89257f 100644 --- a/src/configuration/SensorConfig.h +++ b/src/configuration/SensorConfig.h @@ -161,6 +161,7 @@ struct ICM42688SensorConfig { }; struct BNO0XXSensorConfig { + // the magEnabled Flag has been replaced by SensorToggles. It is no longer used. bool magEnabled; constexpr bool operator==(const BNO0XXSensorConfig& rhs) const = default; From d3edaafbf78fbce1800562b4f174e6784dff3c6e Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Wed, 1 Jul 2026 22:09:31 +0200 Subject: [PATCH 05/16] Add serial add config command wip --- src/serial/serialcommands.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/serial/serialcommands.cpp b/src/serial/serialcommands.cpp index 43b8e2f6d..8a34876b1 100644 --- a/src/serial/serialcommands.cpp +++ b/src/serial/serialcommands.cpp @@ -36,12 +36,12 @@ #endif #ifdef EXT_SERIAL_COMMANDS -#define CALLBACK_SIZE 7 // Increase callback size to allow for debug commands +#define CALLBACK_SIZE 8 // Increase callback size to allow for debug commands #include "i2cscan.h" #endif #ifndef CALLBACK_SIZE -#define CALLBACK_SIZE 6 // Default callback size +#define CALLBACK_SIZE 7 // Default callback size #endif #if defined(VENDOR_URL) && defined(VENDOR_NAME) && defined(PRODUCT_NAME) \ @@ -458,6 +458,18 @@ void cmdScanI2C(CmdParser* parser) { } #endif +void cmdConfig(CmdParser* parser) { + // The current implementation of config alloes only to print its value + // For future i want it to implement: + // - IP Configuration / DHCP + // - LED Settings + // - Sensor Settings (changing sensor parameters) + // + // Currently only print the SensorConfiguration + logger.info("SensorConfiguration:"); + configuration.print(); +} + void setUp() { cmdCallbacks.addCmd("SET", &cmdSet); cmdCallbacks.addCmd("GET", &cmdGet); @@ -465,6 +477,7 @@ void setUp() { cmdCallbacks.addCmd("REBOOT", &cmdReboot); cmdCallbacks.addCmd("DELCAL", &cmdDeleteCalibration); cmdCallbacks.addCmd("TCAL", &cmdTemperatureCalibration); + cmdCallbacks.addCmd("CONFIG", &cmdConfig); #if EXT_SERIAL_COMMANDS cmdCallbacks.addCmd("SCANI2C", &cmdScanI2C); #endif From 44a5c1708401de6f548d6e6227bcbf4a942bb049 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 00:34:26 +0200 Subject: [PATCH 06/16] make sensorConfig tick based --- src/configuration/Configuration.cpp | 169 ++++++++++++++++++++++++---- src/configuration/Configuration.h | 17 ++- src/main.cpp | 5 + 3 files changed, 168 insertions(+), 23 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index 8ab30e4f7..530a815be 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -93,7 +93,8 @@ void Configuration::setup() { } else { m_Logger.info("No configuration file found, creating new one"); m_Config.version = CURRENT_CONFIGURATION_VERSION; - save(); + m_ConfigChanged = true; + saveNeeded = true; } loadSensors(); @@ -102,12 +103,110 @@ void Configuration::setup() { m_Logger.info("Loaded configuration"); + cleanupMigration(); + #ifdef DEBUG_CONFIGURATION print(); #endif } +// Constant called function +// Should do the following: +// - Check if a config is flaged to change (well or check the flag for that) +// - Updaten after processig the flag if it is no changes left to save +// - make a minimal delay in between saves of files to limit the impact of multi config +// file saves +void Configuration::tick() { + if (saveNeeded && ((lastsave + delaysave) < millis())) { + bool saved = false; + + // Handle SensorConfig and saveNeeded + for (size_t i = 0; i < m_SensorsChanged.size(); i++) { + if (m_SensorsChanged[i] && !saved) { + if (saveSensorConfig(i)) { + m_SensorsChanged[i] = false; + saved = true; + } + } + if (m_SensorsChanged[i]) { + saveNeeded = true; + } + } + + // Handle SensorToggle and saveNeeded + for (size_t i = 0; i < m_SensorTogglesChanged.size(); i++) { + if (m_SensorTogglesChanged[i] && !saved) { + if (saveSensorToggle(i)) { + m_SensorTogglesChanged[i] = false; + saved = true; + } + } + if (m_SensorTogglesChanged[i]) { + saveNeeded = true; + } + } + + // TODO handle tracker config + if (m_ConfigChanged && !saved) { + File file = LittleFS.open("/config.bin", "w"); + file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); + file.close(); + m_ConfigChanged = false; + } + if (m_ConfigChanged) { + saveNeeded = true; + } + } +} + +bool Configuration::saveSensorConfig(size_t sensorId) { + SensorConfig config = m_Sensors[sensorId]; + if (config.type == SensorConfigType::NONE) { + return true; + } + + char path[17]; + sprintf(path, DIR_CALIBRATIONS "/%zu", sensorId); + + m_Logger.trace("Saving sensor config data for %zu", sensorId); + + File file = LittleFS.open(path, "w"); + bool ret = true; + if (file.write((uint8_t*)&config, sizeof(config)) < sizeof(config)) { + m_Logger.error("Failed to save sensor config: %s SensorID: %zu", path, sensorId); + ret = false; + } + file.close(); + return ret; +} + +bool Configuration::saveSensorToggle(size_t sensorId) { + char path[17]; + if (sensorId < m_SensorToggles.size()) { + sprintf(path, DIR_TOGGLES "/%zu", sensorId); + + m_Logger.trace("Saving sensor toggle state for %d", sensorId); + + File file = LittleFS.open(path, "w"); + auto toggleValues = m_SensorToggles[sensorId].getValues(); + bool ret = true; + if (file.write((uint8_t*)&toggleValues, sizeof(toggleValues)) < sizeof(toggleValues)) { + m_Logger.error("Failed to save sensor toggle state: %s SensorID: %zu", path, sensorId); + ret = false; + }; + file.close(); + return ret; + } else { + m_Logger.trace( + "Skipping saving toggles for sensor %d, no toggles present", + sensorId + ); + return true; + } +} + void Configuration::save() { +/* for (size_t i = 0; i < m_Sensors.size(); i++) { SensorConfig config = m_Sensors[i]; if (config.type == SensorConfigType::NONE) { @@ -139,13 +238,19 @@ void Configuration::save() { ); } } +*/ +/* { File file = LittleFS.open("/config.bin", "w"); file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); file.close(); } +*/ +} +void Configuration::cleanupMigration() +{ // Clean up old toggles directory if (LittleFS.exists(DIR_TOGGLES_OLD)) { char path[17] = DIR_TOGGLES_OLD; @@ -156,18 +261,22 @@ void Configuration::save() { file.close(); }); LittleFS.rmdir(DIR_TOGGLES_OLD); + m_Logger.debug("Cleanup Migration done"); } - - m_Logger.debug("Saved configuration"); } void Configuration::reset() { LittleFS.format(); m_Sensors.clear(); + m_SensorsChanged.clear(); m_SensorToggles.clear(); - m_Config.version = 1; + m_SensorTogglesChanged.clear(); + m_Config.version = CURRENT_CONFIGURATION_VERSION; + m_ConfigChanged = true; + // Todo: save basic config save(); + saveNeeded = true; m_Logger.debug("Reset configuration"); } @@ -176,22 +285,27 @@ int32_t Configuration::getVersion() const { return m_Config.version; } size_t Configuration::getSensorCount() const { return m_Sensors.size(); } -SensorConfig Configuration::getSensor(size_t sensorID) const { - if (sensorID >= m_Sensors.size()) { +SensorConfig Configuration::getSensor(size_t sensorId) const { + if (sensorId >= m_Sensors.size()) { return {}; } - return m_Sensors.at(sensorID); + return m_Sensors.at(sensorId); } -void Configuration::setSensor(size_t sensorID, const SensorConfig& config) { +void Configuration::setSensor(size_t sensorId, const SensorConfig& config, bool nosave) { size_t currentSensors = m_Sensors.size(); - - if (sensorID >= currentSensors) { - m_Sensors.resize(sensorID + 1); + m_Logger.trace("setSensor ID %d", sensorId); + if (sensorId >= currentSensors) { + m_Sensors.resize(sensorId + 1); } - - m_Sensors[sensorID] = config; + if ((m_Sensors[sensorId] != config) && !nosave) { + m_Logger.trace("setSensor ID %d, saving", sensorId); + m_SensorsChanged.resize(sensorId +1); + m_SensorsChanged[sensorId] = true; + saveNeeded = true; + } + m_Sensors[sensorId] = config; } SensorToggleState Configuration::getSensorToggles(size_t sensorId) const { @@ -202,18 +316,33 @@ SensorToggleState Configuration::getSensorToggles(size_t sensorId) const { return m_SensorToggles.at(sensorId); } -void Configuration::setSensorToggles(size_t sensorId, SensorToggleState state) { +void Configuration::setSensorToggles(size_t sensorId, SensorToggleState state, bool nosave) { size_t currentSensors = m_SensorToggles.size(); - + m_Logger.trace("setSensorToggles ID %d", sensorId); if (sensorId >= currentSensors) { m_SensorToggles.resize(sensorId + 1); } - + if (sensorId >= m_SensorTogglesChanged.size()) { + m_SensorTogglesChanged.resize(sensorId +1); + } + if ((m_SensorToggles[sensorId].getValues() != state.getValues()) && !nosave){ + m_Logger.trace("setSensorToggles ID %d, saving", sensorId); + m_SensorTogglesChanged[sensorId] = true; + saveNeeded = true; + } m_SensorToggles[sensorId] = state; } +// eraseSensors() +// What was this function intende for? m_Sensors.clear will erase the +// m_Sensors config but not the one stored in the Sensor:: +// a restart of the tracker is needed to reset the configuration values in the end +// the save at the end ... did not save any m_Sensors as it was cleared +// TODO: +// check if we should also remove sensorToggles from file void Configuration::eraseSensors() { m_Sensors.clear(); + m_SensorsChanged.clear(); SlimeVR::Utils::forEachFile(DIR_CALIBRATIONS, [&](SlimeVR::Utils::File f) { char path[17]; @@ -223,8 +352,7 @@ void Configuration::eraseSensors() { LittleFS.remove(path); }); - - save(); + saveNeeded = true; } void Configuration::loadSensors() { @@ -276,10 +404,10 @@ void Configuration::loadSensors() { SensorToggles::MagEnabled, sensorConfig.data.bno0XX.magEnabled ); - setSensorToggles(sensorId, toggles); + setSensorToggles(sensorId, toggles, true); } - setSensor(sensorId, sensorConfig); + setSensor(sensorId, sensorConfig, true); }); if (LittleFS.exists(DIR_TOGGLES_OLD)) { @@ -295,6 +423,7 @@ void Configuration::loadSensors() { setSensorToggles(sensorId, SensorToggleState{values}); }); + cleanupMigration(); } SlimeVR::Utils::forEachFile(DIR_TOGGLES, [&](SlimeVR::Utils::File f) { diff --git a/src/configuration/Configuration.h b/src/configuration/Configuration.h index b8aff0d87..b4c21dc71 100644 --- a/src/configuration/Configuration.h +++ b/src/configuration/Configuration.h @@ -41,13 +41,15 @@ class Configuration { void print(); + void tick(); + int32_t getVersion() const; size_t getSensorCount() const; - SensorConfig getSensor(size_t sensorID) const; - void setSensor(size_t sensorID, const SensorConfig& config); + SensorConfig getSensor(size_t sensorId) const; + void setSensor(size_t sensorId, const SensorConfig& config, bool nosave = false); SensorToggleState getSensorToggles(size_t sensorId) const; - void setSensorToggles(size_t sensorId, SensorToggleState state); + void setSensorToggles(size_t sensorId, SensorToggleState state, bool nosave = false); void eraseSensors(); bool loadTemperatureCalibration( @@ -62,12 +64,21 @@ class Configuration { private: void loadSensors(); bool runMigrations(int32_t version); + bool saveSensorConfig(size_t sensorId); + bool saveSensorToggle(size_t sensorId); + void cleanupMigration(); + unsigned long lastsave = millis(); + unsigned long delaysave = 200; + bool saveNeeded = false; bool m_Loaded = false; DeviceConfig m_Config{}; std::vector m_Sensors; std::vector m_SensorToggles; + bool m_ConfigChanged = false; + std::vector m_SensorsChanged; + std::vector m_SensorTogglesChanged; Logging::Logger m_Logger = Logging::Logger("Configuration"); }; diff --git a/src/main.cpp b/src/main.cpp index a1bf90116..0a53437a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,6 +57,7 @@ SlimeVR::Debugging::Benchmark ledManagerBM{"ledManager.update()"}; SlimeVR::Debugging::Benchmark i2cScanBM{"I2CSCAN::update()"}; SlimeVR::Debugging::Benchmark targetLooptimeBM{"TARGET_LOOPTIME_MICROS"}; SlimeVR::Debugging::Benchmark printStateBM{"Serial printState()"}; +SlimeVR::Debugging::Benchmark configSaveBM{"configSave.tick()"}; int sensorToCalibrate = -1; bool blinking = false; @@ -203,6 +204,10 @@ void loop() { I2CSCAN::update(); i2cScanBM.after(); + configSaveBM.before(); + configuration.tick(); + configSaveBM.after(); + #if defined(PRINT_STATE_EVERY_MS) && PRINT_STATE_EVERY_MS > 0 printStateBM.before(); unsigned long now = millis(); From 31e40fcb926fd8818feb0e6848213c3fee01ebbb Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 00:35:47 +0200 Subject: [PATCH 07/16] fix BNO080 saving configuration --- src/sensors/bno080sensor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sensors/bno080sensor.cpp b/src/sensors/bno080sensor.cpp index 9172e017e..f91fb4724 100644 --- a/src/sensors/bno080sensor.cpp +++ b/src/sensors/bno080sensor.cpp @@ -56,6 +56,11 @@ void BNO080Sensor::motionSetup() { imu.swVersionPatch ); + SlimeVR::Configuration::SensorConfig config; + config.type = SlimeVR::Configuration::SensorConfigType::BNO0XX; + config.data.bno0XX = m_Config; + configuration.setSensor(sensorId, config); + this->imu.enableLinearAccelerometer(10); toggles = configuration.getSensorToggles(sensorId); From b3aa355b6757eace2cd8f9656659f0b7f4512650 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 01:02:54 +0200 Subject: [PATCH 08/16] Add runtime_calibration print --- src/configuration/Configuration.cpp | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index 530a815be..ce468f3a2 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -642,8 +642,80 @@ void Configuration::print() { case SensorConfigType::BNO0XX: m_Logger.info(" magEnabled: %d", c.data.bno0XX.magEnabled); + break; + case SensorConfigType::RUNTIME_CALIBRATION: + m_Logger.info( + " A_Ts : %f", + c.data.runtimeCalibration.A_Ts + ); + m_Logger.info( + " G_Ts : %f", + c.data.runtimeCalibration.G_Ts + ); + m_Logger.info( + " M_Ts : %f", + c.data.runtimeCalibration.M_Ts + ); + m_Logger.info( + " T_Ts : %f", + c.data.runtimeCalibration.T_Ts + ); + + m_Logger.info( + " TimestepsCalibrated: %d", + c.data.runtimeCalibration.sensorTimestepsCalibrated + ); + + m_Logger.info( + " accelCalibrated: %d, %d, %d", + UNPACK_VECTOR_ARRAY(c.data.runtimeCalibration.accelCalibrated) + ); + m_Logger.info( + " A_off : %f, %f, %f", + UNPACK_VECTOR_ARRAY(c.data.runtimeCalibration.A_off) + ); + + m_Logger.info( + " gyroPointsCalibrated: %d", + c.data.runtimeCalibration.gyroPointsCalibrated + ); + + m_Logger.info( + " G_OffTemp1 : %f", + c.data.runtimeCalibration.gyroMeasurementTemperature1 + ); + m_Logger.info( + " G_off1 : %f, %f, %f", + UNPACK_VECTOR_ARRAY(c.data.runtimeCalibration.G_off1) + ); + + m_Logger.info( + " G_OffTemp2 : %f", + c.data.runtimeCalibration.gyroMeasurementTemperature2 + ); + m_Logger.info( + " G_off2 : %f, %f, %f", + UNPACK_VECTOR_ARRAY(c.data.runtimeCalibration.G_off2) + ); + + m_Logger.info( + " MotionlessDataLen: %d", + c.data.runtimeCalibration.MotionlessDataLen + ); + + m_Logger.info(" MotionlessData:"); + m_Logger.loghex( + SlimeVR::Logging::INFO, + c.data.runtimeCalibration.MotionlessData, + sizeof(c.data.runtimeCalibration.MotionlessData) + ); + break; default: + m_Logger.info( + " Not defined to Print %s", + calibrationConfigTypeToString(c.type) + ); break; } } From 72fb3c34e475cf4efcf03518a488db76a5b58b90 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 01:07:03 +0200 Subject: [PATCH 09/16] Add sensorToggles to print --- src/configuration/Configuration.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index ce468f3a2..8578cab69 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -718,6 +718,24 @@ void Configuration::print() { ); break; } + + if (i < m_SensorToggles.size()) { + m_Logger.info( + " SensorToggles:" + ); + m_Logger.info( + " MagEnabled: %d", + m_SensorToggles[i].getToggle(SensorToggles::MagEnabled) + ); + m_Logger.info( + " CalibrationEnabled: %d", + m_SensorToggles[i].getToggle(SensorToggles::CalibrationEnabled) + ); + m_Logger.info( + " TempCalibrationEnabled: %d", + m_SensorToggles[i].getToggle(SensorToggles::TempGradientCalibrationEnabled) + ); + } } } } // namespace SlimeVR::Configuration From a787a33c874a161db9faf1d6ca8afcba53e46635 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 01:22:28 +0200 Subject: [PATCH 10/16] format --- src/configuration/Configuration.cpp | 107 ++++++++++++++++------------ 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index 8578cab69..a359f7c1f 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -173,7 +173,8 @@ bool Configuration::saveSensorConfig(size_t sensorId) { File file = LittleFS.open(path, "w"); bool ret = true; if (file.write((uint8_t*)&config, sizeof(config)) < sizeof(config)) { - m_Logger.error("Failed to save sensor config: %s SensorID: %zu", path, sensorId); + m_Logger + .error("Failed to save sensor config: %s SensorID: %zu", path, sensorId); ret = false; } file.close(); @@ -190,8 +191,13 @@ bool Configuration::saveSensorToggle(size_t sensorId) { File file = LittleFS.open(path, "w"); auto toggleValues = m_SensorToggles[sensorId].getValues(); bool ret = true; - if (file.write((uint8_t*)&toggleValues, sizeof(toggleValues)) < sizeof(toggleValues)) { - m_Logger.error("Failed to save sensor toggle state: %s SensorID: %zu", path, sensorId); + if (file.write((uint8_t*)&toggleValues, sizeof(toggleValues)) + < sizeof(toggleValues)) { + m_Logger.error( + "Failed to save sensor toggle state: %s SensorID: %zu", + path, + sensorId + ); ret = false; }; file.close(); @@ -206,51 +212,50 @@ bool Configuration::saveSensorToggle(size_t sensorId) { } void Configuration::save() { -/* - for (size_t i = 0; i < m_Sensors.size(); i++) { - SensorConfig config = m_Sensors[i]; - if (config.type == SensorConfigType::NONE) { - continue; - } + /* + for (size_t i = 0; i < m_Sensors.size(); i++) { + SensorConfig config = m_Sensors[i]; + if (config.type == SensorConfigType::NONE) { + continue; + } - char path[17]; - sprintf(path, DIR_CALIBRATIONS "/%zu", i); + char path[17]; + sprintf(path, DIR_CALIBRATIONS "/%zu", i); - m_Logger.trace("Saving sensor config data for %d", i); + m_Logger.trace("Saving sensor config data for %d", i); - File file = LittleFS.open(path, "w"); - file.write((uint8_t*)&config, sizeof(SensorConfig)); - file.close(); + File file = LittleFS.open(path, "w"); + file.write((uint8_t*)&config, sizeof(SensorConfig)); + file.close(); - if (i < m_SensorToggles.size()) { - sprintf(path, DIR_TOGGLES "/%zu", i); + if (i < m_SensorToggles.size()) { + sprintf(path, DIR_TOGGLES "/%zu", i); - m_Logger.trace("Saving sensor toggle state for %d", i); + m_Logger.trace("Saving sensor toggle state for %d", i); - file = LittleFS.open(path, "w"); - auto toggleValues = m_SensorToggles[i].getValues(); - file.write((uint8_t*)&toggleValues, sizeof(SensorToggleValues)); - file.close(); - } else { - m_Logger.trace( - "Skipping saving toggles for sensor %d, no toggles present", - i - ); + file = LittleFS.open(path, "w"); + auto toggleValues = m_SensorToggles[i].getValues(); + file.write((uint8_t*)&toggleValues, sizeof(SensorToggleValues)); + file.close(); + } else { + m_Logger.trace( + "Skipping saving toggles for sensor %d, no toggles present", + i + ); + } } - } -*/ + */ -/* - { - File file = LittleFS.open("/config.bin", "w"); - file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); - file.close(); - } -*/ + /* + { + File file = LittleFS.open("/config.bin", "w"); + file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); + file.close(); + } + */ } -void Configuration::cleanupMigration() -{ +void Configuration::cleanupMigration() { // Clean up old toggles directory if (LittleFS.exists(DIR_TOGGLES_OLD)) { char path[17] = DIR_TOGGLES_OLD; @@ -293,7 +298,11 @@ SensorConfig Configuration::getSensor(size_t sensorId) const { return m_Sensors.at(sensorId); } -void Configuration::setSensor(size_t sensorId, const SensorConfig& config, bool nosave) { +void Configuration::setSensor( + size_t sensorId, + const SensorConfig& config, + bool nosave +) { size_t currentSensors = m_Sensors.size(); m_Logger.trace("setSensor ID %d", sensorId); if (sensorId >= currentSensors) { @@ -301,7 +310,7 @@ void Configuration::setSensor(size_t sensorId, const SensorConfig& config, bool } if ((m_Sensors[sensorId] != config) && !nosave) { m_Logger.trace("setSensor ID %d, saving", sensorId); - m_SensorsChanged.resize(sensorId +1); + m_SensorsChanged.resize(sensorId + 1); m_SensorsChanged[sensorId] = true; saveNeeded = true; } @@ -316,16 +325,20 @@ SensorToggleState Configuration::getSensorToggles(size_t sensorId) const { return m_SensorToggles.at(sensorId); } -void Configuration::setSensorToggles(size_t sensorId, SensorToggleState state, bool nosave) { +void Configuration::setSensorToggles( + size_t sensorId, + SensorToggleState state, + bool nosave +) { size_t currentSensors = m_SensorToggles.size(); m_Logger.trace("setSensorToggles ID %d", sensorId); if (sensorId >= currentSensors) { m_SensorToggles.resize(sensorId + 1); } if (sensorId >= m_SensorTogglesChanged.size()) { - m_SensorTogglesChanged.resize(sensorId +1); + m_SensorTogglesChanged.resize(sensorId + 1); } - if ((m_SensorToggles[sensorId].getValues() != state.getValues()) && !nosave){ + if ((m_SensorToggles[sensorId].getValues() != state.getValues()) && !nosave) { m_Logger.trace("setSensorToggles ID %d, saving", sensorId); m_SensorTogglesChanged[sensorId] = true; saveNeeded = true; @@ -720,9 +733,7 @@ void Configuration::print() { } if (i < m_SensorToggles.size()) { - m_Logger.info( - " SensorToggles:" - ); + m_Logger.info(" SensorToggles:"); m_Logger.info( " MagEnabled: %d", m_SensorToggles[i].getToggle(SensorToggles::MagEnabled) @@ -733,7 +744,9 @@ void Configuration::print() { ); m_Logger.info( " TempCalibrationEnabled: %d", - m_SensorToggles[i].getToggle(SensorToggles::TempGradientCalibrationEnabled) + m_SensorToggles[i].getToggle( + SensorToggles::TempGradientCalibrationEnabled + ) ); } } From 801b54bf19d09e777aab3c5226c79013aed84149 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 2 Jul 2026 01:29:53 +0200 Subject: [PATCH 11/16] format --- src/configuration/Configuration.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/configuration/Configuration.h b/src/configuration/Configuration.h index b4c21dc71..386c49eaa 100644 --- a/src/configuration/Configuration.h +++ b/src/configuration/Configuration.h @@ -49,7 +49,8 @@ class Configuration { SensorConfig getSensor(size_t sensorId) const; void setSensor(size_t sensorId, const SensorConfig& config, bool nosave = false); SensorToggleState getSensorToggles(size_t sensorId) const; - void setSensorToggles(size_t sensorId, SensorToggleState state, bool nosave = false); + void + setSensorToggles(size_t sensorId, SensorToggleState state, bool nosave = false); void eraseSensors(); bool loadTemperatureCalibration( From a9a7288a8f162e2547a68aae406cb30d360237b2 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 9 Jul 2026 20:31:01 +0200 Subject: [PATCH 12/16] cleaning up --- src/configuration/Configuration.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index a359f7c1f..e61a9b45e 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -146,7 +146,7 @@ void Configuration::tick() { } } - // TODO handle tracker config + // Handle sensor config if (m_ConfigChanged && !saved) { File file = LittleFS.open("/config.bin", "w"); file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); @@ -279,8 +279,11 @@ void Configuration::reset() { m_SensorTogglesChanged.clear(); m_Config.version = CURRENT_CONFIGURATION_VERSION; m_ConfigChanged = true; - // Todo: save basic config - save(); + // Todo: + // - we dont want to save the old tracker configuration. As it would defeat the purpus of the reset. + // Also not clear if we realy need to save the basic configuration, till a command it changed again. + // But this also means the the after a reset we need to restart a tracker to activate the + // new configuration on the sensor. The sensorconfig is not cleared on the sensor saveNeeded = true; m_Logger.debug("Reset configuration"); @@ -347,12 +350,10 @@ void Configuration::setSensorToggles( } // eraseSensors() -// What was this function intende for? m_Sensors.clear will erase the -// m_Sensors config but not the one stored in the Sensor:: -// a restart of the tracker is needed to reset the configuration values in the end -// the save at the end ... did not save any m_Sensors as it was cleared -// TODO: -// check if we should also remove sensorToggles from file +// Removes the Configuration: +// m_Sensors from Configuration, but it leaves a active copy on +// the Sensors itself. To make a change after eraseSensors the trackern +// needs to be rebooted. Only then the Sensors are reinitialized void Configuration::eraseSensors() { m_Sensors.clear(); m_SensorsChanged.clear(); From 445cd7b37cbe401db6b4fd9511de7d4f047368c7 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 9 Jul 2026 21:09:40 +0200 Subject: [PATCH 13/16] remove configuration::save() --- src/configuration/Configuration.cpp | 44 ------------------- src/configuration/Configuration.h | 1 - src/network/connection.cpp | 1 - src/sensors/icm20948sensor.cpp | 1 - src/sensors/mpu6050sensor.cpp | 4 +- src/sensors/mpu9250sensor.cpp | 1 - src/sensors/sensor.cpp | 1 - .../softfusion/SoftfusionCalibration.h | 1 - .../runtimecalibration/RuntimeCalibration.h | 1 - 9 files changed, 3 insertions(+), 52 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index e61a9b45e..1c168ee43 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -211,50 +211,6 @@ bool Configuration::saveSensorToggle(size_t sensorId) { } } -void Configuration::save() { - /* - for (size_t i = 0; i < m_Sensors.size(); i++) { - SensorConfig config = m_Sensors[i]; - if (config.type == SensorConfigType::NONE) { - continue; - } - - char path[17]; - sprintf(path, DIR_CALIBRATIONS "/%zu", i); - - m_Logger.trace("Saving sensor config data for %d", i); - - File file = LittleFS.open(path, "w"); - file.write((uint8_t*)&config, sizeof(SensorConfig)); - file.close(); - - if (i < m_SensorToggles.size()) { - sprintf(path, DIR_TOGGLES "/%zu", i); - - m_Logger.trace("Saving sensor toggle state for %d", i); - - file = LittleFS.open(path, "w"); - auto toggleValues = m_SensorToggles[i].getValues(); - file.write((uint8_t*)&toggleValues, sizeof(SensorToggleValues)); - file.close(); - } else { - m_Logger.trace( - "Skipping saving toggles for sensor %d, no toggles present", - i - ); - } - } - */ - - /* - { - File file = LittleFS.open("/config.bin", "w"); - file.write((uint8_t*)&m_Config, sizeof(DeviceConfig)); - file.close(); - } - */ -} - void Configuration::cleanupMigration() { // Clean up old toggles directory if (LittleFS.exists(DIR_TOGGLES_OLD)) { diff --git a/src/configuration/Configuration.h b/src/configuration/Configuration.h index 386c49eaa..664b9bc90 100644 --- a/src/configuration/Configuration.h +++ b/src/configuration/Configuration.h @@ -36,7 +36,6 @@ class Configuration { public: void setup(); - void save(); void reset(); void print(); diff --git a/src/network/connection.cpp b/src/network/connection.cpp index f5eb1ff94..6e4e1232c 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -799,7 +799,6 @@ void Connection::update() { sensor->setFlag(flag, newState); } sendAcknowledgeConfigChange(sensorId, flag); - configuration.save(); break; } } diff --git a/src/sensors/icm20948sensor.cpp b/src/sensors/icm20948sensor.cpp index bffcea15a..b56ba4375 100644 --- a/src/sensors/icm20948sensor.cpp +++ b/src/sensors/icm20948sensor.cpp @@ -432,7 +432,6 @@ void ICM20948Sensor::saveCalibration(bool repeat) { config.type = SlimeVR::Configuration::SensorConfigType::ICM20948; config.data.icm20948 = m_Config; configuration.setSensor(sensorId, config); - configuration.save(); if (repeat) { bias_save_counter++; diff --git a/src/sensors/mpu6050sensor.cpp b/src/sensors/mpu6050sensor.cpp index e3402e0c3..0c4a83b70 100644 --- a/src/sensors/mpu6050sensor.cpp +++ b/src/sensors/mpu6050sensor.cpp @@ -228,8 +228,10 @@ void MPU6050Sensor::startCalibration(int calibrationType) { SlimeVR::Configuration::SensorConfig calibration; calibration.type = SlimeVR::Configuration::SensorConfigType::MPU6050; calibration.data.mpu6050 = m_Config; + // TODO: setCalibration does nolonger exist. + // that code branch is only enabled when trying to compile with + // IMU_MPU6050_RUNTIME_CALIBRATION configuration.setCalibration(sensorId, calibration); - configuration.save(); m_Logger.info("Calibration finished"); #endif // !IMU_MPU6050_RUNTIME_CALIBRATION diff --git a/src/sensors/mpu9250sensor.cpp b/src/sensors/mpu9250sensor.cpp index 6425d7b73..de573b06c 100644 --- a/src/sensors/mpu9250sensor.cpp +++ b/src/sensors/mpu9250sensor.cpp @@ -395,7 +395,6 @@ void MPU9250Sensor::startCalibration(int calibrationType) { config.type = SlimeVR::Configuration::SensorConfigType::MPU9250; config.data.mpu9250 = m_Config; configuration.setSensor(sensorId, config); - configuration.save(); ledManager.off(); m_Logger.debug("Saved the calibration data"); diff --git a/src/sensors/sensor.cpp b/src/sensors/sensor.cpp index ea484d24c..71d1e0fbb 100644 --- a/src/sensors/sensor.cpp +++ b/src/sensors/sensor.cpp @@ -170,5 +170,4 @@ void Sensor::setFlag(SensorToggles toggle, bool state) { toggles.setToggle(toggle, state); configuration.setSensorToggles(sensorId, toggles); - configuration.save(); } diff --git a/src/sensors/softfusion/SoftfusionCalibration.h b/src/sensors/softfusion/SoftfusionCalibration.h index b4b7850b2..515ac033d 100644 --- a/src/sensors/softfusion/SoftfusionCalibration.h +++ b/src/sensors/softfusion/SoftfusionCalibration.h @@ -254,7 +254,6 @@ class SoftfusionCalibrator : public CalibrationBase { calibration.type = SlimeVR::Configuration::SensorConfigType::SFUSION; calibration.data.sfusion = this->calibration; configuration.setSensor(sensorId, calibration); - configuration.save(); } void calibrateGyroOffset() { diff --git a/src/sensors/softfusion/runtimecalibration/RuntimeCalibration.h b/src/sensors/softfusion/runtimecalibration/RuntimeCalibration.h index 0fa1a5306..1269868b7 100644 --- a/src/sensors/softfusion/runtimecalibration/RuntimeCalibration.h +++ b/src/sensors/softfusion/runtimecalibration/RuntimeCalibration.h @@ -315,7 +315,6 @@ class RuntimeCalibrator : public Sensors::CalibrationBase { = SlimeVR::Configuration::SensorConfigType::RUNTIME_CALIBRATION; calibration.data.runtimeCalibration = this->calibration; configuration.setSensor(sensorId, calibration); - configuration.save(); } enum class CalibrationPrintFlags { From 01652674392c100aa2309cb475c69262809e2692 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Thu, 9 Jul 2026 21:31:03 +0200 Subject: [PATCH 14/16] fix format --- src/configuration/Configuration.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index 1c168ee43..2ae06b18c 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -236,10 +236,11 @@ void Configuration::reset() { m_Config.version = CURRENT_CONFIGURATION_VERSION; m_ConfigChanged = true; // Todo: - // - we dont want to save the old tracker configuration. As it would defeat the purpus of the reset. - // Also not clear if we realy need to save the basic configuration, till a command it changed again. - // But this also means the the after a reset we need to restart a tracker to activate the - // new configuration on the sensor. The sensorconfig is not cleared on the sensor + // - we dont want to save the old tracker configuration. As it would defeat the + // purpus of the reset. Also not clear if we realy need to save the basic + // configuration, till a command it changed again. But this also means the the after + // a reset we need to restart a tracker to activate the new configuration on the + // sensor. The sensorconfig is not cleared on the sensor saveNeeded = true; m_Logger.debug("Reset configuration"); From bad9af7771b6fa29a7d28a04ca7af33fb4d1a895 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Sun, 12 Jul 2026 02:34:55 +0200 Subject: [PATCH 15/16] feat benchmark enable/disable trough serial --- src/debugging/Benchmark.cpp | 42 +++++++++++++++++++++++------------ src/debugging/Benchmark.h | 4 ++++ src/serial/serialcommands.cpp | 22 ++++++++++++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/debugging/Benchmark.cpp b/src/debugging/Benchmark.cpp index ac2139db2..ac8ec8d2d 100644 --- a/src/debugging/Benchmark.cpp +++ b/src/debugging/Benchmark.cpp @@ -1,40 +1,57 @@ #include "Benchmark.h" -#include "../debug.h" - -#if DEBUG_MEASURE_TIME_TAKEN #include -#endif + +#include "../debug.h" namespace SlimeVR::Debugging { Benchmark::Benchmark(const char* name) : name{name} {} +void Benchmark::enable() { + lastReportMillis = millis(); + totalLoops = 0; + enabled = true; +} + +void Benchmark::disable() { + for (auto* instance : benchmarkInstances) { + instance->reset(); + } + enabled = false; +} + +bool Benchmark::status() { return enabled; } + void Benchmark::before() { -#if DEBUG_MEASURE_TIME_TAKEN + if (!enabled) { + return; + } if (!registered) { benchmarkInstances.push_back(this); registered = true; } currentMeasurementStartMicros = micros(); -#endif } void Benchmark::after() { -#if DEBUG_MEASURE_TIME_TAKEN + if (!enabled) { + return; + } auto timeTakenMicros = micros() - currentMeasurementStartMicros; totalTimeTakenMicros += timeTakenMicros; minTimeTakenMicros = std::min(minTimeTakenMicros, timeTakenMicros); maxTimeTakenMicros = std::max(maxTimeTakenMicros, timeTakenMicros); measurementCount++; -#endif } void Benchmark::tick() { -#if DEBUG_MEASURE_TIME_TAKEN + if (!enabled) { + return; + } totalLoops++; auto timeSinceLastReport = millis() - lastReportMillis; @@ -57,11 +74,9 @@ void Benchmark::tick() { lastReportMillis = millis(); totalLoops = 0; -#endif } void Benchmark::printReport() const { -#if DEBUG_MEASURE_TIME_TAKEN if (measurementCount == 0) { return; } @@ -86,16 +101,13 @@ void Benchmark::printReport() const { timeSinceLastReport, measurementCount ); -#endif } void Benchmark::reset() { -#if DEBUG_MEASURE_TIME_TAKEN totalTimeTakenMicros = 0; minTimeTakenMicros = std::numeric_limits::max(); maxTimeTakenMicros = 0; measurementCount = 0; -#endif } uint32_t Benchmark::lastReportMillis = millis(); @@ -106,4 +118,6 @@ SlimeVR::Logging::Logger Benchmark::logger("Benchmark"); uint32_t Benchmark::totalLoops = 0; +bool Benchmark::enabled = DEBUG_MEASURE_TIME_TAKEN; + } // namespace SlimeVR::Debugging diff --git a/src/debugging/Benchmark.h b/src/debugging/Benchmark.h index 93e2876b7..086db5b21 100644 --- a/src/debugging/Benchmark.h +++ b/src/debugging/Benchmark.h @@ -45,6 +45,9 @@ class Benchmark { void before(); void after(); static void tick(); + static void enable(); + static void disable(); + static bool status(); private: static constexpr float ReportsIntervalSeconds = 10.0f; @@ -67,6 +70,7 @@ class Benchmark { static SlimeVR::Logging::Logger logger; static std::vector benchmarkInstances; static uint32_t totalLoops; + static bool enabled; }; } // namespace SlimeVR::Debugging diff --git a/src/serial/serialcommands.cpp b/src/serial/serialcommands.cpp index 8a34876b1..e84ef632e 100644 --- a/src/serial/serialcommands.cpp +++ b/src/serial/serialcommands.cpp @@ -25,6 +25,7 @@ #include +#include "../debugging/Benchmark.h" #include "GlobalVars.h" #include "base64.hpp" #include "batterymonitor.h" @@ -158,6 +159,20 @@ void cmdSet(CmdParser* parser) { wifiNetwork.setWiFiCredentials(ssid, ppass); logger.info("CMD SET BWIFI OK: New wifi credentials set, reconnecting"); } + } else if (parser->equalCmdParam(1, "BENCHMARK")) { + if (parser->getParamCount() < 3) { + logger.error("CMD SET BENCHMARK ERROR: Too few arguments"); + logger.info("Syntax: SET BENCHMARK ON/OFF"); + } else if (parser->equalCmdParam(2, "ON")) { + SlimeVR::Debugging::Benchmark::enable(); + logger.info("CMD SET BENCHMARK ON"); + } else if (parser->equalCmdParam(2, "OFF")) { + SlimeVR::Debugging::Benchmark::disable(); + logger.info("CMD SET BENCHMARK OFF"); + } else { + logger.error("CMD SET BENCHMARK ERROR: Invalid argument"); + logger.info("Syntax: SET BENCHMARK ON/OFF"); + } } else { logger.error("CMD SET ERROR: Unrecognized variable to set"); } @@ -370,6 +385,13 @@ void cmdGet(CmdParser* parser) { WiFi.begin(); } } + + if (parser->equalCmdParam(1, "BENCHMARK")) { + logger.info( + "Benchmark is %s", + SlimeVR::Debugging::Benchmark::status() ? "enabled" : "disabled" + ); + } } void cmdReboot(CmdParser* parser) { From 09c26f81438b605e9f254c7e48f1010a600c1dcf Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:54:49 +0200 Subject: [PATCH 16/16] Some spell checking --- src/configuration/Configuration.cpp | 20 ++++++++++---------- src/sensors/mpu6050sensor.cpp | 2 +- src/serial/serialcommands.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/configuration/Configuration.cpp b/src/configuration/Configuration.cpp index 2ae06b18c..06b707e3b 100644 --- a/src/configuration/Configuration.cpp +++ b/src/configuration/Configuration.cpp @@ -112,10 +112,10 @@ void Configuration::setup() { // Constant called function // Should do the following: -// - Check if a config is flaged to change (well or check the flag for that) -// - Updaten after processig the flag if it is no changes left to save -// - make a minimal delay in between saves of files to limit the impact of multi config -// file saves +// - Check if a config is flagged to be saved. +// - after processing that one flag, check if there is a other config to save. +// - make a minimal delay in between saves of files, to limit the impact of multi +// config file saves void Configuration::tick() { if (saveNeeded && ((lastsave + delaysave) < millis())) { bool saved = false; @@ -236,11 +236,11 @@ void Configuration::reset() { m_Config.version = CURRENT_CONFIGURATION_VERSION; m_ConfigChanged = true; // Todo: - // - we dont want to save the old tracker configuration. As it would defeat the - // purpus of the reset. Also not clear if we realy need to save the basic - // configuration, till a command it changed again. But this also means the the after + // - we don't want to save the old tracker configuration. As it would defeat the + // purpose of the reset. Also not clear if we really need to save the basic + // configuration, until a command changes it again. But this also means, after // a reset we need to restart a tracker to activate the new configuration on the - // sensor. The sensorconfig is not cleared on the sensor + // sensor. The sensorconfig is not cleared in the running class. saveNeeded = true; m_Logger.debug("Reset configuration"); @@ -308,8 +308,8 @@ void Configuration::setSensorToggles( // eraseSensors() // Removes the Configuration: -// m_Sensors from Configuration, but it leaves a active copy on -// the Sensors itself. To make a change after eraseSensors the trackern +// m_Sensors from Configuration, but it leaves an active copy on +// the Sensors itself. To make a change after eraseSensors the tracker // needs to be rebooted. Only then the Sensors are reinitialized void Configuration::eraseSensors() { m_Sensors.clear(); diff --git a/src/sensors/mpu6050sensor.cpp b/src/sensors/mpu6050sensor.cpp index 0c4a83b70..e6d7cfb64 100644 --- a/src/sensors/mpu6050sensor.cpp +++ b/src/sensors/mpu6050sensor.cpp @@ -228,7 +228,7 @@ void MPU6050Sensor::startCalibration(int calibrationType) { SlimeVR::Configuration::SensorConfig calibration; calibration.type = SlimeVR::Configuration::SensorConfigType::MPU6050; calibration.data.mpu6050 = m_Config; - // TODO: setCalibration does nolonger exist. + // TODO: setCalibration does no longer exist. // that code branch is only enabled when trying to compile with // IMU_MPU6050_RUNTIME_CALIBRATION configuration.setCalibration(sensorId, calibration); diff --git a/src/serial/serialcommands.cpp b/src/serial/serialcommands.cpp index e84ef632e..160a3114a 100644 --- a/src/serial/serialcommands.cpp +++ b/src/serial/serialcommands.cpp @@ -481,8 +481,8 @@ void cmdScanI2C(CmdParser* parser) { #endif void cmdConfig(CmdParser* parser) { - // The current implementation of config alloes only to print its value - // For future i want it to implement: + // The current implementation of config allows only to print its value + // For the future, I want it to support: // - IP Configuration / DHCP // - LED Settings // - Sensor Settings (changing sensor parameters)