Warning thresholds added in drone profile. traffic light indication in drone satus menue added. layout and content optimized

This commit is contained in:
Constantin Leue
2026-08-05 20:15:18 +02:00
parent f65dceb338
commit 4982341203
8 changed files with 1302 additions and 37 deletions
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../domain/telemetry/drone_event.dart';
import '../../domain/telemetry/drone_status.dart';
import '../../domain/telemetry/telemetry_field_status.dart';
import '../dmc_colors.dart';
import '../providers/active_drone_profile_provider.dart';
import '../providers/drone_event_log_provider.dart';
import '../providers/telemetry_provider.dart';
@@ -109,36 +112,56 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
Widget _statusTab() {
final telemetry = ref.watch(telemetryProvider);
final droneProfile = ref.watch(activeDroneProfileProvider);
return telemetry.when(
data: (frame) => ListView(
padding: const EdgeInsets.all(16),
children: [
_statusRow('GPS satellites', '${frame.numSat}'),
_statusRow(
'GPS precision (HDOP)',
frame.hasFix ? frame.hdop.toStringAsFixed(2) : '—',
),
_statusRow(
'GPS coordinates',
frame.hasFix
? '${frame.lat.toStringAsFixed(6)}, ${frame.lon.toStringAsFixed(6)}'
: '—',
),
_statusRow('Current draw', '${frame.currentA.toStringAsFixed(1)} A'),
_statusRow('Battery voltage', '${frame.batteryVoltage.toStringAsFixed(2)} V'),
_statusRow('Heading', '${frame.headingDeg.round()}°'),
_statusRow('RX quality / SNR', '${frame.linkQuality}% / ${frame.snrDb} dB'),
// Downlink-Qualitaet/-SNR und die Akku-SoC des Sendemoduls selbst
// (nicht der Drohne) sind ueber keinen MSP-GET-Befehl abrufbar -
// rxLinkStatistics_t (iNAV 9.1, rx.h) hat zwar ein downlinkLQ-Feld,
// das wird aber nur per MSP2_COMMON_SET_MSP_RC_LINK_STATS von
// aussen HINEINgeschrieben, nie per GET zurueckgelesen; eine
// Downlink-SNR oder eine Sender-Akkugroesse existiert im Struct
// ueberhaupt nicht (verifiziert im lokalen iNAV-Checkout,
// release/9.1).
_statusRow('TX battery SoC / quality / SNR', 'Not available (not exposed via MSP)'),
],
),
data: (frame) {
final fieldStatus = computeTelemetryFieldStatus(
numSat: frame.numSat,
hasFix: frame.hasFix,
hdop: frame.hdop,
currentA: frame.currentA,
batteryVoltage: frame.batteryVoltage,
linkQuality: frame.linkQuality,
snrDb: frame.snrDb,
profile: droneProfile,
);
return ListView(
padding: const EdgeInsets.all(16),
children: [
// Farbcodierte Felder zuerst (Doku: "drone status felder im
// menue auch farblich kodieren", Schwellwerte je Drohnenprofil -
// siehe computeTelemetryFieldStatus), informelle Felder ohne
// Ampel-Bewertung (Koordinaten/Heading/Alt/Speed) danach.
_statusRow('GPS satellites', '${frame.numSat}', level: fieldStatus.numSat),
_statusRow(
'GPS precision (HDOP)',
frame.hasFix ? frame.hdop.toStringAsFixed(2) : '—',
level: fieldStatus.hdop,
),
_statusRow(
'Current draw',
'${frame.currentA.toStringAsFixed(1)} A',
level: fieldStatus.currentA,
),
_statusRow(
'Battery voltage',
'${frame.batteryVoltage.toStringAsFixed(2)} V',
level: fieldStatus.batteryVoltage,
),
_statusRow('RX quality', '${frame.linkQuality}%', level: fieldStatus.rxQuality),
_statusRow('RX SNR', '${frame.snrDb} dB', level: fieldStatus.rxSnr),
_statusRow(
'GPS coordinates',
frame.hasFix
? '${frame.lat.toStringAsFixed(6)}, ${frame.lon.toStringAsFixed(6)}'
: '—',
),
_statusRow('Heading', '${frame.headingDeg.round()}°'),
_statusRow('Altitude', '${frame.altitudeM.toStringAsFixed(0)} m'),
_statusRow('Speed', '${frame.speedMs.toStringAsFixed(1)} m/s'),
],
);
},
loading: () => const Center(
child: CircularProgressIndicator(color: Color(0xFF4D9DFF)),
),
@@ -148,7 +171,14 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
);
}
Widget _statusRow(String label, String value) {
static const _signalColors = {
SignalLevel.green: DmcColors.flyModeColor,
SignalLevel.yellow: DmcColors.pafAmber,
SignalLevel.red: DmcColors.warnRed,
};
Widget _statusRow(String label, String value, {SignalLevel? level}) {
final valueColor = level != null ? _signalColors[level]! : Colors.white;
return Container(
margin: const EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
@@ -159,7 +189,15 @@ class _DroneStatusWarningsPanelState extends ConsumerState<DroneStatusWarningsPa
child: Row(
children: [
Expanded(child: Text(label, style: const TextStyle(color: Colors.white70))),
Text(value, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
if (level != null) ...[
Container(
width: 8,
height: 8,
margin: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(color: valueColor, shape: BoxShape.circle),
),
],
Text(value, style: TextStyle(color: valueColor, fontWeight: FontWeight.w600)),
],
),
);