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/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<DashboardScreen> {
// From backend - GPS data
double? _gpsSpeed;
double? _gpsTrack;
// Placeholder values for system bar
int? _gpsSatellites;
@@ -105,6 +107,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
_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<DashboardScreen> {
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<DashboardScreen> {
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'),
],
),

View File

@@ -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 ?? "-"}');
}
});

View File

@@ -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',
),