feat(trail): record altitude in trail points

Each point keeps the GPS altitude in what was padding, so a point stays
16 bytes. The save format goes to version 2; version 1 files still load,
with the altitude unknown. GPX export writes <ele>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-02 19:24:36 +02:00
co-authored by Claude Opus 5.5
parent 2589fe95ce
commit 0bbf2fa2b3
5 changed files with 43 additions and 21 deletions
@@ -31,6 +31,15 @@ public:
return false;
}
// Current GPS altitude in metres, false without a fix.
bool currentAltitude(int16_t& m) const {
LocationProvider* loc = _sensors ? _sensors->getLocationProvider() : nullptr;
if (!loc || !loc->isValid()) return false;
long a = loc->getAltitude() / 1000; // the provider reports millimetres
m = (int16_t)(a < -32000 ? -32000 : a > 32000 ? 32000 : a);
return true;
}
// Current course over ground in degrees (0..359), or false if not enough
// recent movement to derive a stable heading. Holds the last good heading
// while standing still.
@@ -47,8 +47,10 @@ public:
} else if (_trail.isPaused()) {
_trail.setPaused(false); // feature turned off → resume
}
int16_t alt = TRAIL_ALT_NONE;
_course->currentAltitude(alt);
if (!_trail.isPaused())
_trail.addPoint(la, lo, (uint32_t)rtc_clock.getCurrentTime(), md);
_trail.addPoint(la, lo, (uint32_t)rtc_clock.getCurrentTime(), md, alt);
}
// True while a trail is recording and not auto-paused (needs live GPS).