Skip to content

Commit

Permalink
Display current state; not emulator-state
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmicro committed Sep 10, 2023
1 parent 32b2ca0 commit a0ae581
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 0 additions & 1 deletion emulator/include/Emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 15 additions & 10 deletions emulator/src/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0ae581

Please sign in to comment.