Give the Fly App every remaining GO 4 flight mode and the missing settings

Intelligent modes: Point of Interest (orbit on the map, live radius and
speed), Follow Me (follows the phone), QuickShots on a boxed subject,
Course Lock / Home Lock, Tripod and Cinematic, a Free hyperlapse, and
Waypoints 2.0 for V2-only aircraft. ActiveTrack gains Spotlight Pro and
Circle. Every mode has a first-use tutorial and stops from the rail.
Waypoints can resume an interrupted mission, change cruise speed in
flight and check terrain clearance (Open-Meteo, on tap).

Settings: units, C1/C2 actions, dual-operator master/slave, HDMI/SDI
output, a link spectrum chart, Wi-Fi name and password, aircraft name,
video cache, battery warning history and pairing, non-smart cell
voltages. Calibration: compass interference meter, per-IMU calibration,
lens infinity focus and a first-manual-focus prompt. Also an RTK chip,
gimbal movement presets and motor tuning, Precision Takeoff gated on the
flight controller, and the precise GEO database's server version.

Built and unit/widget-tested only; nothing has flown yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-20 23:06:16 +02:00
1 parent 91ca150a35
commit 636da1ac2c
57 files changed
+5363 -87

No files matched your search

@@ -214,6 +214,41 @@ class KeyReadoutSpec extends SettingSpec {
}
}
/// A string the pilot types (aircraft name, a remote's name). [secret] masks
/// it and never shows the stored value; [maxLength] caps what is typed;
/// [send] replaces the plain `setKey` for values the SDK only takes through a
/// bespoke method.
class KeyTextSpec extends SettingSpec {
const KeyTextSpec({
required super.id,
required super.label,
required DjiKey key,
this.secret = false,
this.maxLength = 32,
this.send,
super.hint,
super.requires,
super.visibleWhen,
super.groundOnly,
}) : _key = key;
final DjiKey _key;
final bool secret;
final int maxLength;
final Future<void> Function(DjiService dji, String value)? send;
@override
DjiKey get key => _key;
String? current(KeyState s) => asString(s.value(_key));
String shown(KeyState s) {
final String? v = current(s);
if (secret) return v == null || v.isEmpty ? '—' : '••••••';
return v == null || v.isEmpty ? '—' : v;
}
}
/// A button that runs an argument-less action key (`START_PAIRING`).
class KeyActionSpec extends SettingSpec {
const KeyActionSpec({
@@ -295,6 +330,35 @@ String formatValue(Object? v) => switch (v) {
/// `≈ 394 ft` for [m] metres.
String feetHint(int m) => '≈ ${(m * 3.28084).round()} ft';
/// One battery `WarningRecord` (as `KeyBridge.kt` maps it) → what went wrong.
String formatWarningRecord(Object? v) {
final Map<String, dynamic>? m = asMap(v);
if (m == null) return formatValue(v);
final List<String> found = <String>[
if (asBool(m['overCurrent']) == true) 'over-current',
if (asBool(m['overHeated']) == true) 'overheated',
if (asBool(m['lowTemperature']) == true) 'too cold',
if (asBool(m['shortCircuit']) == true) 'short circuit',
if (asBool(m['underVoltage']) == true) 'under-voltage',
if ((asInt(m['lowVoltageCell']) ?? 0) > 0) 'low cell ${asInt(m['lowVoltageCell'])}',
if ((asInt(m['damagedCell']) ?? 0) > 0) 'damaged cell ${asInt(m['damagedCell'])}',
];
if (found.isEmpty) return asBool(m['error']) == true ? 'Error' : 'None';
return found.join(', ');
}
/// A list of `WarningRecord`s → how many flights had a warning, and the worst.
String formatWarningHistory(Object? v) {
if (v is! List) return formatValue(v);
if (v.isEmpty) return 'None';
final List<String> bad = <String>[
for (final Object? r in v)
if (formatWarningRecord(r) case final String s when s != 'None') s,
];
if (bad.isEmpty) return 'None in ${v.length} records';
return '${bad.length} of ${v.length}: ${bad.first}';
}
/// Millivolt cell list → `3.85 3.86 3.84 V`.
String formatCells(Object? v) {
if (v is! List || v.isEmpty) return '—';
+295 -1
View File
@@ -31,6 +31,7 @@ abstract final class SettingsKeys {
static const DjiKey lowBattery = DjiKey.flightController('LOW_BATTERY_WARNING_THRESHOLD');
static const DjiKey criticalBattery = DjiKey.flightController('SERIOUS_LOW_BATTERY_WARNING_THRESHOLD');
static const DjiKey fcSerial = DjiKey.flightController('SERIAL_NUMBER');
static const DjiKey aircraftName = DjiKey.flightController('AIRCRAFT_NAME');
// Flight assistant (vision)
static const DjiKey collision = DjiKey.flightAssistant('COLLISION_AVOIDANCE_ENABLED');
@@ -56,6 +57,25 @@ abstract final class SettingsKeys {
static const DjiKey rcName = DjiKey.remoteController('DISPLAY_NAME');
static const DjiKey rcSerial = DjiKey.remoteController('SERIAL_NUMBER');
static const DjiKey rcFirmware = DjiKey.remoteController('FIRMWARE_VERSION');
static const DjiKey customButton1 = DjiKey.remoteController('CUSTOM_BUTTON_1');
// Dual operator (master / slave)
static const DjiKey rcRole = DjiKey.remoteController('MODE');
static const DjiKey rcLinkName = DjiKey.remoteController('NAME');
static const DjiKey rcLinkPassword = DjiKey.remoteController('PASSWORD');
static const DjiKey masterSlaveSupported = DjiKey.remoteController('IS_MASTER_SLAVE_MODE_SUPPORTED');
static const DjiKey masterSlaveState = DjiKey.remoteController('MASTER_SLAVE_STATE');
// Secondary video output (Lightbridge remotes / CrystalSky HDMI, Cendence SDI)
static const DjiKey secondaryOut = DjiKey.remoteController('SECONDARY_VIDEO_OUTPUT_ENABLED');
static const DjiKey secondaryPort = DjiKey.remoteController('SECONDARY_VIDEO_OUTPUT_PORT');
static const DjiKey secondaryDisplay = DjiKey.remoteController('SECONDARY_VIDEO_DISPLAY_MODE');
static const DjiKey secondaryOsd = DjiKey.remoteController('SECONDARY_VIDEO_OSD_ENABLED');
static const DjiKey secondaryOsdUnit = DjiKey.remoteController('SECONDARY_VIDEO_OSD_UNIT');
static const DjiKey hdmiFormat = DjiKey.remoteController('HDMI_OUTPUT_FORMAT');
static const DjiKey sdiFormat = DjiKey.remoteController('SDI_OUTPUT_FORMAT');
static const DjiKey pipPosition = DjiKey.remoteController('PIP_POSITION');
static DjiKey osdMargin(String side) => DjiKey.remoteController('SECONDARY_VIDEO_OSD_${side}_MARGIN');
// Image transmission
static const DjiKey uplink = DjiKey.airLink('UPLINK_SIGNAL_QUALITY');
@@ -76,6 +96,8 @@ abstract final class SettingsKeys {
static const DjiKey wifiSsid = DjiKey.wifi('SSID');
static const DjiKey wifiBand = DjiKey.wifi('WIFI_FREQUENCY_BAND');
static const DjiKey wifiChannel = DjiKey.wifi('CHANNEL_NUMBER');
static const DjiKey wifiPassword = DjiKey.wifi('PASSWORD');
static const DjiKey wifiReboot = DjiKey.wifi('REBOOT');
// Product
static const DjiKey firmwarePackage = DjiKey.product('FIRMWARE_PACKAGE_VERSION');
@@ -111,12 +133,38 @@ abstract final class SettingsTabs {
static const String liveStream = 'liveStream';
static const String about = 'about';
static const String developer = 'developer';
static const String units = 'units';
static const String customButtons = 'customButtons';
static const String masterSearch = 'masterSearch';
static const String slaveList = 'slaveList';
static const String spectrum = 'spectrum';
static const String videoCache = 'videoCache';
static const String flightLogs = 'flightLogs';
static const String batteryHistory = 'batteryHistory';
static bool _isOn(KeyState s, DjiKey k) => asBool(s.value(k)) == true;
static bool _manual(KeyState s, DjiKey k) => asString(s.value(k)) == 'MANUAL';
/// The remote's dual-operator role; `NORMAL` until it says otherwise.
static String _role(KeyState s) => asString(s.value(SettingsKeys.rcRole)) ?? 'NORMAL';
static const List<(String, String)> _channelModes = <(String, String)>[('AUTO', 'Auto'), ('MANUAL', 'Custom')];
static const List<(String, String)> _videoFormats = <(String, String)>[
('RESOLUTION_1080P_60FPS', '1080p60'),
('RESOLUTION_1080P_50FPS', '1080p50'),
('RESOLUTION_1080P_30FPS', '1080p30'),
('RESOLUTION_1080P_25FPS', '1080p25'),
('RESOLUTION_1080P_24FPS', '1080p24'),
('RESOLUTION_1080I_60FPS', '1080i60'),
('RESOLUTION_1080I_50FPS', '1080i50'),
('RESOLUTION_720P_60FPS', '720p60'),
('RESOLUTION_720P_50FPS', '720p50'),
('RESOLUTION_720P_30FPS', '720p30'),
('RESOLUTION_720P_25FPS', '720p25'),
('RESOLUTION_720P_24FPS', '720p24'),
];
/// The tabs for [p]; battery groups repeat per battery.
static List<SettingsTab> all(ProductProfile p) => <SettingsTab>[
SettingsTab(id: safety, label: 'Safety', icon: 'shield', rows: _safety),
@@ -311,6 +359,135 @@ abstract final class SettingsTabs {
max: 100,
step: 5,
),
GroupSpec('BUTTONS', requires: HudFeatures.customButtons),
CustomSpec(id: customButtons, requires: HudFeatures.customButtons, keys: const <DjiKey>[SettingsKeys.customButton1]),
// ── Dual operator ─────────────────────────────────────────────────────────
GroupSpec('DUAL OPERATOR', requires: HudFeatures.masterSlaveBadge),
KeyChoiceSpec(
id: 'rcRole',
label: 'Remote role',
hint: 'Master flies; slave runs the gimbal and camera',
key: SettingsKeys.rcRole,
options: const <(String, String)>[('NORMAL', 'Single'), ('MASTER', 'Master'), ('SLAVE', 'Slave')],
requires: HudFeatures.masterSlaveBadge,
groundOnly: true,
),
KeyTextSpec(
id: 'rcLinkName',
label: 'Remote name',
hint: 'How the other remote finds this one',
key: SettingsKeys.rcLinkName,
maxLength: 6,
requires: HudFeatures.masterSlaveBadge,
visibleWhen: (SettingsContext c) => _role(c.keys) != 'NORMAL',
),
KeyTextSpec(
id: 'rcLinkPassword',
label: 'Connection password',
hint: 'Four digits the slave types to join',
key: SettingsKeys.rcLinkPassword,
secret: true,
maxLength: 4,
requires: HudFeatures.masterSlaveBadge,
visibleWhen: (SettingsContext c) => _role(c.keys) == 'MASTER',
),
CustomSpec(
id: masterSearch,
requires: HudFeatures.masterSlaveBadge,
visibleWhen: (SettingsContext c) => _role(c.keys) == 'SLAVE',
),
CustomSpec(
id: slaveList,
requires: HudFeatures.masterSlaveBadge,
visibleWhen: (SettingsContext c) => _role(c.keys) == 'MASTER',
),
// ── Secondary video output (HDMI / SDI) ───────────────────────────────────
GroupSpec('VIDEO OUTPUT', requires: HudFeatures.linkLightbridge),
KeySwitchSpec(
id: 'secondaryOut',
label: 'HDMI / SDI output',
hint: "The remote's video out to a monitor or recorder",
key: SettingsKeys.secondaryOut,
requires: HudFeatures.linkLightbridge,
),
KeyChoiceSpec(
id: 'secondaryPort',
label: 'Output port',
key: SettingsKeys.secondaryPort,
options: const <(String, String)>[('HDMI', 'HDMI'), ('SDI', 'SDI')],
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut),
),
KeyChoiceSpec(
id: 'hdmiFormat',
label: 'HDMI format',
key: SettingsKeys.hdmiFormat,
options: _videoFormats,
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut) && asString(c.keys.value(SettingsKeys.secondaryPort)) != 'SDI',
),
KeyChoiceSpec(
id: 'sdiFormat',
label: 'SDI format',
key: SettingsKeys.sdiFormat,
options: _videoFormats,
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut) && asString(c.keys.value(SettingsKeys.secondaryPort)) == 'SDI',
),
KeyChoiceSpec(
id: 'secondaryDisplay',
label: 'Picture',
hint: 'Which feed, and which one inset (dual-camera aircraft)',
key: SettingsKeys.secondaryDisplay,
options: const <(String, String)>[
('SOURCE_1_ONLY', 'Feed 1'),
('SOURCE_2_ONLY', 'Feed 2'),
('SOURCE_1_MAIN', 'Feed 1 + inset'),
('SOURCE_2_MAIN', 'Feed 2 + inset'),
],
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut),
),
KeyChoiceSpec(
id: 'pipPosition',
label: 'Inset position',
key: SettingsKeys.pipPosition,
options: const <(String, String)>[
('TOP_LEFT', 'Top left'),
('TOP_RIGHT', 'Top right'),
('BOTTOM_LEFT', 'Bottom left'),
('BOTTOM_RIGHT', 'Bottom right'),
],
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) =>
_isOn(c.keys, SettingsKeys.secondaryOut) && (asString(c.keys.value(SettingsKeys.secondaryDisplay)) ?? '').endsWith('_MAIN'),
),
KeySwitchSpec(
id: 'secondaryOsd',
label: 'Show flight data (OSD)',
key: SettingsKeys.secondaryOsd,
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut),
),
KeyChoiceSpec(
id: 'secondaryOsdUnit',
label: 'OSD units',
key: SettingsKeys.secondaryOsdUnit,
options: const <(String, String)>[('METRIC', 'Metric'), ('IMPERIAL', 'Imperial')],
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut) && _isOn(c.keys, SettingsKeys.secondaryOsd),
),
for (final (String side, String label) in const <(String, String)>[('TOP', 'top'), ('BOTTOM', 'bottom'), ('LEFT', 'left'), ('RIGHT', 'right')])
KeyNumberSpec(
id: 'osdMargin$side',
label: 'OSD margin, $label',
key: SettingsKeys.osdMargin(side),
min: 0,
max: 50,
unit: 'px',
requires: HudFeatures.linkLightbridge,
visibleWhen: (SettingsContext c) => _isOn(c.keys, SettingsKeys.secondaryOut) && _isOn(c.keys, SettingsKeys.secondaryOsd),
),
const GroupSpec('CONTROLLER'),
const KeyChoiceSpec(
id: 'chargeMobile',
@@ -347,6 +524,7 @@ abstract final class SettingsTabs {
static final List<SettingSpec> _transmission = <SettingSpec>[
const KeyReadoutSpec(id: 'uplink', label: 'Control signal', key: SettingsKeys.uplink, format: _percent),
const KeyReadoutSpec(id: 'downlink', label: 'Video signal', key: SettingsKeys.downlink, format: _percent),
const CustomSpec(id: spectrum),
// OcuSync
GroupSpec('OCUSYNC', requires: HudFeatures.linkOcuSync),
KeyReadoutSpec(id: 'osDataRate', label: 'Video bitrate', key: SettingsKeys.osDataRate, format: _mbps, requires: HudFeatures.linkOcuSync),
@@ -433,7 +611,40 @@ abstract final class SettingsTabs {
),
// Wi-Fi
GroupSpec('WI-FI', requires: HudFeatures.linkWifi),
KeyReadoutSpec(id: 'wifiSsid', label: 'Network', key: SettingsKeys.wifiSsid, requires: HudFeatures.linkWifi),
KeyTextSpec(
id: 'wifiSsid',
label: 'Network name',
hint: 'Takes effect after Restart Wi-Fi',
key: SettingsKeys.wifiSsid,
requires: HudFeatures.linkWifi,
groundOnly: true,
send: (DjiService dji, String v) => dji.setWifiCredentials(ssid: v),
),
KeyTextSpec(
id: 'wifiPassword',
label: 'Wi-Fi password',
hint: 'At least 8 characters; takes effect after Restart Wi-Fi',
key: SettingsKeys.wifiPassword,
secret: true,
maxLength: 63,
requires: HudFeatures.linkWifi,
groundOnly: true,
send: (DjiService dji, String v) {
if (v.length < 8) throw ArgumentError('The password needs at least 8 characters');
return dji.setWifiCredentials(password: v);
},
),
KeyActionSpec(
id: 'wifiReboot',
label: 'Restart Wi-Fi',
hint: 'Applies a new name or password; the phone has to join the network again',
key: SettingsKeys.wifiReboot,
button: 'Restart',
requires: HudFeatures.linkWifi,
groundOnly: true,
confirmTitle: 'Restart the aircraft Wi-Fi',
confirmText: 'The connection drops. Join the network again in the phone\'s Wi-Fi settings, with the new name or password if you changed them.',
),
KeyChoiceSpec(
id: 'wifiBand',
label: 'Frequency band',
@@ -481,6 +692,66 @@ abstract final class SettingsTabs {
},
),
for (int i = 0; i < n; i++) ..._batteryRows(i, n),
// Inspire 2 / M200: the two packs fly as a pair and must be matched.
GroupSpec('BATTERY PAIR', requires: HudFeatures.dualBattery),
KeyReadoutSpec(
id: 'pairingState',
label: 'Pairing',
key: SettingsKeys.battery('PAIRING_STATE', 0),
requires: HudFeatures.dualBattery,
),
KeyActionSpec(
id: 'pairBatteries',
label: 'Pair the two batteries',
hint: 'After swapping a pack: the pair then ages and balances together',
key: SettingsKeys.battery('PAIR_BATTERIES', 0),
button: 'Pair',
requires: HudFeatures.dualBattery,
groundOnly: true,
confirmTitle: 'Pair batteries',
confirmText: 'The two batteries in the aircraft are recorded as a pair. Use two packs of similar age and charge.',
visibleWhen: (SettingsContext c) => asString(c.keys.value(SettingsKeys.battery('PAIRING_STATE', 0))) != 'PAIRED',
),
// Non-smart packs (A3 / N3 / M600 on plain LiPos): the FC judges cells by voltage.
GroupSpec('CELL VOLTAGE', requires: HudFeatures.nonSmartBattery),
KeyNumberSpec(
id: 'cellCount',
label: 'Number of cells',
key: SettingsKeys.battery('NUMBER_OF_CELLS', 0),
min: 3,
max: 12,
unit: 'S',
requires: HudFeatures.nonSmartBattery,
groundOnly: true,
),
for (final int level in const <int>[1, 2]) ...<SettingSpec>[
KeyNumberSpec(
id: 'cellLevel$level',
label: level == 1 ? 'Low cell voltage' : 'Critical cell voltage',
key: SettingsKeys.battery('LEVEL_${level}_CELL_VOLTAGE_THRESHOLD', 0),
min: level == 1 ? 3500 : 3300,
max: level == 1 ? 3900 : 3700,
step: 10,
unit: 'mV',
requires: HudFeatures.nonSmartBattery,
bounds: level == 1
? (KeyState s, int lo, int hi) {
final int? l2 = asInt(s.value(SettingsKeys.battery('LEVEL_2_CELL_VOLTAGE_THRESHOLD', 0)));
return (l2 == null ? lo : (l2 + 50).clamp(lo, hi), hi);
}
: (KeyState s, int lo, int hi) {
final int? l1 = asInt(s.value(SettingsKeys.battery('LEVEL_1_CELL_VOLTAGE_THRESHOLD', 0)));
return (lo, l1 == null ? hi : (l1 - 50).clamp(lo, hi));
},
),
KeyChoiceSpec(
id: 'cellBehavior$level',
label: level == 1 ? 'At low voltage' : 'At critical voltage',
key: SettingsKeys.battery('LEVEL_${level}_CELL_VOLTAGE_BEHAVIOR', 0),
options: const <(String, String)>[('FLASH_LED', 'Flash LEDs'), ('GO_HOME', 'Return home'), ('LAND', 'Land')],
requires: HudFeatures.nonSmartBattery,
),
],
];
}
@@ -504,19 +775,42 @@ abstract final class SettingsTabs {
),
KeyReadoutSpec(id: 'batterySerial$i', label: 'Serial number', key: k('SERIAL_NUMBER')),
KeyReadoutSpec(id: 'batteryFirmware$i', label: 'Firmware', key: k('FIRMWARE_VERSION')),
KeyReadoutSpec(id: 'batteryLatest$i', label: 'Latest warning', key: k('LATEST_WARNING_RECORD'), format: formatWarningRecord),
KeyReadoutSpec(
id: 'batteryHistory$i',
label: 'Warning history',
hint: 'What the pack recorded over its last flights',
key: k('HISTORICAL_WARNING_RECORDS'),
format: formatWarningHistory,
),
];
}
// ── General ─────────────────────────────────────────────────────────────────
static final List<SettingSpec> _general = <SettingSpec>[
const GroupSpec('UNITS'),
const CustomSpec(id: units),
const GroupSpec('MAP'),
const CustomSpec(id: showRoute),
const CustomSpec(id: clearRoute),
GroupSpec('GEO UNLOCKS', requires: HudFeatures.flyZones),
CustomSpec(id: flyZoneLicences, requires: HudFeatures.flyZones),
GroupSpec('VIDEO CACHE', requires: HudFeatures.cameraControls),
CustomSpec(id: videoCache, requires: HudFeatures.cameraControls),
const GroupSpec('FLIGHT RECORDS'),
const CustomSpec(id: flightLogs),
GroupSpec('LIVE STREAMING', requires: HudFeatures.liveStream),
CustomSpec(id: liveStream, requires: HudFeatures.liveStream),
GroupSpec('ON-SCREEN STICKS', requires: HudFeatures.virtualSticks),
CustomSpec(id: stickPads, requires: HudFeatures.virtualSticks),
const GroupSpec('ABOUT'),
const KeyTextSpec(
id: 'aircraftName',
label: 'Aircraft name',
hint: 'Shown in the logbook and to other DJI apps',
key: SettingsKeys.aircraftName,
maxLength: 32,
),
const CustomSpec(id: about, keys: <DjiKey>[SettingsKeys.firmwarePackage, SettingsKeys.fcSerial]),
const GroupSpec('DEVELOPER'),
const CustomSpec(id: developer),