gps related minor fixes

This commit is contained in:
Mikkeli Matlock
2026-02-09 17:48:38 +09:00
parent 47b3427e63
commit a46496d688
4 changed files with 16 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ class GPSService:
# Periodic status logging # Periodic status logging
self._last_status_log = 0.0 self._last_status_log = 0.0
self._last_state_emit = 0.0
self._fix_count = 0 self._fix_count = 0
def set_on_data(self, callback): def set_on_data(self, callback):
@@ -165,11 +166,20 @@ class GPSService:
timeout_s = "120s" if not self._has_ever_fixed else "10s" timeout_s = "120s" if not self._has_ever_fixed else "10s"
print(f"[GPS] No GPS fix after {timeout_s}, will retry connection") print(f"[GPS] No GPS fix after {timeout_s}, will retry connection")
raise ConnectionError("No GPS fix within timeout") 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 continue # Skip empty fixes
# Got real data — mark first fix, reset timeout to shorter window # Got real data — mark first fix, reset timeout to shorter window
if not self._has_ever_fixed: if not self._has_ever_fixed:
self._has_ever_fixed = True self._has_ever_fixed = True
self._last_state_emit = 0.0 # Force immediate emit on transition
print("[GPS] First fix acquired") print("[GPS] First fix acquired")
fix_timeout = time.time() + 10.0 # 10s timeout for signal loss fix_timeout = time.time() + 10.0 # 10s timeout for signal loss

View File

@@ -140,6 +140,10 @@ def on_arduino_data(data):
data = dict(data) # Don't mutate original data = dict(data) # Don't mutate original
data["theme_switch"] = gpio.theme_switch data["theme_switch"] = gpio.theme_switch
# backend voltage offset correction
if "voltage" in data:
data["voltage"] += 0.2 # Calibration offset
def emit_fn(d): def emit_fn(d):
socketio.emit("arduino", d) socketio.emit("arduino", d)

View File

@@ -61,7 +61,7 @@ class GpsCompass extends StatelessWidget {
_hasSignal ? "${_displayHeading} ${_compassDirection}" : (_isAcquiring ? "ACQ" : "N/A"), _hasSignal ? "${_displayHeading} ${_compassDirection}" : (_isAcquiring ? "ACQ" : "N/A"),
style: TextStyle( style: TextStyle(
fontSize: 80, fontSize: 80,
color: theme.subdued, color: theme.subdued, // less emphasis on text, let the icon have semantic colour
fontFamily: 'DIN1451', fontFamily: 'DIN1451',
), ),
), ),

View File

@@ -70,7 +70,7 @@ class SystemBar extends StatelessWidget {
value: gpsState == 'acquiring' ? 'ACQ' value: gpsState == 'acquiring' ? 'ACQ'
: gpsState == 'fix' ? (gpsSatellites?.toString() ?? 'N/A') : gpsState == 'fix' ? (gpsSatellites?.toString() ?? 'N/A')
: '0', // lost or unknown : '0', // lost or unknown
isAbnormal: gpsState != 'fix', isAbnormal: gpsState != 'fix' || gpsSatellites == null,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
labelSize: labelSize, labelSize: labelSize,
valueSize: valueSize, valueSize: valueSize,