mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 10:16:11 +00:00
fix(ui): show distance to active target on Home map status line
The MAP page status line only ever measured distance to the nearest live-tracked ([LOC]-sharing) contact, ignoring the active Locator/Nav target entirely. A waypoint target isn't a live-tracked contact at all, so after "Set as target" on a waypoint its flag drew fine on the mini-map but the status line below it never showed how far away it was. statusDistanceKm() (renamed from nearestTrackedKm()) now checks activeTargetPos() first — covers both waypoint and person targets — and only falls back to the nearest live-tracked contact when no target is set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d2c9f2e19b
commit
0c46cc5212
@@ -622,9 +622,10 @@ public:
|
|||||||
// Active target flag drawn last so it stays legible even atop a contact/own dot.
|
// Active target flag drawn last so it stays legible even atop a contact/own dot.
|
||||||
if (have_tgt) { int px, py; project(tla, tlo, px, py); miniIconDrawCentered(display, px, py, ICON_MAP_TARGET); }
|
if (have_tgt) { int px, py; project(tla, tlo, px, py); miniIconDrawCentered(display, px, py, ICON_MAP_TARGET); }
|
||||||
|
|
||||||
// Bottom-left scale reference, always shown — distance to the nearest
|
// Bottom-left scale reference, always shown — distance to the active
|
||||||
// live-tracked contact now lives on the status line below instead (see
|
// target (or else the nearest live-tracked contact) now lives on the
|
||||||
// nearestTrackedKm() / render()), so this corner is free for it.
|
// status line below instead (see statusDistanceKm() / render()), so this
|
||||||
|
// corner is free for it.
|
||||||
{
|
{
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
int ty = ay + ah - display.getLineHeight();
|
int ty = ay + ah - display.getLineHeight();
|
||||||
@@ -654,12 +655,17 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distance to the nearest live-tracked ([LOC]-sharing) contact, in km, or
|
// Distance shown on the MAP status line. The active Locator/Nav target
|
||||||
// -1 when we don't have a fix or there's no active share to measure
|
// takes priority — that's what the flag on the mini-map is pointing at,
|
||||||
// against. Shared by the MAP status line (see render()).
|
// and it's the only way a waypoint target ever gets a distance readout
|
||||||
float nearestTrackedKm() {
|
// here (a waypoint isn't a live-tracked contact). Falls back to the
|
||||||
|
// nearest live-tracked ([LOC]-sharing) contact when no target is set.
|
||||||
|
// -1 when we don't have a fix or nothing to measure against.
|
||||||
|
float statusDistanceKm() {
|
||||||
int32_t mla, mlo;
|
int32_t mla, mlo;
|
||||||
if (!_task->currentLocation(mla, mlo)) return -1.0f;
|
if (!_task->currentLocation(mla, mlo)) return -1.0f;
|
||||||
|
int32_t tla, tlo;
|
||||||
|
if (_task->activeTargetPos(tla, tlo)) return geo::haversineKm(mla, mlo, tla, tlo);
|
||||||
LiveTrackStore& lt = _task->liveTrack();
|
LiveTrackStore& lt = _task->liveTrack();
|
||||||
uint32_t now = rtc_clock.getCurrentTime();
|
uint32_t now = rtc_clock.getCurrentTime();
|
||||||
float nearest_km = -1.0f;
|
float nearest_km = -1.0f;
|
||||||
@@ -1084,10 +1090,10 @@ public:
|
|||||||
LiveTrackStore& lt = _task->liveTrack();
|
LiveTrackStore& lt = _task->liveTrack();
|
||||||
int trk = lt.active(now_m);
|
int trk = lt.active(now_m);
|
||||||
// Fix state lives in the top-bar GPS icon. Track count plus an arrow +
|
// Fix state lives in the top-bar GPS icon. Track count plus an arrow +
|
||||||
// distance to the nearest live-tracked contact (when we have both a fix
|
// distance (to the active target, else the nearest live-tracked
|
||||||
// and an active share) share this one status line.
|
// contact) share this one status line.
|
||||||
snprintf(left, sizeof(left), "Track:%d", trk);
|
snprintf(left, sizeof(left), "Track:%d", trk);
|
||||||
float nearest_km = nearestTrackedKm();
|
float nearest_km = statusDistanceKm();
|
||||||
if (nearest_km >= 0.0f) geo::fmtDist(right, sizeof(right), nearest_km, _task->useImperial());
|
if (nearest_km >= 0.0f) geo::fmtDist(right, sizeof(right), nearest_km, _task->useImperial());
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
if (!drew)
|
if (!drew)
|
||||||
|
|||||||
Reference in New Issue
Block a user