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

Fix enabled state

This commit is contained in:
Pawel Spychalski (DzikuVx) 2023-10-20 12:15:20 +02:00
parent 09170f5bbf
commit 9ff0e539f5
5 changed files with 142 additions and 74 deletions

View file

@ -5549,5 +5549,8 @@
}, },
"ezTuneRatePreviewExpo" : { "ezTuneRatePreviewExpo" : {
"message": "Expo" "message": "Expo"
},
"ezTuneEnabledTips": {
"message": ""
} }
} }

View file

@ -1584,7 +1584,7 @@ var mspHelper = (function (gui) {
break; break;
case MSPCodes.MSP2_INAV_EZ_TUNE_SET: case MSPCodes.MSP2_INAV_EZ_TUNE_SET:
console.log('Rate dynamics saved'); console.log('EzTune settings saved');
break; break;
default: default:
@ -2235,6 +2235,9 @@ var mspHelper = (function (gui) {
buffer.push(EZ_TUNE.aggressiveness); buffer.push(EZ_TUNE.aggressiveness);
buffer.push(EZ_TUNE.rate); buffer.push(EZ_TUNE.rate);
buffer.push(EZ_TUNE.expo); buffer.push(EZ_TUNE.expo);
console.log(buffer);
break;
default: default:
return false; return false;

View file

@ -401,18 +401,21 @@
/* background: #D6D6D6 linear-gradient(-45deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, rgba(255, 255, 255, .2) 80%, rgba(255, 255, 255, .2) 90%, transparent 90%, transparent 100%, rgba(255, 255, 255, .2) 100%, transparent); */ /* background: #D6D6D6 linear-gradient(-45deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, rgba(255, 255, 255, .2) 80%, rgba(255, 255, 255, .2) 90%, transparent 90%, transparent 100%, rgba(255, 255, 255, .2) 100%, transparent); */
} }
.pid-slider-row { .pid-slider-row,
.pid-switch-row {
display: flex; display: flex;
padding: 4px; padding: 4px;
} }
.pid-slider-row span { .pid-slider-row span,
.pid-switch-row .label {
margin-right: 2em; margin-right: 2em;
width: 120px; width: 120px;
line-height: 22px;; line-height: 22px;;
} }
.pid-slider-row input[type="number"] { .pid-slider-row input[type="number"],
.pid-switch-row input[type="number"] {
font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif; font-family: 'open_sansregular', 'Segoe UI', Tahoma, sans-serif;
background-color: #fff; background-color: #fff;
border: 1px solid #ccc; border: 1px solid #ccc;
@ -422,7 +425,9 @@
margin-right: 2em; margin-right: 2em;
} }
.pid-slider-row input[type="range"] { .pid-slider-row input[type="range"],
.pid-switch-row input[type="range"]
{
display: block; display: block;
flex-grow: 100; flex-grow: 100;
} }

View file

@ -8,6 +8,17 @@
<div> <div>
<div class="pid-sliders-axis" style="background-color: #2a9d8f;">
<div style="padding: 1em;" data-i18n="ezTuneEnabledTips"></div>
<div class="pid-switch-row">
<span data-i18n="configurationFeatureEnabled" class="bold label"></span>
<div class="checkbox no-border">
<input id="ez_tune_enabled" type="checkbox" class="ez-element toggle" />
</div>
</div>
<div class="clear-both"></div>
</div>
<div class="pid-sliders-axis" data-axis="roll"> <div class="pid-sliders-axis" data-axis="roll">
<div style="padding: 1em;" data-i18n="ezTuneFilterHzTips"></div> <div style="padding: 1em;" data-i18n="ezTuneFilterHzTips"></div>
<div class="pid-slider-row"> <div class="pid-slider-row">

View file

@ -7,9 +7,9 @@ TABS.ez_tune = {
TABS.ez_tune.initialize = function (callback) { TABS.ez_tune.initialize = function (callback) {
var loadChainer = new MSPChainerClass(); let loadChainer = new MSPChainerClass();
var loadChain = [ let loadChain = [
mspHelper.loadEzTune, mspHelper.loadEzTune,
]; ];
@ -22,6 +22,29 @@ TABS.ez_tune.initialize = function (callback) {
loadChainer.setExitPoint(load_html); loadChainer.setExitPoint(load_html);
loadChainer.execute(); loadChainer.execute();
var saveChainer = new MSPChainerClass();
var saveChain = [
mspHelper.saveEzTune,
mspHelper.saveToEeprom
];
saveChainer.setChain(saveChain);
saveChainer.setExitPoint(reboot);
function reboot() {
//noinspection JSUnresolvedVariable
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
});
}
function reinitialize() {
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_ez_tune a'));
}
if (GUI.active_tab != 'ez_tune') { if (GUI.active_tab != 'ez_tune') {
GUI.active_tab = 'ez_tune'; GUI.active_tab = 'ez_tune';
googleAnalytics.sendAppView('Ez Tune'); googleAnalytics.sendAppView('Ez Tune');
@ -84,6 +107,8 @@ TABS.ez_tune.initialize = function (callback) {
helper.tabs.init($('.tab-ez_tune')); helper.tabs.init($('.tab-ez_tune'));
helper.features.updateUI($('.tab-ez_tune'), FEATURES); helper.features.updateUI($('.tab-ez_tune'), FEATURES);
$("#ez_tune_enabled").prop('checked', EZ_TUNE.enabled);
GUI.sliderize($('#ez_tune_filter_hz'), EZ_TUNE.filterHz, 10, 300); GUI.sliderize($('#ez_tune_filter_hz'), EZ_TUNE.filterHz, 10, 300);
GUI.sliderize($('#ez_tune_axis_ratio'), EZ_TUNE.axisRatio, 25, 175); GUI.sliderize($('#ez_tune_axis_ratio'), EZ_TUNE.axisRatio, 25, 175);
GUI.sliderize($('#ez_tune_response'), EZ_TUNE.response, 0, 200); GUI.sliderize($('#ez_tune_response'), EZ_TUNE.response, 0, 200);
@ -104,6 +129,27 @@ TABS.ez_tune.initialize = function (callback) {
GUI.simpleBind(); GUI.simpleBind();
GUI.content_ready(callback); GUI.content_ready(callback);
$('a.update').on('click', function () {
if ($("#ez_tune_enabled").is(":checked")) {
EZ_TUNE.enabled = 1;
} else {
EZ_TUNE.enabled = 0;
}
EZ_TUNE.filterHz = $('#ez_tune_filter_hz').val();
EZ_TUNE.axisRatio = $('#ez_tune_axis_ratio').val();
EZ_TUNE.response = $('#ez_tune_response').val();
EZ_TUNE.damping = $('#ez_tune_damping').val();
EZ_TUNE.stability = $('#ez_tune_stability').val();
EZ_TUNE.aggressiveness = $('#ez_tune_aggressiveness').val();
EZ_TUNE.rate = $('#ez_tune_rate').val();
EZ_TUNE.expo = $('#ez_tune_expo').val();
saveChainer.execute();
});
} }
}; };