From f2c69587eec871212efbf08f10044a874f52a720 Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Sun, 8 Feb 2026 02:27:21 +0900 Subject: [PATCH] ui: gps compass widget visual update --- pi/ui/lib/screens/dashboard_screen.dart | 6 +++++- pi/ui/lib/services/websocket_service.dart | 2 +- pi/ui/lib/widgets/gps_compass.dart | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pi/ui/lib/screens/dashboard_screen.dart b/pi/ui/lib/screens/dashboard_screen.dart index d7b7cad..b75c23d 100644 --- a/pi/ui/lib/screens/dashboard_screen.dart +++ b/pi/ui/lib/screens/dashboard_screen.dart @@ -13,6 +13,7 @@ import '../widgets/system_bar.dart'; import '../widgets/debug_console.dart'; import '../widgets/whiskey_mark.dart'; import '../widgets/accel_graph.dart'; +import '../widgets/gps_compass.dart'; // test service for triggers import '../services/test_flipflop_service.dart'; @@ -55,6 +56,7 @@ class _DashboardScreenState extends State { // From backend - GPS data double? _gpsSpeed; + double? _gpsTrack; // Placeholder values for system bar int? _gpsSatellites; @@ -105,6 +107,7 @@ class _DashboardScreenState extends State { _gpsSub = WebSocketService.instance.gpsStream.listen((data) { setState(() { _gpsSpeed = data.speed; + _gpsTrack = data.track; // Derive satellites from mode (placeholder logic) _gpsSatellites = data.mode == 3 ? 8 : (data.mode == 2 ? 4 : 0); }); @@ -140,6 +143,7 @@ class _DashboardScreenState extends State { final cachedGps = WebSocketService.instance.latestGps; if (cachedGps != null) { _gpsSpeed = cachedGps.speed; + _gpsTrack = cachedGps.track; _gpsSatellites = cachedGps.mode == 3 ? 8 : (cachedGps.mode == 2 ? 4 : 0); } @@ -236,7 +240,7 @@ class _DashboardScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ StatBox(value: _formatInt(_rpm), label: 'RPM', isWarning: () => (_rpm ?? 0) > 4000), - GpsCompass(heading: 147), + GpsCompass(heading: _gpsTrack), StatBox(value: _formatGear(_gear), label: 'GEAR'), ], ), diff --git a/pi/ui/lib/services/websocket_service.dart b/pi/ui/lib/services/websocket_service.dart index 697b881..8b1ccfa 100644 --- a/pi/ui/lib/services/websocket_service.dart +++ b/pi/ui/lib/services/websocket_service.dart @@ -204,7 +204,7 @@ class WebSocketService { final gps = GpsData.fromJson(data); _latestGps = gps; _gpsController.add(gps); - _log('gps: ${gps.speed?.toStringAsFixed(1) ?? "-"}m/s mode${gps.mode ?? "-"}'); + _log('gps: ${gps.speed?.toStringAsFixed(1) ?? "-"}m/s hdg=${gps.track?.round() ?? "-"}° mode${gps.mode ?? "-"}'); } }); diff --git a/pi/ui/lib/widgets/gps_compass.dart b/pi/ui/lib/widgets/gps_compass.dart index 64ad128..32d9945 100644 --- a/pi/ui/lib/widgets/gps_compass.dart +++ b/pi/ui/lib/widgets/gps_compass.dart @@ -10,7 +10,7 @@ class GpsCompass extends StatelessWidget { bool get _hasSignal => heading != null && !heading!.isNaN && heading! >= 0 && heading! < 360; String get _displayHeading { - if (!_hasSignal) return '—°'; + if (!_hasSignal) return '—-'; // Intentional double dash return '${heading!.round()}°'; } @@ -30,12 +30,12 @@ class GpsCompass extends StatelessWidget { Flexible( flex: 3, child: Transform.rotate( - angle: angle, + angle: _hasSignal ? angle : 0, child: FittedBox( fit: BoxFit.contain, child: Icon( - Icons.navigation, - size: 60, + _hasSignal ? Icons.navigation : Icons.navigation_outlined, + size: 80, color: color, ), ), @@ -48,7 +48,7 @@ class GpsCompass extends StatelessWidget { child: Text( _displayHeading, style: TextStyle( - fontSize: 30, + fontSize: 60, color: color, fontFamily: 'DIN1451', ),