mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
fix: GPS shutdown active-level, buzzer octave-8 consistency, waypoint header read checks
- UITask::shutdown(): power GPS off using !PIN_GPS_EN_ACTIVE instead of hardcoded LOW, matching MicroNMEALocationProvider::stop() (still LOW on current active-high devices, but correct for a future active-low GPS). - buzzer _noteFreq(): clamp octave to 8 instead of 7 so the parser's accepted range (4-8) is fully consumed; previously an octave-8 digit was clamped away and could leak into the stream as the next note's duration. - Waypoint::readFrom(): check read() return for version/reserved/count header bytes so a truncated file is rejected instead of using garbage count. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,9 +74,9 @@ public:
|
||||
if (magic != SAVE_MAGIC) return false;
|
||||
uint8_t ver = 0, res = 0;
|
||||
uint16_t cnt = 0;
|
||||
file.read(&ver, 1);
|
||||
file.read(&res, 1);
|
||||
file.read((uint8_t*)&cnt, sizeof(cnt));
|
||||
if (file.read(&ver, 1) != 1) return false;
|
||||
if (file.read(&res, 1) != 1) return false;
|
||||
if (file.read((uint8_t*)&cnt, sizeof(cnt)) != (int)sizeof(cnt)) return false;
|
||||
if (ver != SAVE_VERSION) return false;
|
||||
if (cnt > CAPACITY) cnt = CAPACITY;
|
||||
_count = 0;
|
||||
|
||||
@@ -1523,8 +1523,12 @@ void UITask::shutdown(bool restart){
|
||||
// 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, LOW);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
#endif
|
||||
_board->powerOff();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user