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:
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Homepoint-Marker auf der Karte im Fly-Modus (Doku: "den auf der Drohne
|
||||
/// gelockten Homepoint abfragen ... benutze dieses Icon"), Pentagon-Haus-
|
||||
/// Form aus design/homepoint-pentagon.svg - nativ als [CustomPainter] statt
|
||||
/// als SVG-Asset nachgebaut (Format bewusst geaendert, dasselbe Muster wie
|
||||
/// DroneMarkerIcon/PaperPlaneIcon: ein einzelnes Polygon lohnt keine
|
||||
/// zusaetzliche SVG-Renderer-Abhaengigkeit).
|
||||
class HomePointIcon extends StatelessWidget {
|
||||
const HomePointIcon({super.key, this.size = 32});
|
||||
|
||||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomPaint(
|
||||
size: Size.square(size),
|
||||
painter: const _HomePointPainter(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _HomePointPainter extends CustomPainter {
|
||||
const _HomePointPainter();
|
||||
|
||||
// 1:1 aus design/homepoint-pentagon.svg uebernommene Koordinaten (viewBox
|
||||
// 0 0 72 72): Haus-Silhouette (Fuenfeck) mit spitzem Dach.
|
||||
static const _viewBoxSize = 72.0;
|
||||
static const _points = [
|
||||
Offset(20, 52),
|
||||
Offset(20, 34),
|
||||
Offset(36, 16),
|
||||
Offset(52, 34),
|
||||
Offset(52, 52),
|
||||
];
|
||||
static const _fill = Color(0xFF161616);
|
||||
static const _strokeWidth = 3.0;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final scale = size.width / _viewBoxSize;
|
||||
Offset s(Offset p) => p * scale;
|
||||
|
||||
final path = Path()..moveTo(s(_points.first).dx, s(_points.first).dy);
|
||||
for (final point in _points.skip(1)) {
|
||||
path.lineTo(s(point).dx, s(point).dy);
|
||||
}
|
||||
path.close();
|
||||
|
||||
canvas.drawPath(path, Paint()..color = _fill);
|
||||
canvas.drawPath(
|
||||
path,
|
||||
Paint()
|
||||
..color = Colors.white
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = _strokeWidth * scale
|
||||
..strokeJoin = StrokeJoin.round,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant _HomePointPainter oldDelegate) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user