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

GUI for async gyro mode

This commit is contained in:
Pawel Spychalski (DzikuVx) 2016-11-30 20:08:11 +01:00
parent b68f9a15c4
commit dace7d27d8
5 changed files with 117 additions and 24 deletions

View file

@ -1810,5 +1810,11 @@
}, },
"pidTuningTPABreakPointHelp": { "pidTuningTPABreakPointHelp": {
"message": "Throttle PID Attenuation begins when Throttle position exceeds this value. " "message": "Throttle PID Attenuation begins when Throttle position exceeds this value. "
},
"configurationAsyncMode": {
"message": "Asynchronous mode"
},
"configurationGyroFrequencyTitle": {
"message": "Gyroscope frequency"
} }
} }

View file

@ -407,6 +407,31 @@ var FC = {
} }
}; };
}, },
getGyroFrequencies: function () {
return {
125: {
defaultLooptime: 1000,
looptimes: {
4000: "250Hz",
3000: "334Hz",
2000: "500Hz",
1500: "667Hz",
1000: "1kHz",
500: "2kHz",
250: "4kHz",
125: "8kHz"
}
},
1000: {
defaultLooptime: 1000,
looptimes: {
4000: "250Hz",
2000: "500Hz",
1000: "1kHz"
}
}
};
},
getGyroLpfValues: function () { getGyroLpfValues: function () {
return [ return [
{ {
@ -564,6 +589,12 @@ var FC = {
200: "200Hz", 200: "200Hz",
400: "400Hz" 400: "400Hz"
}; };
},
getAsyncModes: function () {
return [
'Disabled',
'Gyro',
'All'
]
} }
}; };

View file

@ -203,6 +203,7 @@
.tab-configuration .number, .tab-configuration .number,
.tab-configuration .select, .tab-configuration .select,
.tab-configuration .checkbox,
hr hr
{ {
margin-bottom: 5px; margin-bottom: 5px;
@ -214,7 +215,8 @@ hr
} }
.tab-configuration .number:last-child, .tab-configuration .number:last-child,
.tab-configuration .select:last-child { .tab-configuration .select:last-child,
.tab-configuration .checkbox:last-child{
border-bottom: none; border-bottom: none;
padding-bottom: 0; padding-bottom: 0;
margin-bottom: 0; margin-bottom: 0;

View file

@ -193,15 +193,24 @@
</div> </div>
<div class="spacer_box"> <div class="spacer_box">
<div class="checkbox requires-v1_4"> <div class="select requires-v1_4">
<div class="numberspacer"> <select id="async-mode"></select>
<input type="checkbox" id="gyro-sync-checkbox" class="toggle" /> <label for="async-mode"> <span data-i18n="configurationAsyncMode"></span></label>
</div> </div>
<label> <span data-i18n="configurationGyroSyncTitle"></span>
<div id="gyro-sync-wrapper" class="checkbox requires-v1_4">
<input type="checkbox" id="gyro-sync-checkbox" class="toggle" />
<label for="gyro-sync-checkbox">
<span data-i18n="configurationGyroSyncTitle"></span>
</label> </label>
</div> </div>
<hr class="requires-v1_4" /> <div id="gyro-frequency-wrapper" class="checkbox requires-v1_4">
<select id="gyro-frequency"></select>
<label for="gyro-frequency">
<span data-i18n="configurationGyroFrequencyTitle"></span>
</label>
</div>
<div class="select requires-v1_4"> <div class="select requires-v1_4">
<select id="gyro-lpf"></select> <select id="gyro-lpf"></select>
@ -210,8 +219,8 @@
<div class="select"> <div class="select">
<select id="looptime"></select> <select id="looptime"></select>
<label for="looptime"> <span <label for="looptime">
data-i18n="configurationLoopTime"></span> <span data-i18n="configurationLoopTime"></span>
</label> </label>
</div> </div>
</div> </div>

View file

@ -354,14 +354,20 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('#servo-rate-container').show(); $('#servo-rate-container').show();
} }
var gyroLpfValues = FC.getGyroLpfValues(); var gyroLpfValues = FC.getGyroLpfValues(),
var looptimes = FC.getLooptimes(); looptimes = FC.getLooptimes(),
var $looptime = $("#looptime"); $looptime = $("#looptime"),
asyncModes = FC.getAsyncModes(),
gyroFrequencies = FC.getGyroFrequencies();
if (semver.gte(CONFIG.flightControllerVersion, "1.4.0")) { if (semver.gte(CONFIG.flightControllerVersion, "1.4.0")) {
$(".requires-v1_4").show();
var $gyroLpf = $("#gyro-lpf"), var $gyroLpf = $("#gyro-lpf"),
$gyroSync = $("#gyro-sync-checkbox"); $gyroSync = $("#gyro-sync-checkbox"),
$asyncMode = $('#async-mode'),
$gyroFrequency = $('#gyro-frequency');
for (i in gyroLpfValues) { for (i in gyroLpfValues) {
if (gyroLpfValues.hasOwnProperty(i)) { if (gyroLpfValues.hasOwnProperty(i)) {
@ -373,36 +379,51 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$gyroSync.prop("checked", ADVANCED_CONFIG.gyroSync); $gyroSync.prop("checked", ADVANCED_CONFIG.gyroSync);
$gyroLpf.change(function () { $gyroLpf.change(function () {
var i,
looptimeOptions;
INAV_PID_CONFIG.gyroscopeLpf = $gyroLpf.val(); INAV_PID_CONFIG.gyroscopeLpf = $gyroLpf.val();
$looptime.find("*").remove(); $looptime.find("*").remove();
var looptimeOptions = looptimes[gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick]; looptimeOptions = looptimes[gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick];
for (var i in looptimeOptions.looptimes) { for (i in looptimeOptions.looptimes) {
if (looptimeOptions.looptimes.hasOwnProperty(i)) { if (looptimeOptions.looptimes.hasOwnProperty(i)) {
$looptime.append('<option value="' + i + '">' + looptimeOptions.looptimes[i] + '</option>'); $looptime.append('<option value="' + i + '">' + looptimeOptions.looptimes[i] + '</option>');
} }
} }
$looptime.val(looptimeOptions.defaultLooptime); $looptime.val(looptimeOptions.defaultLooptime);
$looptime.change(); $looptime.change();
$gyroFrequency.find("*").remove();
looptimeOptions = gyroFrequencies[gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick];
for (i in looptimeOptions.looptimes) {
if (looptimeOptions.looptimes.hasOwnProperty(i)) {
$gyroFrequency.append('<option value="' + i + '">' + looptimeOptions.looptimes[i] + '</option>');
}
}
$gyroFrequency.val(looptimeOptions.defaultLooptime);
$gyroFrequency.change();
}); });
$gyroLpf.change(); $gyroLpf.change();
$looptime.val(FC_CONFIG.loopTime);
$looptime.val(FC_CONFIG.loopTime);
$looptime.change(function () { $looptime.change(function () {
FC_CONFIG.loopTime = $(this).val();
if (INAV_PID_CONFIG.asynchronousMode == 0) { if (INAV_PID_CONFIG.asynchronousMode == 0) {
//All task running together //All task running together
FC_CONFIG.loopTime = $(this).val();
ADVANCED_CONFIG.gyroSyncDenominator = Math.floor(FC_CONFIG.loopTime / gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick);
} else {
//FIXME this is temporaty fix that gives the same functionality to ASYNC_MODE=GYRO and ALL
FC_CONFIG.loopTime = $(this).val();
ADVANCED_CONFIG.gyroSyncDenominator = Math.floor(FC_CONFIG.loopTime / gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick); ADVANCED_CONFIG.gyroSyncDenominator = Math.floor(FC_CONFIG.loopTime / gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick);
} }
}); });
$looptime.change(); $looptime.change();
$gyroFrequency.val(ADVANCED_CONFIG.gyroSyncDenominator * gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick);
$gyroFrequency.change(function () {
ADVANCED_CONFIG.gyroSyncDenominator = Math.floor($gyroFrequency.val() / gyroLpfValues[INAV_PID_CONFIG.gyroscopeLpf].tick);
});
$gyroSync.change(function () { $gyroSync.change(function () {
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
ADVANCED_CONFIG.gyroSync = 1; ADVANCED_CONFIG.gyroSync = 1;
@ -413,7 +434,31 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$gyroSync.change(); $gyroSync.change();
$(".requires-v1_4").show(); /*
* Async mode select
*/
for (i in asyncModes) {
if (asyncModes.hasOwnProperty(i)) {
$asyncMode.append('<option value="' + i + '">' + asyncModes[i] + '</option>');
}
}
$asyncMode.val(INAV_PID_CONFIG.asynchronousMode);
$asyncMode.change(function () {
INAV_PID_CONFIG.asynchronousMode = $asyncMode.val();
if (INAV_PID_CONFIG.asynchronousMode == 0) {
$('#gyro-sync-wrapper').show();
$('#gyro-frequency-wrapper').hide();
} else {
$('#gyro-sync-wrapper').hide();
$('#gyro-frequency-wrapper').show();
ADVANCED_CONFIG.gyroSync = 1;
}
});
$asyncMode.change();
} else { } else {
var looptimeOptions = looptimes[125]; var looptimeOptions = looptimes[125];
for (i in looptimeOptions.looptimes) { for (i in looptimeOptions.looptimes) {