mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 17:25:14 +03:00
Basic preview of PIDFF
This commit is contained in:
parent
b0726bbe8c
commit
851e24031b
4 changed files with 104 additions and 12 deletions
|
@ -456,6 +456,7 @@ GUI_control.prototype.sliderize = function ($input, value, min, max) {
|
|||
}
|
||||
|
||||
$input.val(val);
|
||||
$input.trigger('updated');
|
||||
});
|
||||
|
||||
$input.on('change', function() {
|
||||
|
@ -474,6 +475,7 @@ GUI_control.prototype.sliderize = function ($input, value, min, max) {
|
|||
}
|
||||
|
||||
$range.val(newVal);
|
||||
$input.trigger('updated');
|
||||
});
|
||||
|
||||
$input.trigger('change');
|
||||
|
|
|
@ -436,18 +436,34 @@
|
|||
padding: 4px;
|
||||
}
|
||||
|
||||
.pid-sliders-axis[data-axis="roll"] {
|
||||
.pid-sliders-axis[data-axis="roll"],
|
||||
.pid-sliders-axis[data-axis="0"] {
|
||||
background-color: #8ecae6;
|
||||
}
|
||||
|
||||
.pid-sliders-axis[data-axis="pitch"] {
|
||||
.pid-sliders-axis[data-axis="pitch"],
|
||||
.pid-sliders-axis[data-axis="1"]
|
||||
{
|
||||
background-color: #00b4d8;
|
||||
}
|
||||
|
||||
.pid-sliders-axis[data-axis="yaw"] {
|
||||
.pid-sliders-axis[data-axis="yaw"],
|
||||
.pid-sliders-axis[data-axis="2"]
|
||||
{
|
||||
background-color: #e9c46a;
|
||||
}
|
||||
|
||||
.pid-sliders-axis[data-axis="3"]
|
||||
{
|
||||
background-color: #f4a261;
|
||||
}
|
||||
|
||||
#pid-sliders {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.ez-tune-preview {
|
||||
background-color: #f4a261;
|
||||
margin-left: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneFilterHz" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_filter_hz" type="number"/>
|
||||
<input id="ez_tune_filter_hz" type="number" class="ez-element"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
<span data-i18n="ezTuneAxisRatio" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_axis_ratio" type="number"/>
|
||||
<input id="ez_tune_axis_ratio" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneResponse" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_response" type="number"/>
|
||||
<input id="ez_tune_response" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneDamping" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_damping" type="number"/>
|
||||
<input id="ez_tune_damping" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -52,7 +52,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneStability" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_stability" type="number"/>
|
||||
<input id="ez_tune_stability" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneAggressiveness" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_aggressiveness" type="number"/>
|
||||
<input id="ez_tune_aggressiveness" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -73,7 +73,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneRate" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_rate" type="number"/>
|
||||
<input id="ez_tune_rate" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -82,7 +82,7 @@
|
|||
<div class="pid-slider-row">
|
||||
<span data-i18n="ezTuneExpo" class="bold"></span>
|
||||
<div class="number no-border">
|
||||
<input id="ez_tune_expo" type="number"/>
|
||||
<input id="ez_tune_expo" type="number" class="ez-element"/>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
|
@ -90,7 +90,41 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div>Bla</div>
|
||||
<div class="ez-tune-preview">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>P</th>
|
||||
<th>I</th>
|
||||
<th>D</th>
|
||||
<th>FF</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Roll</th>
|
||||
<td id="preview-roll-p"></td>
|
||||
<td id="preview-roll-i"></td>
|
||||
<td id="preview-roll-d"></td>
|
||||
<td id="preview-roll-ff"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Pitch</th>
|
||||
<td id="preview-pitch-p"></td>
|
||||
<td id="preview-pitch-i"></td>
|
||||
<td id="preview-pitch-d"></td>
|
||||
<td id="preview-pitch-ff"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Yaw</th>
|
||||
<td id="preview-yaw-p"></td>
|
||||
<td id="preview-yaw-i"></td>
|
||||
<td id="preview-yaw-d"></td>
|
||||
<td id="preview-yaw-ff"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ TABS.ez_tune.initialize = function (callback) {
|
|||
mspHelper.loadEzTune,
|
||||
];
|
||||
|
||||
let EZ_TUNE_PID_RP_DEFAULT = [40, 75, 23, 100];
|
||||
let EZ_TUNE_PID_YAW_DEFAULT = [45, 80, 0, 100];
|
||||
|
||||
loadChain.push(mspHelper.loadRateProfileData);
|
||||
|
||||
loadChainer.setChain(loadChain);
|
||||
|
@ -28,6 +31,37 @@ TABS.ez_tune.initialize = function (callback) {
|
|||
GUI.load("./tabs/ez_tune.html", Settings.processHtml(process_html));
|
||||
}
|
||||
|
||||
function getYawPidScale(input) {
|
||||
const normalized = (input - 100) * 0.01;
|
||||
|
||||
return 1.0 + (normalized * 0.5);
|
||||
}
|
||||
|
||||
function updatePreview() {
|
||||
|
||||
let axisRatio = $('#ez_tune_axis_ratio').val() / 100;
|
||||
let response = $('#ez_tune_response').val();
|
||||
let damping = $('#ez_tune_damping').val();
|
||||
let stability = $('#ez_tune_stability').val();
|
||||
let aggressiveness = $('#ez_tune_aggressiveness').val();
|
||||
|
||||
$('#preview-roll-p').html(Math.floor(EZ_TUNE_PID_RP_DEFAULT[0] * response / 100));
|
||||
$('#preview-roll-i').html(Math.floor(EZ_TUNE_PID_RP_DEFAULT[1] * stability / 100));
|
||||
$('#preview-roll-d').html(Math.floor(EZ_TUNE_PID_RP_DEFAULT[2] * damping / 100));
|
||||
$('#preview-roll-ff').html(Math.floor(EZ_TUNE_PID_RP_DEFAULT[3] * aggressiveness / 100));
|
||||
|
||||
$('#preview-pitch-p').html(Math.floor(axisRatio * EZ_TUNE_PID_RP_DEFAULT[0] * response / 100));
|
||||
$('#preview-pitch-i').html(Math.floor(axisRatio * EZ_TUNE_PID_RP_DEFAULT[1] * stability / 100));
|
||||
$('#preview-pitch-d').html(Math.floor(axisRatio * EZ_TUNE_PID_RP_DEFAULT[2] * damping / 100));
|
||||
$('#preview-pitch-ff').html(Math.floor(axisRatio * EZ_TUNE_PID_RP_DEFAULT[3] * aggressiveness / 100));
|
||||
|
||||
$('#preview-yaw-p').html(Math.floor(EZ_TUNE_PID_YAW_DEFAULT[0] * getYawPidScale(response)));
|
||||
$('#preview-yaw-i').html(Math.floor(EZ_TUNE_PID_YAW_DEFAULT[1] * getYawPidScale(stability)));
|
||||
$('#preview-yaw-d').html(Math.floor(EZ_TUNE_PID_YAW_DEFAULT[2] * getYawPidScale(damping)));
|
||||
$('#preview-yaw-ff').html(Math.floor(EZ_TUNE_PID_YAW_DEFAULT[3] * getYawPidScale(aggressiveness)));
|
||||
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
localize();
|
||||
|
||||
|
@ -44,6 +78,12 @@ TABS.ez_tune.initialize = function (callback) {
|
|||
GUI.sliderize($('#ez_tune_rate'), EZ_TUNE.rate, 0, 200);
|
||||
GUI.sliderize($('#ez_tune_expo'), EZ_TUNE.expo, 0, 200);
|
||||
|
||||
|
||||
$('.ez-element').on('updated', function () {
|
||||
updatePreview();
|
||||
});
|
||||
|
||||
|
||||
GUI.simpleBind();
|
||||
|
||||
GUI.content_ready(callback);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue