1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 16:55:24 +03:00

Merge pull request #64 from mikeller/clean_up_pid_tab

Cleaned up PID tab, made blocks show / hide properly.
This commit is contained in:
borisbstyle 2016-06-30 14:46:34 +02:00 committed by GitHub
commit d2f7a7b8cd
4 changed files with 119 additions and 63 deletions

View file

@ -1543,17 +1543,32 @@
"pidTuningGps": {
"message": "GPS Navigation"
},
"pidTuningLevelP": {
"message": "Strength (Angle)"
"pidTuningStrength": {
"message": "Strength"
},
"pidTuningLevelI": {
"message": "Strength (Horizon)"
"pidTuningTransition": {
"message": "Transition"
},
"pidTuningLevelD": {
"message": "Transition (Horizon)"
"pidTuningHorizon": {
"message": "Horizon"
},
"pidTuningAngle": {
"message": "Angle"
},
"pidTuningLevelHelp": {
"message": "The values below change the behaviour of the ANGLE and HORIZON flight modes. Different PID controllers handle the LEVEL values differently. Please check the documentation."
"message": "The values below change the behaviour of the ANGLE and HORIZON flight modes. Different PID controllers handle the values differently. Please check the documentation."
},
"pidTuningLfpFilters": {
"message": "LFP Filters"
},
"pidTuningGyro": {
"message": "Gyro Soft (Hz)"
},
"pidTuningDTerm": {
"message": "D Term (Hz)"
},
"pidTuningYaw": {
"message": "Yaw (Hz)"
},
"configHelp2": {
"message": "Arbitrary board rotation in degrees, to allow mounting it sideways / upside down / rotated etc. When running external sensors, use the sensor alignments (Gyro, Acc, Mag) to define sensor position independent from board orientation. "

View file

@ -1354,6 +1354,10 @@ dialog {
border-style: dotted;
}
.third {
width: 33%;
}
.noboarder td {
border: none;
}

View file

@ -95,7 +95,7 @@
</tr>
</table>
</div>
<div class="gui_box grey topspacer">
<div id="pid_optional" class="gui_box grey topspacer pid_tuning">
<table class="pid_titlebar">
<tr>
<th class="name" i18n="pidTuningName"></th>
@ -169,39 +169,55 @@
</tr>
</table>
</div>
<div class="gui_box grey topspacer">
<table id="pid_accel" class="pid_tuning">
<tr class="fancy header">
<th>
<div class="pidTuningLevel" i18n="pidTuningLevel"></div>
<div class="helpicon cf_tip" i18n_title="pidTuningLevelHelp"></div>
</th>
<th i18n="pidTuningLevelP"></th>
<th i18n="pidTuningLevelI"></th>
<th i18n="pidTuningLevelD"></th>
<div id="pid_accel" class="gui_box grey topspacer pid_tuning">
<table class="pid_titlebar">
<tr>
<th class="third" i18n="pidTuningName"></th>
<th class="third" i18n="pidTuningStrength"></th>
<th class="third" i18n="pidTuningTransition"></th>
</tr>
<tr class="LEVEL">
</table>
<table>
<tr>
<th colspan="3">
<div class="pid_mode">
<div class="spacer_box_title" i18n="pidTuningLevel"></div>
<div class="helpicon cf_tip" i18n_title="pidTuningLevelHelp"></div>
</div>
</th>
</tr>
<tr class="HORIZON">
<!-- 7 -->
<td></td>
<td><input type="number" name="p" step="1" min="0" max="255" /></td>
<td><input type="number" name="i" step="1" min="0" max="255" /></td>
<td><input type="number" name="d" step="1" min="0" max="255" /></td>
<td class="third" i18n="pidTuningHorizon"></td>
<td class="third"><input type="number" name="p" step="1" min="0" max="255" /></td>
<td class="third"><input type="number" name="i" step="1" min="0" max="255" /></td>
</tr>
<tr class="ANGLE">
<!-- 7 -->
<td class="third" i18n="pidTuningAngle"></td>
<td class="third"><input type="number" name="d" step="1" min="0" max="255" /></td>
<td></td>
</tr>
</table>
</div>
<div class="gui_box grey topspacer">
<table class="pid_filter" class="pid_tuning">
<tr class="fancy header">
<th>LFP Filters (Hz)</th>
<th>Gyro Soft</th>
<th>D Term</th>
<th>Yaw</th>
<div id="pid_filter" class="gui_box grey topspacer pid_tuning">
<table class="pid_titlebar">
<tr>
<th class="third" i18n="pidTuningGyro"></th>
<th class="third" i18n="pidTuningDTerm"></th>
<th class="third" i18n="pidTuningYaw"></th>
</tr>
</table>
<table>
<tr>
<th colspan="3">
<div class="pid_mode" i18n="pidTuningLfpFilters"> </div>
</th>
</tr>
<tr>
<td></td>
<td><input type="number" class="gyro" step="1" min="0" max="255" /></td>
<td><input type="number" class="dterm" step="1" min="0" max="500" /></td>
<td><input type="number" class="yaw" step="1" min="0" max="500" /></td>
<td class="third"><input type="number" name="gyro" step="1" min="0" max="255" /></td>
<td class="third"><input type="number" name="dterm" step="1" min="0" max="500" /></td>
<td class="third"><input type="number" name="yaw" step="1" min="0" max="500" /></td>
</tr>
</table>
</div>
@ -336,4 +352,4 @@
<a class="refresh" href="#" i18n="pidTuningButtonRefresh"></a>
</div>
</div>
</div>
</div>

View file

@ -130,7 +130,7 @@ TABS.pid_tuning.initialize = function (callback) {
});
i = 0;
$('.pid_tuning .LEVEL input').each(function () {
$('.pid_tuning .HORIZON input').each(function () {
switch (i) {
case 0:
$(this).val(PIDs[7][i++]);
@ -138,6 +138,10 @@ TABS.pid_tuning.initialize = function (callback) {
case 1:
$(this).val(PIDs[7][i++]);
break;
}
});
$('.pid_tuning .ANGLE input').each(function () {
switch (i) {
case 2:
$(this).val(PIDs[7][i++]);
break;
@ -185,11 +189,11 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3");
}
$('.pid_filter .gyro').val(FILTER_CONFIG.gyro_soft_lpf_hz);
$('.pid_filter .dterm').val(FILTER_CONFIG.dterm_lpf_hz);
$('.pid_filter .yaw').val(FILTER_CONFIG.yaw_lpf_hz);
$('.pid_tuning input[name="gyro"]').val(FILTER_CONFIG.gyro_soft_lpf_hz);
$('.pid_tuning input[name="dterm"]').val(FILTER_CONFIG.dterm_lpf_hz);
$('.pid_tuning input[name="yaw"]').val(FILTER_CONFIG.yaw_lpf_hz);
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
if (CONFIG.flightControllerIdentifier !== "BTFL" || semver.lt(CONFIG.flightControllerVersion, "2.8.1")) {
$('.pid_filter').hide();
$('.pid_tuning input[name="rc_rate_yaw"]').hide();
}
@ -238,7 +242,10 @@ TABS.pid_tuning.initialize = function (callback) {
});
i = 0;
$('table.pid_tuning tr.LEVEL input').each(function () {
$('table.pid_tuning tr.HORIZON input').each(function () {
PIDs[7][i++] = parseFloat($(this).val());
});
$('table.pid_tuning tr.ANGLE input').each(function () {
PIDs[7][i++] = parseFloat($(this).val());
});
@ -262,30 +269,44 @@ TABS.pid_tuning.initialize = function (callback) {
RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val());
RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val());
FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_filter .gyro').val());
FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_filter .dterm').val());
FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_filter .yaw').val());
FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_tuning input[name="gyro"]').val());
FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_tuning input[name="dterm"]').val());
FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_tuning input[name="yaw"]').val());
}
function hideUnusedPids(sensors_detected) {
$('.tab-pid_tuning table.pid_tuning').hide();
$('#pid_main').show();
if (have_sensor(sensors_detected, 'acc')) {
$('#pid_accel').show();
}
if (have_sensor(sensors_detected, 'baro')) {
$('#pid_baro').show();
}
if (have_sensor(sensors_detected, 'mag')) {
$('#pid_mag').show();
}
if (bit_check(BF_CONFIG.features, 7)) { //This will need to be reworked to remove BF_CONFIG reference eventually
$('#pid_gps').show();
}
if (have_sensor(sensors_detected, 'sonar')) {
$('#pid_baro').show();
}
function hideUnusedPids(sensors_detected) {
$('.tab-pid_tuning .pid_tuning').hide();
$('#pid_main').show();
if (CONFIG.flightControllerIdentifier === "BTFL" || semver.ge(CONFIG.flightControllerVersion, "2.9.0")) {
$('#pid_filter').show();
}
if (have_sensor(sensors_detected, 'acc')) {
$('#pid_accel').show();
}
var showTitle = false;
if (have_sensor(sensors_detected, 'baro') ||
have_sensor(sensors_detected, 'sonar')) {
$('#pid_baro').show();
showTitle = true;
}
if (have_sensor(sensors_detected, 'mag')) {
$('#pid_mag').show();
showTitle = true;
}
if (bit_check(BF_CONFIG.features, 7)) { //This will need to be reworked to remove BF_CONFIG reference eventually
$('#pid_gps').show();
showTitle = true;
}
if (showTitle) {
$('#pid_optional').show();
}
}
function process_html() {
// translate to user-selected language
localize();
@ -294,7 +315,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('#showAllPids').on('click', function(){
if($(this).text() == "Show all PIDs") {
$('.tab-pid_tuning table.pid_tuning').show();
$('.tab-pid_tuning .pid_tuning').show();
$(this).text('Hide unused PIDs');
} else {
hideUnusedPids(CONFIG.activeSensors);