Update MSPHelper.js

pull/1388/head
breadoven 3 years ago
parent bfeb8ff33d
commit 075e4a6f3d

@ -2988,32 +2988,30 @@ var mspHelper = (function (gui) {
self.loadWaypoints = function (callback) {
MISSION_PLANER.reinit();
let waypointId = 1;
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, getFirstWP);
let waypointId = 0;
let startTime = new Date().getTime();
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, loadWaypoint);
function getFirstWP() {
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint)
};
function nextWaypoint() {
function loadWaypoint() {
waypointId++;
if (waypointId < MISSION_PLANER.getCountBusyPoints()) {
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, nextWaypoint);
}
else {
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, loadWaypoint);
} else {
GUI.log('Receive time: ' + (new Date().getTime() - startTime) + 'ms');
MSP.send_message(MSPCodes.MSP_WP, [waypointId], false, callback);
}
};
};
self.saveWaypoints = function (callback) {
let waypointId = 1;
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint)
let waypointId = 0;
let startTime = new Date().getTime();
sendWaypoint();
function nextWaypoint() {
function sendWaypoint() {
waypointId++;
if (waypointId < MISSION_PLANER.get().length) {
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, nextWaypoint);
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, sendWaypoint);
}
else {
MSP.send_message(MSPCodes.MSP_SET_WP, MISSION_PLANER.extractBuffer(waypointId), false, endMission);
@ -3021,6 +3019,7 @@ var mspHelper = (function (gui) {
};
function endMission() {
GUI.log('Send time: ' + (new Date().getTime() - startTime) + 'ms');
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, callback);
}
};

Loading…
Cancel
Save