refactor(ui): extract shared helpers, dedup screens, GPS shutdown via provider

Pull repeated UI idioms into DisplayDriver and remove duplicated logic:

- DisplayDriver: add drawScrollArrows() and drawInvertedHeader(); replaces 11
  copy-pasted scroll-arrow blocks across 5 screens and 3 inverted title-bar
  blocks (NearbyScreen x2, NavView). Standardises the detail-view separator.
- useImperial(): single source on UITask; NearbyScreen/TrailScreen delegate
  instead of each re-reading NodePrefs.units_imperial.
- NearbyScreen: extract saveSelectedWaypoint() (two identical blocks -> one);
  drop the redundant local label buffer (WaypointStore truncates).
- UITask::shutdown(): power GPS off through LocationProvider::stop() instead of
  poking PIN_GPS_EN directly — centralises enable/reset-pin + active-level logic.

Net -58 lines. Verified: GAT562 (SSD1306) and WioTrackerL1Eink (GxEPD) solo
builds compile clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-14 13:21:59 +02:00
parent 1521be3803
commit 151892e1ce
9 changed files with 76 additions and 134 deletions

View File

@@ -406,11 +406,7 @@ private:
bool ownPos(int32_t& lat, int32_t& lon) const { return _task->currentLocation(lat, lon); }
// Global metric/imperial preference for distance display.
bool useImperial() const {
NodePrefs* p = _task->getNodePrefs();
return p && p->units_imperial;
}
bool useImperial() const { return _task && _task->useImperial(); }
void handleMarkHere() {
int32_t lat, lon;
@@ -683,15 +679,9 @@ private:
display.print(buf);
}
int cw = display.getCharWidth();
if (_summary_scroll > 0) {
display.setCursor(display.width() - cw, y0);
display.print("^");
}
if (_summary_scroll + visible < SUMMARY_ITEM_COUNT) {
display.setCursor(display.width() - cw, y0 + (visible - 1) * step);
display.print("v");
}
display.drawScrollArrows(y0, y0 + (visible - 1) * step,
_summary_scroll > 0,
_summary_scroll + visible < SUMMARY_ITEM_COUNT);
}
void renderList(DisplayDriver& display) {
@@ -743,15 +733,8 @@ private:
display.print(row);
}
int cw = display.getCharWidth();
if (_list_scroll > 0) {
display.setCursor(display.width() - cw, top);
display.print("^");
}
if (_list_scroll + visible < total) {
display.setCursor(display.width() - cw, top + (visible - 1) * step);
display.print("v");
}
display.drawScrollArrows(top, top + (visible - 1) * step,
_list_scroll > 0, _list_scroll + visible < total);
}
void renderMap(DisplayDriver& display) {