ui: gps compass widget visual update

This commit is contained in:
Mikkeli Matlock
2026-02-08 02:27:21 +09:00
parent 324cd5dddc
commit f2c69587ee
3 changed files with 11 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import '../widgets/system_bar.dart';
import '../widgets/debug_console.dart'; import '../widgets/debug_console.dart';
import '../widgets/whiskey_mark.dart'; import '../widgets/whiskey_mark.dart';
import '../widgets/accel_graph.dart'; import '../widgets/accel_graph.dart';
import '../widgets/gps_compass.dart';
// test service for triggers // test service for triggers
import '../services/test_flipflop_service.dart'; import '../services/test_flipflop_service.dart';
@@ -55,6 +56,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
// From backend - GPS data // From backend - GPS data
double? _gpsSpeed; double? _gpsSpeed;
double? _gpsTrack;
// Placeholder values for system bar // Placeholder values for system bar
int? _gpsSatellites; int? _gpsSatellites;
@@ -105,6 +107,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
_gpsSub = WebSocketService.instance.gpsStream.listen((data) { _gpsSub = WebSocketService.instance.gpsStream.listen((data) {
setState(() { setState(() {
_gpsSpeed = data.speed; _gpsSpeed = data.speed;
_gpsTrack = data.track;
// Derive satellites from mode (placeholder logic) // Derive satellites from mode (placeholder logic)
_gpsSatellites = data.mode == 3 ? 8 : (data.mode == 2 ? 4 : 0); _gpsSatellites = data.mode == 3 ? 8 : (data.mode == 2 ? 4 : 0);
}); });
@@ -140,6 +143,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
final cachedGps = WebSocketService.instance.latestGps; final cachedGps = WebSocketService.instance.latestGps;
if (cachedGps != null) { if (cachedGps != null) {
_gpsSpeed = cachedGps.speed; _gpsSpeed = cachedGps.speed;
_gpsTrack = cachedGps.track;
_gpsSatellites = cachedGps.mode == 3 ? 8 : (cachedGps.mode == 2 ? 4 : 0); _gpsSatellites = cachedGps.mode == 3 ? 8 : (cachedGps.mode == 2 ? 4 : 0);
} }
@@ -236,7 +240,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
StatBox(value: _formatInt(_rpm), label: 'RPM', isWarning: () => (_rpm ?? 0) > 4000), StatBox(value: _formatInt(_rpm), label: 'RPM', isWarning: () => (_rpm ?? 0) > 4000),
GpsCompass(heading: 147), GpsCompass(heading: _gpsTrack),
StatBox(value: _formatGear(_gear), label: 'GEAR'), StatBox(value: _formatGear(_gear), label: 'GEAR'),
], ],
), ),

View File

@@ -204,7 +204,7 @@ class WebSocketService {
final gps = GpsData.fromJson(data); final gps = GpsData.fromJson(data);
_latestGps = gps; _latestGps = gps;
_gpsController.add(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 ?? "-"}');
} }
}); });

View File

@@ -10,7 +10,7 @@ class GpsCompass extends StatelessWidget {
bool get _hasSignal => heading != null && !heading!.isNaN && heading! >= 0 && heading! < 360; bool get _hasSignal => heading != null && !heading!.isNaN && heading! >= 0 && heading! < 360;
String get _displayHeading { String get _displayHeading {
if (!_hasSignal) return '°'; if (!_hasSignal) return '-'; // Intentional double dash
return '${heading!.round()}°'; return '${heading!.round()}°';
} }
@@ -30,12 +30,12 @@ class GpsCompass extends StatelessWidget {
Flexible( Flexible(
flex: 3, flex: 3,
child: Transform.rotate( child: Transform.rotate(
angle: angle, angle: _hasSignal ? angle : 0,
child: FittedBox( child: FittedBox(
fit: BoxFit.contain, fit: BoxFit.contain,
child: Icon( child: Icon(
Icons.navigation, _hasSignal ? Icons.navigation : Icons.navigation_outlined,
size: 60, size: 80,
color: color, color: color,
), ),
), ),
@@ -48,7 +48,7 @@ class GpsCompass extends StatelessWidget {
child: Text( child: Text(
_displayHeading, _displayHeading,
style: TextStyle( style: TextStyle(
fontSize: 30, fontSize: 60,
color: color, color: color,
fontFamily: 'DIN1451', fontFamily: 'DIN1451',
), ),