Skip to content

Commit b0933b4

Browse files
committed
Safehome update version 1.0
Add Save to Eprom to the Save button Add Second circle to Safehome icon representing the Safehome_max_distance where the value is directly extracted from the COMMON_SETTINGS Add Legend under Safehome table about the circles
1 parent 1bbc834 commit b0933b4

File tree

3 files changed

+79
-22
lines changed

3 files changed

+79
-22
lines changed

src/css/tabs/mission_planer.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,22 @@
474474

475475
.tab-mission-control .btnTable-success a:hover {
476476
background-color: #218838;
477-
}
477+
}
478+
479+
.tab-mission-control .legendItem {
480+
display:block;
481+
}
482+
483+
.tab-mission-control .fill{
484+
border:none;
485+
border-bottom:5px dotted #88CC3E;
486+
display:inline-block;
487+
width:20px;
488+
}
489+
490+
.tab-mission-control .textLegend{
491+
margin:2px;
492+
}
493+
.tab-mission-control .valueLegend{
494+
float:right;
495+
}

tabs/mission_control.html

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,33 @@
9696
</div>
9797
<div class="spacer" id="SafehomeContent">
9898
<div>
99-
<table class="safehomesTable">
100-
<thead>
101-
<tr>
102-
<th style="width: 80px" data-i18n="SafehomeSelected"></th>
103-
<th style="width: 50px" data-i18n="SafehomeId"></th>
104-
<th style="width: 80px" data-i18n="SafehomeEnabled"></th>
105-
<th style="width: 120px" data-i18n="SafehomeLon"></th>
106-
<th style="width: 120px" data-i18n="SafehomeLat"></th>
107-
</tr>
108-
</thead>
109-
<tbody id="safehomesTableBody">
110-
</tbody>
111-
</table>
99+
<table class="safehomesTable">
100+
<thead>
101+
<tr>
102+
<th style="width: 80px" data-i18n="SafehomeSelected"></th>
103+
<th style="width: 50px" data-i18n="SafehomeId"></th>
104+
<th style="width: 80px" data-i18n="SafehomeEnabled"></th>
105+
<th style="width: 120px" data-i18n="SafehomeLon"></th>
106+
<th style="width: 120px" data-i18n="SafehomeLat"></th>
107+
</tr>
108+
</thead>
109+
<tbody id="safehomesTableBody">
110+
</tbody>
111+
</table>
112+
<hr>
113+
<div class="spacer" id="safehomeLegend">
114+
<span><b>Legend : </b></span>
115+
<div class="legendItem">
116+
<span class="fill" style="border-bottom-color:#900C3F"></span>
117+
<span class="textLegend">Max distance (m):</span>
118+
<span id="safeHomeMaxDistance" class="valueLegend"></span>
119+
</div>
120+
<div class="legendItem">
121+
<span class="fill"></span>
122+
<span class="textLegend">Safe Radius (m):</span>
123+
<span id="SafeHomeSafeDistance" class="valueLegend"></span>
124+
</div>
125+
</div>
112126
</div>
113127
</div>
114128
</div>

tabs/mission_control.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,22 @@ TABS.mission_control.initialize = function (callback) {
360360

361361
//////////////////////////////////////////////////////////////////////////////////////////////
362362
// define & init parameters for default Settings
363-
//////////////////////////////////////////////////////////////////////////////////////////////
364-
var settings = { speed: 0, alt: 5000, safeRadiusSH : 50};
365-
363+
//////////////////////////////////////////////////////////////////////////////////////////////
364+
var vMaxDistSH = 0;
365+
var settings = {};
366+
mspHelper.getSetting("safehome_max_distance").then(function (s) {
367+
if (s) {
368+
console.log(s);
369+
vMaxDistSH = Number(s.value)/100;
370+
settings = { speed: 0, alt: 5000, safeRadiusSH : 50, maxDistSH : vMaxDistSH};
371+
}
372+
else {
373+
console.log(s);
374+
vMaxDistSH = 0;
375+
settings = { speed: 0, alt: 5000, safeRadiusSH : 50, maxDistSH : vMaxDistSH};
376+
}
377+
});
378+
console.log(settings);
366379
//////////////////////////////////////////////////////////////////////////////////////////////
367380
// define & init Waypoints parameters
368381
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -543,7 +556,7 @@ TABS.mission_control.initialize = function (callback) {
543556

544557
let circleStyle = new ol.style.Style({
545558
stroke: new ol.style.Stroke({
546-
color: 'rgba(255, 163, 46, 1)',
559+
color: 'rgba(144, 12, 63, 0.5)',
547560
width: 3,
548561
lineDash : [10]
549562
}),
@@ -570,9 +583,10 @@ TABS.mission_control.initialize = function (callback) {
570583
style : function(iconFeature) {
571584
let styles = [getSafehomeIcon(safehome)];
572585
if (safehome.isUsed()) {
573-
//circleStyle.setGeometry(new ol.geom.Circle(iconFeature.getGeometry().getCoordinates(), safehomeRangeRadius));
586+
circleStyle.setGeometry(new ol.geom.Circle(iconFeature.getGeometry().getCoordinates(), getProjectedRadius(settings.maxDistSH)));
574587
circleSafeStyle.setGeometry(new ol.geom.Circle(iconFeature.getGeometry().getCoordinates(), getProjectedRadius(Number(settings.safeRadiusSH))));
575588
styles.push(circleSafeStyle);
589+
styles.push(circleStyle);
576590
}
577591
return styles;
578592
}
@@ -1029,6 +1043,8 @@ TABS.mission_control.initialize = function (callback) {
10291043
cleanSafehomeLayers();
10301044
renderSafehomesTable();
10311045
renderSafehomesOnMap();
1046+
$('#safeHomeMaxDistance').text(settings.maxDistSH);
1047+
$('#SafeHomeSafeDistance').text(settings.safeRadiusSH);
10321048
};
10331049

10341050
button.addEventListener('click', handleShowSafehome, false);
@@ -1530,8 +1546,11 @@ TABS.mission_control.initialize = function (callback) {
15301546
$(this).addClass('disabled');
15311547
GUI.log('Start of sending Safehome points');
15321548
mspHelper.saveSafehomes();
1533-
GUI.log('End of sending Safehome points');
1534-
$('#saveEepromSafehomeButton').removeClass('disabled');
1549+
setTimeout(function(){
1550+
mspHelper.saveToEeprom();
1551+
GUI.log('End of sending Safehome points');
1552+
$('#saveEepromSafehomeButton').removeClass('disabled');
1553+
}, 500);
15351554
});
15361555

15371556
/////////////////////////////////////////////
@@ -1635,8 +1654,14 @@ TABS.mission_control.initialize = function (callback) {
16351654
// Callback for settings
16361655
/////////////////////////////////////////////
16371656
$('#saveSettings').on('click', function () {
1638-
settings = { speed: Number($('#MPdefaultPointSpeed').val()), alt: Number($('#MPdefaultPointAlt').val()), safeRadiusSH: Number($('#MPdefaultSafeRangeSH').val()) };
1657+
let oldSafeRadiusSH = settings.safeRadiusSH;
1658+
settings = { speed: Number($('#MPdefaultPointSpeed').val()), alt: Number($('#MPdefaultPointAlt').val()), safeRadiusSH: Number($('#MPdefaultSafeRangeSH').val()), maxDistSH : vMaxDistSH};
16391659
saveSettings();
1660+
if (settings.safeRadiusSH != oldSafeRadiusSH && $('#showHideSafehomeButton').is(":visible")) {
1661+
cleanSafehomeLayers();
1662+
renderSafehomesOnMap();
1663+
$('#SafeHomeSafeDistance').text(settings.safeRadiusSH);
1664+
}
16401665
closeSettingsPanel();
16411666
});
16421667

0 commit comments

Comments
 (0)