From a46496d68878a8e69f7a603e1b2ca5f0142a2506 Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Mon, 9 Feb 2026 17:48:38 +0900 Subject: [PATCH] gps related minor fixes --- pi/backend/gps_service.py | 10 ++++++++++ pi/backend/main.py | 4 ++++ pi/ui/lib/widgets/gps_compass.dart | 2 +- pi/ui/lib/widgets/system_bar.dart | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pi/backend/gps_service.py b/pi/backend/gps_service.py index c2cc4d7..70b369a 100644 --- a/pi/backend/gps_service.py +++ b/pi/backend/gps_service.py @@ -45,6 +45,7 @@ class GPSService: # Periodic status logging self._last_status_log = 0.0 + self._last_state_emit = 0.0 self._fix_count = 0 def set_on_data(self, callback): @@ -165,11 +166,20 @@ class GPSService: timeout_s = "120s" if not self._has_ever_fixed else "10s" print(f"[GPS] No GPS fix after {timeout_s}, will retry connection") raise ConnectionError("No GPS fix within timeout") + # Emit state periodically so UI knows we're alive + now = time.time() + if now - self._last_state_emit >= 5.0: + self._last_state_emit = now + with self._lock: + self._latest = fix + if self._on_data_callback: + self._on_data_callback(fix) continue # Skip empty fixes # Got real data — mark first fix, reset timeout to shorter window if not self._has_ever_fixed: self._has_ever_fixed = True + self._last_state_emit = 0.0 # Force immediate emit on transition print("[GPS] First fix acquired") fix_timeout = time.time() + 10.0 # 10s timeout for signal loss diff --git a/pi/backend/main.py b/pi/backend/main.py index d6b7a76..c6974fb 100644 --- a/pi/backend/main.py +++ b/pi/backend/main.py @@ -139,6 +139,10 @@ def on_arduino_data(data): # Always include current GPIO state (UI dedupes) data = dict(data) # Don't mutate original data["theme_switch"] = gpio.theme_switch + + # backend voltage offset correction + if "voltage" in data: + data["voltage"] += 0.2 # Calibration offset def emit_fn(d): socketio.emit("arduino", d) diff --git a/pi/ui/lib/widgets/gps_compass.dart b/pi/ui/lib/widgets/gps_compass.dart index a2b0460..d244177 100644 --- a/pi/ui/lib/widgets/gps_compass.dart +++ b/pi/ui/lib/widgets/gps_compass.dart @@ -61,7 +61,7 @@ class GpsCompass extends StatelessWidget { _hasSignal ? "${_displayHeading} ${_compassDirection}" : (_isAcquiring ? "ACQ" : "N/A"), style: TextStyle( fontSize: 80, - color: theme.subdued, + color: theme.subdued, // less emphasis on text, let the icon have semantic colour fontFamily: 'DIN1451', ), ), diff --git a/pi/ui/lib/widgets/system_bar.dart b/pi/ui/lib/widgets/system_bar.dart index 6344fb0..c8b9b32 100644 --- a/pi/ui/lib/widgets/system_bar.dart +++ b/pi/ui/lib/widgets/system_bar.dart @@ -70,7 +70,7 @@ class SystemBar extends StatelessWidget { value: gpsState == 'acquiring' ? 'ACQ' : gpsState == 'fix' ? (gpsSatellites?.toString() ?? 'N/A') : '0', // lost or unknown - isAbnormal: gpsState != 'fix', + isAbnormal: gpsState != 'fix' || gpsSatellites == null, alignment: Alignment.centerLeft, labelSize: labelSize, valueSize: valueSize,