mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 02:06:11 +00:00
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:
co-authored by
Claude Sonnet 4.6
parent
1521be3803
commit
151892e1ce
@@ -1519,17 +1519,15 @@ void UITask::shutdown(bool restart){
|
||||
} else {
|
||||
_display->turnOff();
|
||||
radio_driver.powerOff();
|
||||
#ifdef PIN_GPS_EN
|
||||
// Power off GPS before SYSTEMOFF — GPIO pins retain state in NRF52 SYSTEMOFF,
|
||||
// so without this the GPS stays powered and drains the battery.
|
||||
// gps_enabled is already persisted to flash; applyGpsPrefs() restores it on next boot.
|
||||
// Use the same active level as MicroNMEALocationProvider::stop() (default active-high).
|
||||
#ifndef PIN_GPS_EN_ACTIVE
|
||||
#define PIN_GPS_EN_ACTIVE HIGH
|
||||
#endif
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
#endif
|
||||
// Power GPS down through its provider before SYSTEMOFF — GPIO pins retain
|
||||
// state in NRF52 SYSTEMOFF, so otherwise the module keeps draining the
|
||||
// battery. The provider handles the enable + reset pins and the correct
|
||||
// active level. gps_enabled is persisted; applyGpsPrefs() restores it on
|
||||
// the next boot.
|
||||
if (_sensors) {
|
||||
LocationProvider* loc = _sensors->getLocationProvider();
|
||||
if (loc) loc->stop();
|
||||
}
|
||||
_board->powerOff();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user