From b12d5a8705aa5a4814b482564f256f86f2acdf07 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 25 May 2026 10:26:33 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui):=20trail=20=E2=80=94=20surface=20"wait?= =?UTF-8?q?ing=20for=20GPS=20fix"=20state=20on=20start?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two visible cues when the user starts tracking without a fix: 1. The Enter alert now reads "Waiting for GPS fix" instead of "Tracking started" when the LocationProvider isn't valid at the moment of toggling. Tracking is still armed — sampling starts as soon as the GPS lock comes up. 2. The Summary Status field shows "waiting fix" while active and the ring is still empty (no point ever sampled). It flips to "tracking" once the first point lands. The detection is "any point recorded yet?" rather than "is the fix valid right this second", which is stable across the cadence of UITask::loop sampling. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/TrailScreen.h | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/ui-new/TrailScreen.h b/examples/companion_radio/ui-new/TrailScreen.h index 7bff24a8..7081169a 100644 --- a/examples/companion_radio/ui-new/TrailScreen.h +++ b/examples/companion_radio/ui-new/TrailScreen.h @@ -62,20 +62,40 @@ public: if (_view == V_LIST && c == KEY_UP && _list_scroll > 0) { _list_scroll--; return true; } if (_view == V_LIST && c == KEY_DOWN) { _list_scroll++; return true; } // clamped on render if (c == KEY_ENTER) { - _store->setActive(!_store->isActive()); - _task->showAlert(_store->isActive() ? "Tracking started" : "Tracking stopped", 800); + bool now_active = !_store->isActive(); + _store->setActive(now_active); + if (now_active) { + _task->showAlert(gpsHasFix() ? "Tracking started" : "Waiting for GPS fix", 1000); + } else { + _task->showAlert("Tracking stopped", 800); + } return true; } return false; } + // True when the global SensorManager has a usable GPS fix. + static bool gpsHasFix() { +#if ENV_INCLUDE_GPS == 1 + LocationProvider* loc = sensors.getLocationProvider(); + return loc && loc->isValid(); +#else + return false; +#endif + } + private: // Format the i-th summary line into buf. Indices match SUMMARY_ITEM_COUNT. void summaryItem(int i, char* buf, size_t n) const { switch (i) { - case 0: - snprintf(buf, n, "Status: %s", _store->isActive() ? "tracking" : "stopped"); + case 0: { + const char* st; + if (!_store->isActive()) st = "stopped"; + else if (_store->empty()) st = "waiting fix"; + else st = "tracking"; + snprintf(buf, n, "Status: %s", st); break; + } case 1: snprintf(buf, n, "Points: %d / %d", _store->count(), TrailStore::CAPACITY); break;