mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
save and load points
This commit is contained in:
parent
59b303cb8a
commit
0b7598dabd
7 changed files with 193 additions and 16 deletions
15
js/fc.js
15
js/fc.js
|
@ -23,6 +23,7 @@ var CONFIG,
|
|||
MOTOR_DATA,
|
||||
SERVO_DATA,
|
||||
GPS_DATA,
|
||||
MISSION_PLANER,
|
||||
ANALOG,
|
||||
ARMING_CONFIG,
|
||||
FC_CONFIG,
|
||||
|
@ -196,6 +197,20 @@ var FC = {
|
|||
packetCount: 0
|
||||
};
|
||||
|
||||
MISSION_PLANER = {
|
||||
maxWaypoints: 0,
|
||||
isValidMission: 0,
|
||||
countBusyPoints: 0,
|
||||
bufferPoint: {
|
||||
number: 0,
|
||||
action: 0,
|
||||
lat: 0,
|
||||
lon: 0,
|
||||
alt: 0,
|
||||
endMission: 0
|
||||
}
|
||||
};
|
||||
|
||||
ANALOG = {
|
||||
voltage: 0,
|
||||
mAhdrawn: 0,
|
||||
|
|
|
@ -17,7 +17,8 @@ var MSPCodes = {
|
|||
|
||||
MSP_POSITION_ESTIMATION_CONFIG: 16,
|
||||
MSP_SET_POSITION_ESTIMATION_CONFIG: 17,
|
||||
|
||||
MSP_WP_MISSION_SAVE: 19,
|
||||
MSP_WP_GETINFO: 20,
|
||||
MSP_RTH_AND_LAND_CONFIG: 21,
|
||||
MSP_SET_RTH_AND_LAND_CONFIG: 22,
|
||||
MSP_FW_CONFIG: 23,
|
||||
|
|
|
@ -1106,6 +1106,12 @@ var mspHelper = (function (gui) {
|
|||
case MSPCodes.MSPV2_SET_SETTING:
|
||||
console.log("Setting set");
|
||||
break;
|
||||
case MSPCodes.MSP_WP_GETINFO:
|
||||
// Reserved for waypoint capabilities data.getUint8(0);
|
||||
MISSION_PLANER.maxWaypoints = data.getUint8(1);
|
||||
MISSION_PLANER.isValidMission = data.getUint8(2);
|
||||
MISSION_PLANER.countBusyPoints = data.getUint8(3);
|
||||
break;
|
||||
default:
|
||||
console.log('Unknown code detected: ' + dataHandler.code);
|
||||
} else {
|
||||
|
@ -1586,6 +1592,43 @@ var mspHelper = (function (gui) {
|
|||
buffer.push(SENSOR_CONFIG.opflow);
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_SET_WP:
|
||||
console.log(MISSION_PLANER.bufferPoint.number);
|
||||
console.log(MISSION_PLANER.bufferPoint.action);
|
||||
console.log(MISSION_PLANER.bufferPoint.lat);
|
||||
console.log(MISSION_PLANER.bufferPoint.lon);
|
||||
console.log(MISSION_PLANER.bufferPoint.alt);
|
||||
console.log(MISSION_PLANER.bufferPoint.endMission);
|
||||
console.log('---');
|
||||
|
||||
|
||||
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
|
||||
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lat, 1));
|
||||
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lat, 2));
|
||||
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lat, 3));
|
||||
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lon, 0)); // sbufReadU32(src); // lon
|
||||
buffer.push(specificByte(MISSION_PLANER.bufferPoint.lon, 1));
|
||||
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(0); //sbufReadU16(src); // P1
|
||||
buffer.push(0); //sbufReadU16(src); // P2
|
||||
buffer.push(0); //sbufReadU16(src); // P3
|
||||
buffer.push(MISSION_PLANER.bufferPoint.endMission); //sbufReadU8(src); // future: to set nav flag
|
||||
break;
|
||||
case MSPCodes.MSP_WP:
|
||||
buffer.push(MISSION_PLANER.bufferPoint.number);
|
||||
|
||||
break;
|
||||
case MSPCodes.MSP_WP_MISSION_SAVE:
|
||||
buffer.push(0);
|
||||
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -2329,6 +2372,14 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
};
|
||||
|
||||
self.getMissionInfo = function (callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "1.8.1")) {
|
||||
MSP.send_message(MSPCodes.MSP_WP_GETINFO, false, false, callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
self._getSetting = function(name) {
|
||||
var promise;
|
||||
if (this._settings) {
|
||||
|
|
11
main.css
11
main.css
|
@ -1107,6 +1107,17 @@ dialog {
|
|||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.content_toolbar .btn-danger a {
|
||||
background-color: #db250e;
|
||||
border: 1px solid #b5480e;
|
||||
}
|
||||
|
||||
.content_toolbar .btn-danger a:hover {
|
||||
background-color: #b5480e;
|
||||
transition: all ease 0.2s;
|
||||
}
|
||||
|
||||
|
||||
.toolbar_scroll_bottom .content_wrapper {
|
||||
/* content wrapper in view with toolbar in scroll bottom
|
||||
leave 50px space for the toolbar
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.tab-mission-control .waypoint {
|
||||
padding-left: 19px;
|
||||
padding-right: 19px;
|
||||
padding-bottom: 10px;
|
||||
/*padding-bottom: 10px;*/
|
||||
}
|
||||
.tab-mission-control .waypoint-left {
|
||||
width: 54%;
|
||||
|
@ -21,6 +21,17 @@
|
|||
height: calc(100% - 150px);
|
||||
}
|
||||
|
||||
.tab-mission-control .checksfail {
|
||||
/*float: right;*/
|
||||
margin-top: 3px;
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
background-image:url(../../../images/icons/nopass.svg);
|
||||
background-size:contain;
|
||||
background-position:center;
|
||||
background-repeat:no-repeat;
|
||||
}
|
||||
|
||||
.tab-mission-control .content_toolbar {
|
||||
height: 150px;
|
||||
}
|
||||
|
|
|
@ -11,13 +11,20 @@
|
|||
</div>
|
||||
<div class="spacer">
|
||||
<input type="hidden" name="pointNumber" value="">
|
||||
<div class="point">
|
||||
<select name="type" id="pointType" disabled>
|
||||
<option value="1">Home</option>
|
||||
<option value="1">Waypoint</option>
|
||||
<option value="4">RTH</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="point">
|
||||
<label class="point-label" for="pointLat">Lat: </label>
|
||||
<input id="pointLat" type="text" required>
|
||||
<input id="pointLat" type="text" value="0.0" required>
|
||||
</div>
|
||||
<div class="point">
|
||||
<label class="point-label" for="pointLon">Lon: </label>
|
||||
<input id="pointLon" type="text" required>
|
||||
<input id="pointLon" type="text" value="0.0" required>
|
||||
</div>
|
||||
<div class="point">
|
||||
<label class="point-label" for="pointAlt">Alt: </label>
|
||||
|
@ -27,10 +34,10 @@
|
|||
<div id="savePoint" class="btn save_btn" style="padding-top: 10px; display: inline-block">
|
||||
<a class="save" href="#" data-i18n="editPointButtonSave" style="float: left">Save</a>
|
||||
</div>
|
||||
<div id="removePoint" class="btn btn-danger save_btn" style="padding-top: 10px; display: inline-block;">
|
||||
<div id="removePoint" class="btn btn-danger" style="padding-top: 10px; display: inline-block;">
|
||||
<a class="save" href="#" data-i18n="editPointButtonRemove" style="float: left">Remove</a>
|
||||
</div>
|
||||
<div id="removeAllPoints" class="btn save_btn" style="padding-top: 10px; display: inline-block">
|
||||
<div id="removeAllPoints" class="btn btn-danger" style="padding-top: 10px; display: inline-block">
|
||||
<a class="save" href="#" data-i18n="removeAllPointButtonSave" style="float: left">Remove all points</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -49,11 +56,16 @@
|
|||
</div>
|
||||
<div>
|
||||
<span>Available Points</span>
|
||||
<span id="availablePoints">0/0</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>Mission valid</span>
|
||||
<div id="missionValid" style="display: inline-block"></div>
|
||||
</div>
|
||||
|
||||
<div class="btn save_btn">
|
||||
<a class="save" href="#" data-i18n="loadMissionButton">Load mission</a>
|
||||
<a class="save" href="#" data-i18n="saveMissionButton">Save mission</a>
|
||||
<a id="loadMissionButton" class="save" href="#" data-i18n="loadMissionButton">Load mission</a>
|
||||
<a id="saveMissionButton" class="save" href="#" data-i18n="saveMissionButton">Save mission</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,11 +9,22 @@ TABS.mission_control.initialize = function (callback) {
|
|||
googleAnalytics.sendAppView('Mission Control');
|
||||
}
|
||||
|
||||
function load_html() {
|
||||
$('#content').load("./tabs/mission_control.html", process_html);
|
||||
var loadChainer = new MSPChainerClass();
|
||||
loadChainer.setChain([
|
||||
mspHelper.getMissionInfo
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
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'));
|
||||
}
|
||||
|
||||
load_html();
|
||||
function loadHtml() {
|
||||
$('#content').load("./tabs/mission_control.html", process_html);
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
if (typeof require !== "undefined") {
|
||||
|
@ -31,6 +42,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
var lines = [];
|
||||
var map;
|
||||
var selectedMarker;
|
||||
var pointForSend = 0;
|
||||
|
||||
function clearEditForm() {
|
||||
$('#pointLat').val('');
|
||||
|
@ -89,9 +101,9 @@ TABS.mission_control.initialize = function (callback) {
|
|||
map.addLayer(vectorLayer);
|
||||
}
|
||||
|
||||
function addMarker(pos) {
|
||||
function addMarker(_pos, _alt) {
|
||||
var iconFeature = new ol.Feature({
|
||||
geometry: new ol.geom.Point(pos),
|
||||
geometry: new ol.geom.Point(_pos),
|
||||
name: 'Null Island',
|
||||
population: 4000,
|
||||
rainfall: 500
|
||||
|
@ -126,7 +138,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
source: vectorSource
|
||||
});
|
||||
|
||||
vectorLayer.alt = 0;
|
||||
vectorLayer.alt = _alt;
|
||||
vectorLayer.number = markers.length;
|
||||
|
||||
markers.push(vectorLayer);
|
||||
|
@ -295,7 +307,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$('#pointLon').val(coord[1]);
|
||||
$('#pointAlt').val(selectedMarker.alt);
|
||||
} else {
|
||||
map.addLayer(addMarker(evt.coordinate));
|
||||
map.addLayer(addMarker(evt.coordinate, 0));
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
|
@ -353,6 +365,70 @@ TABS.mission_control.initialize = function (callback) {
|
|||
repaint();
|
||||
}
|
||||
});
|
||||
|
||||
$('#loadMissionButton').on('click', function () {
|
||||
$(this).addClass('disabled');
|
||||
console.log('Start get point');
|
||||
GUI.log('Start get point');
|
||||
|
||||
pointForSend = 0;
|
||||
getNextPoint();
|
||||
});
|
||||
|
||||
$('#saveMissionButton').on('click', function () {
|
||||
$(this).addClass('disabled');
|
||||
GUI.log('Start send point');
|
||||
|
||||
pointForSend = 0;
|
||||
sendNextPoint();
|
||||
});
|
||||
|
||||
updateTotalInfo();
|
||||
}
|
||||
|
||||
function getNextPoint() {
|
||||
if (pointForSend > 0 ) {
|
||||
addMarker(ol.proj.fromLonLat(MISSION_PLANER.bufferPoint.lon,MISSION_PLANER.bufferPoint.lat), MISSION_PLANER.bufferPoint.alt);
|
||||
}
|
||||
|
||||
if (pointForSend >= MISSION_PLANER.countBusyPoints) {
|
||||
GUI.log('End get point');
|
||||
$('#loadMissionButton').removeClass('disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
MISSION_PLANER.bufferPoint.number = pointForSend;
|
||||
|
||||
pointForSend++;
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_WP, mspHelper.crunch(MSPCodes.MSP_WP), false, getNextPoint);
|
||||
}
|
||||
|
||||
function sendNextPoint() {
|
||||
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);
|
||||
|
||||
$('#saveMissionButton').removeClass('disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
var geometry = markers[pointForSend].getSource().getFeatures()[0].getGeometry();
|
||||
|
||||
MISSION_PLANER.bufferPoint.number = pointForSend;
|
||||
MISSION_PLANER.bufferPoint.action = 1;
|
||||
MISSION_PLANER.bufferPoint.lat = geometry.getCoordinates()[0] * 10000000;
|
||||
MISSION_PLANER.bufferPoint.lon = geometry.getCoordinates()[1] * 10000000;
|
||||
MISSION_PLANER.bufferPoint.alt = markers[pointForSend].alt;
|
||||
|
||||
pointForSend++;
|
||||
if (pointForSend >= markers.length) {
|
||||
MISSION_PLANER.bufferPoint.endMission = 0xA5;
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_SET_WP, false, false, sendNextPoint);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue