feat(trail): auto-save GPS trail on shutdown (Trail settings toggle)

Losing the whole route on a low-battery auto-shutdown was the worst solo-mode
failure. New NodePrefs::trail_autosave_lowbatt toggle (Tools > Trail >
Settings > Auto-save, default OFF): UITask::shutdown() writes the live trail
to /trail when the toggle is on and _trail.count() > 0. The count guard stops
an empty trail from wiping a previously saved one; it overwrites the same
/trail file the manual Trail > Save uses.

Schema bumped 0xC0DE001A -> 0xC0DE001B: append-only tail field with a load
clamp, so pre-0x1B saves default to off. sizeof(NodePrefs) is unchanged (the
byte fits existing padding after keyboard_type), so the tripwire assert stays
2496.

Builds green: WioTrackerL1_companion_solo_dual (RAM 69.9%, Flash 62.8%).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-07-05 22:21:42 +02:00
co-authored by Claude Opus 4.8
parent 046c2f258e
commit 9ee199e641
4 changed files with 34 additions and 2 deletions
@@ -1927,6 +1927,19 @@ bool UITask::savePrefsIfDirty(bool& dirty) {
void UITask::shutdown(bool restart){
the_mesh.saveRTCTime();
// Auto-save the live GPS trail before power-off when the user enabled it
// (Tools Trail Settings Auto-save). This covers the low-battery
// auto-shutdown, which otherwise loses the whole route. Overwrites /trail
// (same file as the manual Trail Save); guarded on count()>0 so an empty
// trail can't wipe a previously saved one.
if (_node_prefs && _node_prefs->trail_autosave_lowbatt && _trail.count() > 0) {
DataStore* ds = the_mesh.getDataStore();
if (ds) {
File f = ds->openWrite("/trail");
if (f) { _trail.writeTo(f); f.close(); }
}
}
#ifdef PIN_BUZZER
/* note: we have a choice here -
we can do a blocking buzzer.loop() with non-deterministic consequences