1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-25 17:25:14 +03:00

Update mission_control.js

This commit is contained in:
breadoven 2021-11-18 13:47:07 +00:00
parent f16dc4cf93
commit a83fe22deb

View file

@ -2462,7 +2462,7 @@ TABS.mission_control.initialize = function (callback) {
mission.setVersion(node.$[attr]); mission.setVersion(node.$[attr]);
} }
} }
} else if (node['#name'].match(/mwp/i) && node.$) { } else if (node['#name'].match(/meta/i) || node['#name'].match(/mwp/i) && node.$) {
for (var attr in node.$) { for (var attr in node.$) {
if (attr.match(/zoom/i)) { if (attr.match(/zoom/i)) {
mission.setCenterZoom(parseInt(node.$[attr])); mission.setCenterZoom(parseInt(node.$[attr]));
@ -2533,7 +2533,13 @@ TABS.mission_control.initialize = function (callback) {
mission.flush(); mission.flush();
return; return;
} else { } else {
// update Attached Waypoints (i.e non Map Markers) /* update Attached Waypoints (i.e non Map Markers)
* Ensure WPs numbered sequentially across all missions */
i = 1;
mission.get().forEach(function (element) {
element.setNumber(i);
i++;
});
mission.update(false, true); mission.update(false, true);
multimissionCount = missionEndFlagCount; multimissionCount = missionEndFlagCount;
multimission.reinit(); multimission.reinit();
@ -2579,10 +2585,10 @@ TABS.mission_control.initialize = function (callback) {
var center = ol.proj.toLonLat(map.getView().getCenter()); var center = ol.proj.toLonLat(map.getView().getCenter());
var zoom = map.getView().getZoom(); var zoom = map.getView().getZoom();
let version = (multimissionCount && !singleMissionActive()) ? '4.0.0' : '2.3-pre8';
var data = { var data = {
'version': { $: { 'value': '2.3-pre8' } }, 'version': { $: { 'value': version } },
'mwp': { $: { 'cx': (Math.round(center[0] * 10000000) / 10000000), 'meta': { $: { 'cx': (Math.round(center[0] * 10000000) / 10000000),
'cy': (Math.round(center[1] * 10000000) / 10000000), 'cy': (Math.round(center[1] * 10000000) / 10000000),
'home-x' : HOME.getLonMap(), 'home-x' : HOME.getLonMap(),
'home-y' : HOME.getLatMap(), 'home-y' : HOME.getLatMap(),
@ -2590,9 +2596,10 @@ TABS.mission_control.initialize = function (callback) {
'missionitem': [] 'missionitem': []
}; };
let missionStartWPNumber = 0;
mission.get().forEach(function (waypoint) { mission.get().forEach(function (waypoint) {
var point = { $: { var point = { $: {
'no': waypoint.getNumber()+1, 'no': waypoint.getNumber() - missionStartWPNumber + 1,
'action': MWNP.WPTYPE.REV[waypoint.getAction()], 'action': MWNP.WPTYPE.REV[waypoint.getAction()],
'lat': waypoint.getLatMap(), 'lat': waypoint.getLatMap(),
'lon': waypoint.getLonMap(), 'lon': waypoint.getLonMap(),
@ -2602,6 +2609,9 @@ TABS.mission_control.initialize = function (callback) {
'parameter3': waypoint.getP3(), 'parameter3': waypoint.getP3(),
'flag': waypoint.getEndMission(), 'flag': waypoint.getEndMission(),
} }; } };
if (waypoint.getEndMission() == 0xA5) {
missionStartWPNumber = waypoint.getNumber() + 1;
}
data.missionitem.push(point); data.missionitem.push(point);
}); });