diff --git a/emulator/include/Emulator.hpp b/emulator/include/Emulator.hpp index 0a4103ef6..b9c325910 100644 --- a/emulator/include/Emulator.hpp +++ b/emulator/include/Emulator.hpp @@ -84,7 +84,6 @@ class OswEmulator { unsigned long selfWakeUpInMicroseconds = 0; time_t selfWakeUpAtTimestamp = 0; BootReason bootReason = BootReason::undefined; - std::string activityMode = "unknown"; // ImGui and window style / sizes const float guiPadding = 10; diff --git a/emulator/src/Emulator.cpp b/emulator/src/Emulator.cpp index 26488230f..048e61f5f 100644 --- a/emulator/src/Emulator.cpp +++ b/emulator/src/Emulator.cpp @@ -456,20 +456,25 @@ void OswEmulator::renderGUIFrameEmulator() { ImGui::InputInt("Magnetometer Z", &OswHal::getInstance()->devices()->virtualDevice->values.magnetometerZ, 0.1f, 10); ImGui::InputInt("Magnetometer Azimuth", &OswHal::getInstance()->devices()->virtualDevice->values.magnetometerAzimuth, 1, 10); ImGui::InputInt("Steps", (int*) &OswHal::getInstance()->devices()->virtualDevice->values.steps, 1, 10); // Warning - negative values will cause an underflow... ImGui has no conventient way of limiting the input range... - if (ImGui::BeginCombo("Activity", this->activityMode.c_str())) { - if(ImGui::Selectable("still", this->activityMode == "still")) { + // get string to display selected value + const char* str = "unknown"; + OswAccelerationProvider::ActivityMode& activityMode = OswHal::getInstance()->devices()->virtualDevice->values.activityMode; // take reference, for easier access + if(activityMode == OswAccelerationProvider::ActivityMode::STILL) + str = "still"; + else if(activityMode == OswAccelerationProvider::ActivityMode::WALK) + str = "walk"; + else if(activityMode == OswAccelerationProvider::ActivityMode::RUN) + str = "run"; + // display activity mode + if (ImGui::BeginCombo("Activity", str)) { + if(ImGui::Selectable("still", activityMode == OswAccelerationProvider::ActivityMode::STILL)) OswHal::getInstance()->devices()->virtualDevice->values.activityMode = OswAccelerationProvider::ActivityMode::STILL; - this->activityMode = "still"; - } else if(ImGui::Selectable("walk", this->activityMode == "walk")) { + else if(ImGui::Selectable("walk", activityMode == OswAccelerationProvider::ActivityMode::WALK)) OswHal::getInstance()->devices()->virtualDevice->values.activityMode = OswAccelerationProvider::ActivityMode::WALK; - this->activityMode = "walk"; - } else if(ImGui::Selectable("run", this->activityMode == "run")) { + else if(ImGui::Selectable("run", activityMode == OswAccelerationProvider::ActivityMode::RUN)) OswHal::getInstance()->devices()->virtualDevice->values.activityMode = OswAccelerationProvider::ActivityMode::RUN; - this->activityMode = "run"; - } else { + else if(ImGui::Selectable("unknown", activityMode == OswAccelerationProvider::ActivityMode::UNKNOWN)) OswHal::getInstance()->devices()->virtualDevice->values.activityMode = OswAccelerationProvider::ActivityMode::UNKNOWN; - this->activityMode = "unknown"; - } ImGui::EndCombo(); } } else