55 lines
2.4 KiB
Dart
55 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../services/telemetry_service.dart';
|
|
|
|
class DiagnosticsScreen extends ConsumerWidget {
|
|
const DiagnosticsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final telemetryAsync = ref.watch(telemetryStreamProvider);
|
|
final t = telemetryAsync.value;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Sensor Diagnostics')),
|
|
body: t == null
|
|
? const Center(child: CircularProgressIndicator())
|
|
: ListView(
|
|
padding: const EdgeInsets.all(16.0),
|
|
children: [
|
|
_buildMetric('Timestamp', t.timestamp.toIso8601String()),
|
|
const Divider(),
|
|
const Text('GPS Data', style: TextStyle(color: Colors.cyanAccent, fontWeight: FontWeight.bold)),
|
|
_buildMetric('Latitude', t.latitude?.toString() ?? 'N/A'),
|
|
_buildMetric('Longitude', t.longitude?.toString() ?? 'N/A'),
|
|
_buildMetric('Altitude', t.altitude?.toString() ?? 'N/A'),
|
|
_buildMetric('Speed (m/s)', t.speed?.toString() ?? 'N/A'),
|
|
_buildMetric('Heading', t.heading?.toString() ?? 'N/A'),
|
|
const Divider(),
|
|
const Text('IMU Data', style: TextStyle(color: Colors.cyanAccent, fontWeight: FontWeight.bold)),
|
|
_buildMetric('Accel X (m/s²)', t.accelX?.toStringAsFixed(3) ?? 'N/A'),
|
|
_buildMetric('Accel Y (m/s²)', t.accelY?.toStringAsFixed(3) ?? 'N/A'),
|
|
_buildMetric('Accel Z (m/s²)', t.accelZ?.toStringAsFixed(3) ?? 'N/A'),
|
|
_buildMetric('Longitudinal G', t.longitudinalG?.toStringAsFixed(3) ?? 'N/A'),
|
|
_buildMetric('Lateral G', t.lateralG?.toStringAsFixed(3) ?? 'N/A'),
|
|
_buildMetric('Lean Angle', t.leanAngle?.toStringAsFixed(2) ?? 'N/A'),
|
|
_buildMetric('Pitch Angle', t.pitchAngle?.toStringAsFixed(2) ?? 'N/A'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMetric(String label, String value) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(label, style: const TextStyle(color: Colors.white70)),
|
|
Text(value, style: const TextStyle(fontWeight: FontWeight.bold, fontFamily: 'monospace')),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|