1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

fix load point

This commit is contained in:
Sergej Pozdnyakov 2018-01-07 20:49:58 +03:00
parent 8dee7a6340
commit efda795698
4 changed files with 70 additions and 44 deletions

View file

@ -2329,6 +2329,12 @@
"saveMissionButton": {
"message": "Save mission"
},
"loadEepromMissionButton": {
"message": "Load Eeprom mission"
},
"saveEepromMissionButton": {
"message": "Save Eeprom mission"
},
"editPointHead": {
"message": "Edit point"
},

View file

@ -339,7 +339,12 @@ var mspHelper = (function (gui) {
}
break;
case MSPCodes.MSP_WP:
console.log(data);
MISSION_PLANER.bufferPoint.number = data.getUint8(0);
MISSION_PLANER.bufferPoint.action = data.getUint8(1);
MISSION_PLANER.bufferPoint.lon = data.getInt32(2, true) / 10000000;
MISSION_PLANER.bufferPoint.lat = data.getInt32(6, true) / 10000000;
MISSION_PLANER.bufferPoint.alt = data.getInt32(10, true);
break;
case MSPCodes.MSP_BOXIDS:
//noinspection JSUndeclaredVariable
@ -1596,6 +1601,8 @@ var mspHelper = (function (gui) {
break;
case MSPCodes.MSP_SET_WP:
console.log(MISSION_PLANER.bufferPoint.lat);
console.log(MISSION_PLANER.bufferPoint.lon);
buffer.push(MISSION_PLANER.bufferPoint.number); // sbufReadU8(src); // number
buffer.push(MISSION_PLANER.bufferPoint.action); // sbufReadU8(src); // action
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lat, 0)); // sbufReadU32(src); // lat
@ -1607,9 +1614,9 @@ var mspHelper = (function (gui) {
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lon, 2));
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lon, 3));
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 0)); // sbufReadU32(src); // to set altitude (cm)
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 1)); // sbufReadU32(src); // to set altitude (cm)
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 2)); // sbufReadU32(src); // to set altitude (cm)
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 3)); // sbufReadU32(src); // to set altitude (cm)
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 1));
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 2));
buffer.push(specificByte(MISSION_PLANER.bufferPoint.alt, 3));
buffer.push(lowByte(0)); //sbufReadU16(src); // P1
buffer.push(highByte(0));
buffer.push(lowByte(0)); //sbufReadU16(src); // P2

View file

@ -64,8 +64,10 @@
</div>
<div class="btn save_btn">
<a id="loadMissionButton" class="save" href="#" data-i18n="loadMissionButton">Load mission</a>
<a id="saveMissionButton" class="save" href="#" data-i18n="saveMissionButton">Save mission</a>
<a id="loadMissionButton" class="save" href="#" data-i18n="loadMissionButton"></a>
<a id="saveMissionButton" class="save" href="#" data-i18n="saveMissionButton"></a>
<a id="loadEepromMissionButton" class="save" href="#" data-i18n="loadEepromMissionButton">Load Eeprom mission</a>
<a id="saveEepromMissionButton" class="save" href="#" data-i18n="saveEepromMissionButton">Save Eeprom mission</a>
</div>
</div>
</div>

View file

@ -17,7 +17,6 @@ TABS.mission_control.initialize = function (callback) {
loadChainer.execute();
function updateTotalInfo() {
console.log(MISSION_PLANER.isValidMission);
$('#availablePoints').text(MISSION_PLANER.countBusyPoints + '/' + MISSION_PLANER.maxWaypoints);
$('#missionValid').html(MISSION_PLANER.isValidMission ? chrome.i18n.getMessage('armingCheckPass') : chrome.i18n.getMessage('armingCheckFail'));
}
@ -383,17 +382,31 @@ TABS.mission_control.initialize = function (callback) {
sendNextPoint();
});
$('#loadEepromMissionButton').on('click', function () {
});
$('#saveEepromMissionButton').on('click', function () {
GUI.log(chrome.i18n.getMessage('eeprom_saved_ok'));
MSP.send_message(MSPCodes.MSP_WP_MISSION_SAVE, false, false);
});
updateTotalInfo();
}
function getNextPoint() {
if (pointForSend > 0) {
addMarker(ol.proj.fromLonLat(MISSION_PLANER.bufferPoint.lon,MISSION_PLANER.bufferPoint.lat), MISSION_PLANER.bufferPoint.alt);
// console.log(MISSION_PLANER.bufferPoint.lon);
// console.log(MISSION_PLANER.bufferPoint.lat);
// console.log(MISSION_PLANER.bufferPoint.alt);
// console.log(MISSION_PLANER.bufferPoint.action);
map.addLayer(addMarker(ol.proj.fromLonLat([MISSION_PLANER.bufferPoint.lon, MISSION_PLANER.bufferPoint.lat]), MISSION_PLANER.bufferPoint.alt));
// repaint();
}
if (pointForSend >= MISSION_PLANER.countBusyPoints) {
if (pointForSend > MISSION_PLANER.countBusyPoints) {
GUI.log('End get point');
$('#loadMissionButton').removeClass('disabled');
repaint();
return;
}
@ -408,9 +421,6 @@ TABS.mission_control.initialize = function (callback) {
if (pointForSend >= markers.length) {
GUI.log('End send point');
GUI.log(chrome.i18n.getMessage('eeprom_saved_ok'));
MSP.send_message(MSPCodes.MSP_WP_MISSION_SAVE, false, false);
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, updateTotalInfo);
$('#saveMissionButton').removeClass('disabled');
@ -418,11 +428,12 @@ TABS.mission_control.initialize = function (callback) {
}
var geometry = markers[pointForSend].getSource().getFeatures()[0].getGeometry();
var coordinate = ol.proj.toLonLat(geometry.getCoordinates());
MISSION_PLANER.bufferPoint.number = pointForSend;
MISSION_PLANER.bufferPoint.action = 1;
MISSION_PLANER.bufferPoint.lat = parseInt(geometry.getCoordinates()[0] * 10000000);
MISSION_PLANER.bufferPoint.lon = parseInt(geometry.getCoordinates()[1] * 10000000);
MISSION_PLANER.bufferPoint.lat = parseInt(coordinate[0] * 10000000);
MISSION_PLANER.bufferPoint.lon = parseInt(coordinate[1] * 10000000);
MISSION_PLANER.bufferPoint.alt = markers[pointForSend].alt;
pointForSend++;