From b7e7e945d293ffd335d8a9d70ffba2268da84fb6 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Wed, 24 Jun 2026 16:18:39 +0200 Subject: [PATCH] feat(companion): widen Locator targeting beyond favourites/live-share Locator's person target now resolves any known contact's position, not just an active live [LOC] share: locatorDistance() falls back to the contact's last-advertised gps_lat/gps_lon when there's no current live share, so a rarely-updating but stationary node (a repeater, or someone who shared a fix once) still works as a target. LocatorScreen's target picker is widened to match (favourites always offered, plus every other contact with a currently resolvable position), and shows a compact age tag for non-live entries so staleness is visible. Also adds a quick "Set Locator target" action directly from Nearby Nodes' and Waypoints' own popup menus (UITask::setLocatorTarget()), so picking a target doesn't require a detour through Tools > Locator. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/GeoUtils.h | 13 +++ .../companion_radio/ui-new/LocatorScreen.h | 106 ++++++++++++------ .../companion_radio/ui-new/NearbyScreen.h | 13 ++- examples/companion_radio/ui-new/UITask.cpp | 28 ++++- examples/companion_radio/ui-new/UITask.h | 7 ++ .../companion_radio/ui-new/WaypointsView.h | 12 +- 6 files changed, 138 insertions(+), 41 deletions(-) diff --git a/examples/companion_radio/GeoUtils.h b/examples/companion_radio/GeoUtils.h index 16f1f95d..9f823c11 100644 --- a/examples/companion_radio/GeoUtils.h +++ b/examples/companion_radio/GeoUtils.h @@ -61,6 +61,19 @@ static inline void fmtDist(char* buf, int n, float km, bool imperial) { } } +// Compact age tag for a timestamp, e.g. "12s" / "5m" / "3h" / "2d" — sized to +// sit inline after a name (unlike a full "X ago" sentence). Empty string for +// an unknown (0) or future timestamp. Takes `now` rather than reading the RTC +// itself, so this stays a pure function like the rest of this file. +static inline void fmtAgeShort(char* buf, int n, uint32_t now, uint32_t lastmod) { + if (lastmod == 0 || now < lastmod) { buf[0] = '\0'; return; } + uint32_t age = now - lastmod; + if (age < 60) snprintf(buf, n, "%us", (unsigned)age); + else if (age < 3600) snprintf(buf, n, "%um", (unsigned)(age / 60)); + else if (age < 86400) snprintf(buf, n, "%uh", (unsigned)(age / 3600)); + else snprintf(buf, n, "%ud", (unsigned)(age / 86400)); +} + // Tag marking a shared waypoint inside a message: "[WAY],