From b865ac6c23f3d135770cf95904722e8a89c5c0c7 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 20 Jun 2025 13:44:58 +1000 Subject: [PATCH] * refactored SensorManager::toggleGps() --- examples/companion_radio/UITask.cpp | 13 ++++++++++++- src/helpers/SensorManager.h | 2 -- variants/t1000-e/target.h | 2 -- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index 3e477fe9..f57d5f80 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -388,7 +388,18 @@ void UITask::handleButtonTriplePress() { void UITask::handleButtonQuadruplePress() { MESH_DEBUG_PRINTLN("UITask: quad press triggered"); if (_sensors != NULL) { - _sensors->toggleGps(); + // toggle GPS onn/off + int num = _sensors->getNumSettings(); + for (int i = 0; i < num; i++) { + if (strcmp(_sensors->getSettingName(i), "gps") == 0) { + if (strcmp(_sensors->getSettingValue(i), "1") == 0) { + _sensors->setSettingValue("gps", "0"); + } else { + _sensors->setSettingValue("gps", "1"); + } + break; + } + } } _need_refresh = true; } diff --git a/src/helpers/SensorManager.h b/src/helpers/SensorManager.h index 6ef1192a..0e4bc27d 100644 --- a/src/helpers/SensorManager.h +++ b/src/helpers/SensorManager.h @@ -21,6 +21,4 @@ public: virtual const char* getSettingName(int i) const { return NULL; } virtual const char* getSettingValue(int i) const { return NULL; } virtual bool setSettingValue(const char* name, const char* value) { return false; } - virtual bool getGpsStatus() { return false; } - virtual bool toggleGps() { return false; } }; diff --git a/variants/t1000-e/target.h b/variants/t1000-e/target.h index 221db614..855c4d67 100644 --- a/variants/t1000-e/target.h +++ b/variants/t1000-e/target.h @@ -28,8 +28,6 @@ public: const char* getSettingName(int i) const override; const char* getSettingValue(int i) const override; bool setSettingValue(const char* name, const char* value) override; - bool getGpsStatus() override { return gps_active; } - bool toggleGps() override { gps_active ? sleep_gps() : start_gps(); return gps_active; } }; #ifdef DISPLAY_CLASS