Show the drone's locked home point on the fly-mode map
Adds MSP_WP (118) support to query the flightcontroller's stored home point (WP#0 is a special case for this in iNAV's getWaypoint(), per navigation.c) - the FC reports (0,0,0) rather than an error before one is set, so parseMspHomePoint() treats that pair as "unset". Rendered with a small pentagon house icon (design/homepoint-pentagon.svg, ported to a CustomPainter like the other map icons). Deliberately not polled continuously: a new home_point_provider.dart refreshes it only at the three moments the FC's home point can actually change - connect/reconnect, GPS fix acquired, and arming (iNAV's default reset_home_type=FIRST_ARM only freezes it at the first arm; before that it continuously follows the aircraft while disarmed). Mock's implementation offsets the point 25m from the anchor so it doesn't sit exactly under the drone marker during UI testing.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import '../../domain/waypoint/flat_waypoint_list.dart';
|
||||
import '../flight_controller_link.dart';
|
||||
|
||||
/// `navWaypointActions_e` (Doku Kommunikationsschicht v2 Abschnitt 6,
|
||||
/// geprueft gegen den iNAV-9.1.0-Quellcode: `navigation.h`). Nur die vier
|
||||
@@ -136,3 +137,30 @@ MspWpGetInfo parseMspWpGetInfo(Uint8List payload) {
|
||||
waypointCount: payload[3],
|
||||
);
|
||||
}
|
||||
|
||||
/// Sonderwert fuer [encodeMspGetWaypointRequest]/`MspCommands.getWp`: WP#0
|
||||
/// ist laut `navigation.c` `getWaypoint()` der Homepoint, kein echter
|
||||
/// Missions-Wegpunkt.
|
||||
const int mspWpNumberHome = 0;
|
||||
|
||||
/// Kodiert den 1-Byte-Request-Payload fuer `MspCommands.getWp` (`MSP_WP`).
|
||||
Uint8List encodeMspGetWaypointRequest(int wpNumber) =>
|
||||
Uint8List.fromList([wpNumber]);
|
||||
|
||||
/// Parst die 21-Byte-Antwort auf `MspCommands.getWp` fuer `wp_no ==
|
||||
/// [mspWpNumberHome]` (siehe dortige Doku zu `getWaypoint()`/`GPS_home`).
|
||||
///
|
||||
/// Liefert `null`, wenn der FC noch keinen Homepoint gesetzt hat: dafuer
|
||||
/// gibt es kein eigenes Flag in der Antwort selbst, `getWaypoint()`
|
||||
/// initialisiert `lat`/`lon`/`alt` aber generell auf 0 und ueberschreibt
|
||||
/// das fuer WP#0 nur, wenn `STATE(GPS_FIX_HOME)` gesetzt ist - (0,0) ist
|
||||
/// also der FC-eigene "kein Homepoint"-Wert, nicht eine echte Koordinate
|
||||
/// am Nullmeridian/Aequator.
|
||||
HomePoint? parseMspHomePoint(Uint8List payload) {
|
||||
final d = ByteData.sublistView(payload);
|
||||
final lat = d.getInt32(2, Endian.little) / 1e7;
|
||||
final lon = d.getInt32(6, Endian.little) / 1e7;
|
||||
if (lat == 0 && lon == 0) return null;
|
||||
final altCm = d.getInt32(10, Endian.little);
|
||||
return HomePoint(lat: lat, lon: lon, altitudeM: altCm / 100);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user