The new flight screen (lib/ui/fly/fly_screen.dart) is built from layers. Each readout listens to its own telemetry sub-model, so a 10 Hz tick only repaints what changed. It adds a status bar with a status chip and tip marquee, a smart battery bar with land/RTH markers, a camera info strip, an attitude ball, an H/D/VS/HS/VPS strip, and a minimap that swaps places with the video when tapped. The HUD is laid out in design pixels and scaled to phone or tablet inside the safe area. What the HUD shows depends on the product: dual or multi battery bars, SSD status, a thermal spot reading, a master/slave RC badge, and Wi-Fi bars in place of RC/HD. The bridges now report the data for these: the camera's ssd/thermal groups and the RC's master/slave mode. The old FlightControlPage can still be opened from Settings > About > Classic flight screen until the P3 safety flows land. The same tab also gets a toggle for the performance overlay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
import 'package:flutter/foundation.dart';
|
||
|
||
import 'parse.dart';
|
||
|
||
/// Radio links and the remote controller's battery. Fed from the `links` and
|
||
/// `rc` groups of the telemetry tick (≤2 Hz).
|
||
class LinkState extends ChangeNotifier {
|
||
/// `ocusync` / `lightbridge` / `wifi` as the air link reports it at runtime.
|
||
String? kind;
|
||
|
||
/// RC → aircraft control-link quality, 0–100.
|
||
int? uplinkQuality;
|
||
|
||
/// Aircraft → RC video-link quality, 0–100.
|
||
int? downlinkQuality;
|
||
|
||
int? rcBatteryPercent;
|
||
int? rcBatteryMah;
|
||
bool? rcCharging;
|
||
|
||
/// `RCMode` name on dual-operator remotes: `MASTER` / `SLAVE` / `NORMAL` …
|
||
String? rcMode;
|
||
bool? masterSlaveConnected;
|
||
|
||
/// "M" / "S" for the HUD's dual-operator badge, null when flying solo.
|
||
String? get rcRoleBadge => switch (rcMode) {
|
||
'MASTER' || 'MASTER_SUB' => 'M',
|
||
'SLAVE' || 'SLAVE_SUB' => 'S',
|
||
_ => null,
|
||
};
|
||
|
||
DateTime? updatedAt;
|
||
|
||
/// 0–5 bars, the way the top bar draws a 0–100 quality.
|
||
static int bars(int? quality) => quality == null ? 0 : ((quality.clamp(0, 100) + 19) ~/ 20);
|
||
|
||
void apply({Map<String, dynamic>? links, Map<String, dynamic>? rc}) {
|
||
kind = asString(links?['kind']);
|
||
uplinkQuality = asInt(links?['uplinkQuality']);
|
||
downlinkQuality = asInt(links?['downlinkQuality']);
|
||
rcBatteryPercent = asInt(rc?['batteryPercent']);
|
||
rcBatteryMah = asInt(rc?['batteryMah']);
|
||
rcCharging = asBool(rc?['isCharging']);
|
||
rcMode = asString(rc?['mode']);
|
||
masterSlaveConnected = asBool(rc?['masterSlaveConnected']);
|
||
updatedAt = DateTime.now();
|
||
notifyListeners();
|
||
}
|
||
|
||
void clear() {
|
||
kind = rcMode = null;
|
||
uplinkQuality = downlinkQuality = rcBatteryPercent = rcBatteryMah = null;
|
||
rcCharging = masterSlaveConnected = null;
|
||
updatedAt = null;
|
||
notifyListeners();
|
||
}
|
||
}
|