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

@@ -162,6 +162,29 @@ public:
}
}
// Up/down scroll indicators in the right-edge column. top_y is the first
// row's y, bottom_y the last visible row's y. Replaces the 4-line
// setCursor/print("^")/setCursor/print("v") block in every scrollable list.
void drawScrollArrows(int top_y, int bottom_y, bool more_up, bool more_down) {
int x = width() - getCharWidth();
setColor(LIGHT);
if (more_up) { setCursor(x, top_y); print("^"); }
if (more_down) { setCursor(x, bottom_y); print("v"); }
}
// Inverted title bar: light background, dark ellipsized label, then the
// standard separator line. The label is UTF-8 translated by
// drawTextEllipsized. Leaves ink colour LIGHT for following content.
void drawInvertedHeader(const char* label) {
int hdr = headerH();
setColor(LIGHT);
fillRect(0, 0, width(), hdr - 1);
setColor(DARK);
drawTextEllipsized(2, 1, width() - 4, (label && label[0]) ? label : "");
setColor(LIGHT);
fillRect(0, hdr - 1, width(), sepH());
}
// Advance a UTF-8 pointer by one codepoint, returning the decoded value.
// Invalid sequences return 0xFFFD and consume trailing continuation bytes.
static uint32_t decodeCodepoint(const uint8_t*& p) {