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

Validation Fix

This commit is contained in:
Andi Kanzler 2023-11-15 08:55:58 -03:00
parent 412961c5b4
commit 23a6a01143
3 changed files with 35 additions and 26 deletions

View file

@ -1,7 +1,6 @@
/*global $*/ /*global $*/
'use strict'; 'use strict';
const { ColorManagement } = require("three");
function checkChromeRuntimeError() { function checkChromeRuntimeError() {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {

View file

@ -206,7 +206,7 @@
<span id="SafeHomeSafeDistance"></span> <span id="SafeHomeSafeDistance"></span>
</div> </div>
<div class="legendItem"> <div class="legendItem">
<span class="fill" style="border-bottom:5px solid #f78a05;"></span> <span class="fill" style="border-bottom:5px solid #f78a05;border-top:5px solid #0025a1;"></span>
<span class="textLegend">FW Approach</span> <span class="textLegend">FW Approach</span>
<span id="SafeHomeSafeDistance"></span> <span id="SafeHomeSafeDistance"></span>
</div> </div>

View file

@ -649,11 +649,19 @@ TABS.mission_control.initialize = function (callback) {
$safehomeBox.find('#safehomeLandHeading1').val(Math.abs(safehome.getLandHeading1())).on('change', event => { $safehomeBox.find('#safehomeLandHeading1').val(Math.abs(safehome.getLandHeading1())).on('change', event => {
let val = Number($(event.currentTarget).val()); let val = Number($(event.currentTarget).val());
if (val < -360 || val > 360) { if (val < 0) {
$safehomeBox.find('#safehomeLandHeading1').val(safehome.getLandHeading1()); val = 360;
return; $safehomeBox.find('#safehomeLandHeading1').val(360);
}
if (val > 360) {
val = 0;
$safehomeBox.find('#safehomeLandHeading1').val(0);
} }
if ($safehomeBox.find('#safehomeLandHeading1Excl').prop('checked')) {
val *= -1;
}
safehome.setLandHeading1(val); safehome.setLandHeading1(val);
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
@ -667,9 +675,17 @@ TABS.mission_control.initialize = function (callback) {
$safehomeBox.find('#safehomeLandHeading2').val(Math.abs(safehome.getLandHeading2())).on('change', event => { $safehomeBox.find('#safehomeLandHeading2').val(Math.abs(safehome.getLandHeading2())).on('change', event => {
let val = Number($(event.currentTarget).val()); let val = Number($(event.currentTarget).val());
if (val < -360 || val > 360) { if (val < 0) {
$safehomeBox.find('#safehomeLandHeading2').val(safehome.getLandHeading2()); val = 360;
return; $safehomeBox.find('#safehomeLandHeading2').val(360);
}
if (val > 360) {
val = 0;
$safehomeBox.find('#safehomeLandHeading2').val(0);
}
if ($safehomeBox.find('#safehomeLandHeading2Excl').prop('checked')) {
val *= -1;
} }
safehome.setLandHeading2(val); safehome.setLandHeading2(val);
@ -680,7 +696,7 @@ TABS.mission_control.initialize = function (callback) {
$('#safehomeLandAltM').text(safehome.getLandAltAsl() / 100 + " m"); $('#safehomeLandAltM').text(safehome.getLandAltAsl() / 100 + " m");
$('#safehomeApproachAltM').text(safehome.getApproachAltAsl() / 100 + " m"); $('#safehomeApproachAltM').text(safehome.getApproachAltAsl() / 100 + " m");
if (safehome.getElevation() != "NaN") if (safehome.getElevation() != NaN)
$('#safehomeElevation').text(safehome.getElevation() / 100 + " m"); $('#safehomeElevation').text(safehome.getElevation() / 100 + " m");
GUI.switchery(); GUI.switchery();
@ -694,7 +710,6 @@ TABS.mission_control.initialize = function (callback) {
return false; return false;
} }
return true; return true;
} }
function updateSafehomeInfo(){ function updateSafehomeInfo(){
@ -773,7 +788,7 @@ TABS.mission_control.initialize = function (callback) {
function paintApproachLine(pos1, pos2, color) function paintApproachLine(pos1, pos2, color)
{ {
var line = new ol.geom.LineString([pos1, pos2]); var line = new ol.geom.LineString([ol.proj.fromLonLat([pos1.lon, pos1.lat]), ol.proj.fromLonLat([pos2.lon, pos2.lat])]);
var feature = new ol.Feature({ var feature = new ol.Feature({
geometry: line geometry: line
@ -826,24 +841,19 @@ TABS.mission_control.initialize = function (callback) {
} }
function paintApproach(landCoord, approachLength, bearing, approachDirection) { function paintApproach(landCoord, approachLength, bearing, approachDirection) {
var coords = new Array(4);
coords[3] = landCoord; var pos1 = calculate_new_cooridatnes(landCoord, bearing, approachLength);
coords[2] = calculate_new_cooridatnes(coords[3], bearing, approachLength);
let direction; let direction;
if (approachDirection == ApproachDirection.LEFT) { if (approachDirection == ApproachDirection.LEFT) {
direction = wrap_360(bearing + 90); direction = wrap_360(bearing + 90);
} else { } else {
direction = wrap_360(bearing - 90); direction = wrap_360(bearing - 90);
} }
coords[1] = calculate_new_cooridatnes(coords[2], direction, approachLength / 2); var pos2 = calculate_new_cooridatnes(pos1, direction, approachLength / 2);
coords[0] = calculate_new_cooridatnes(coords[3], direction, approachLength / 2);
paintApproachLine(landCoord, pos2, '#0025a1');
for (let i = 0; i < 3; i++) { paintApproachLine(pos2, pos1, '#0025a1');
let pos1 = ol.proj.fromLonLat([coords[i].lon, coords[i].lat]); paintApproachLine(pos1, landCoord, '#f78a05');
let pos2 = ol.proj.fromLonLat([coords[i + 1].lon, coords[i + 1].lat]);
paintApproachLine(pos1, pos2, '#f78a05');
}
} }
function addFwApproach(safehome) function addFwApproach(safehome)
@ -859,13 +869,13 @@ TABS.mission_control.initialize = function (callback) {
} }
if (safehome.getLandHeading2() != 0) { if (safehome.getLandHeading2() != 0) {
paintApproach({lat: safehome.getLatMap(), lon: safehome.getLonMap()}, settings.fwApproachLength, Math.abs(safehome.getLandHeading2()), safehome.getApproachDirection()); let bearing = wrap_360(Math.abs(safehome.getLandHeading2()) + 180);
paintApproach({lat: safehome.getLatMap(), lon: safehome.getLonMap()}, settings.fwApproachLength, bearing, safehome.getApproachDirection());
} }
if (safehome.getLandHeading2() > 0) { if (safehome.getLandHeading2() > 0) {
let bearing = wrap_360(safehome.getLandHeading2() + 180);
let direction = safehome.getApproachDirection() == ApproachDirection.LEFT ? ApproachDirection.RIGHT : ApproachDirection.LEFT; let direction = safehome.getApproachDirection() == ApproachDirection.LEFT ? ApproachDirection.RIGHT : ApproachDirection.LEFT;
paintApproach({lat: safehome.getLatMap(), lon: safehome.getLonMap()}, settings.fwApproachLength, bearing, direction); paintApproach({lat: safehome.getLatMap(), lon: safehome.getLonMap()}, settings.fwApproachLength, safehome.getLandHeading2(), direction);
} }
} }