mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-20 06:45:12 +03:00
Refactor pid-tuning -> tabs
This commit is contained in:
parent
aa47d04fdb
commit
af68114367
4 changed files with 63 additions and 98 deletions
|
@ -52,7 +52,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
});
|
||||
|
||||
function load_html() {
|
||||
$('#content').load("./tabs/pid_tuning.html", process_html);
|
||||
$('#content').load("./tabs/pid_tuning.html", process_html);
|
||||
}
|
||||
|
||||
function pid_and_rc_to_form() {
|
||||
|
@ -112,7 +112,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('.pid_filter input[name="yawLowpassFrequency"]').val(FILTER_CONFIG.yaw_lowpass_hz);
|
||||
} else {
|
||||
$('.tab-pid_tuning .subtab-filter').hide();
|
||||
$('.tab-pid_tuning .tab_container').hide();
|
||||
$('.tab-pid_tuning .tab-container').hide();
|
||||
$('.pid_tuning input[name="rc_rate_yaw"]').hide();
|
||||
}
|
||||
|
||||
|
@ -492,9 +492,9 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
var cutoff_min = FILTER_DEFAULT.gyro_lowpass_dyn_min_hz;
|
||||
var type = FILTER_DEFAULT.gyro_lowpass_type;
|
||||
if (FILTER_CONFIG.gyro_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.gyro_lowpass_dyn_min_hz < FILTER_CONFIG.gyro_lowpass_dyn_max_hz) {
|
||||
cutoff_min = FILTER_CONFIG.gyro_lowpass_dyn_min_hz;
|
||||
cutoff_min = FILTER_CONFIG.gyro_lowpass_dyn_min_hz;
|
||||
type = FILTER_CONFIG.gyro_lowpass_type;
|
||||
}
|
||||
}
|
||||
|
||||
$('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val(checked ? cutoff_min : 0).attr('disabled', !checked);
|
||||
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').attr('disabled', !checked);
|
||||
|
@ -538,9 +538,9 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
var cutoff_min = FILTER_DEFAULT.dterm_lowpass_dyn_min_hz;
|
||||
var type = FILTER_DEFAULT.dterm_lowpass_type;
|
||||
if (FILTER_CONFIG.dterm_lowpass_dyn_min_hz > 0 && FILTER_CONFIG.dterm_lowpass_dyn_min_hz < FILTER_CONFIG.dterm_lowpass_dyn_max_hz) {
|
||||
cutoff_min = FILTER_CONFIG.dterm_lowpass_dyn_min_hz;
|
||||
cutoff_min = FILTER_CONFIG.dterm_lowpass_dyn_min_hz;
|
||||
type = FILTER_CONFIG.dterm_lowpass_type;
|
||||
}
|
||||
}
|
||||
|
||||
$('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(checked ? cutoff_min : 0).attr('disabled', !checked);
|
||||
$('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').attr('disabled', !checked);
|
||||
|
@ -643,7 +643,7 @@ 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_lowpass_hz = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val());
|
||||
FILTER_CONFIG.gyro_lowpass_hz = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val());
|
||||
FILTER_CONFIG.dterm_lowpass_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val());
|
||||
FILTER_CONFIG.yaw_lowpass_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val());
|
||||
|
||||
|
@ -922,18 +922,18 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
const el = $('.tab-pid_tuning .subtab-' + name);
|
||||
el[name == subtabName ? 'show' : 'hide']();
|
||||
}
|
||||
$('.tab-pid_tuning .tab_container td').removeClass('active');
|
||||
$('.tab-pid_tuning .tab_container .' + subtabName).addClass('active');
|
||||
$('.tab-pid_tuning .tab-container .tab').removeClass('active');
|
||||
$('.tab-pid_tuning .tab-container .' + subtabName).addClass('active');
|
||||
self.activeSubtab = subtabName;
|
||||
}
|
||||
|
||||
activateSubtab(self.activeSubtab);
|
||||
|
||||
$('.tab-pid_tuning .tab_container .pid').on('click', () => activateSubtab('pid'));
|
||||
$('.tab-pid_tuning .tab-container .pid').on('click', () => activateSubtab('pid'));
|
||||
|
||||
$('.tab-pid_tuning .tab_container .rates').on('click', () => activateSubtab('rates'));
|
||||
$('.tab-pid_tuning .tab-container .rates').on('click', () => activateSubtab('rates'));
|
||||
|
||||
$('.tab-pid_tuning .tab_container .filter').on('click', () => activateSubtab('filter'));
|
||||
$('.tab-pid_tuning .tab-container .filter').on('click', () => activateSubtab('filter'));
|
||||
|
||||
function loadProfilesList() {
|
||||
var numberOfProfiles = 3;
|
||||
|
@ -965,7 +965,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
// This vars are used here for populate the profile (and rate profile) selector AND in the copy profile (and rate profile) window
|
||||
var selectRateProfileValues = loadRateProfilesList();
|
||||
var selectProfileValues = loadProfilesList();
|
||||
|
||||
|
||||
function populateProfilesSelector(selectProfileValues) {
|
||||
var profileSelect = $('select[name="profile"]');
|
||||
selectProfileValues.forEach(function(value, key) {
|
||||
|
@ -1025,7 +1025,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
MSP.promise(MSPCodes.MSP_SELECT_SETTING, [self.currentProfile]).then(function () {
|
||||
self.refresh(function () {
|
||||
self.updating = false;
|
||||
|
||||
|
||||
$('.tab-pid_tuning select[name="profile"]').prop('disabled', 'false');
|
||||
CONFIG.profile = self.currentProfile;
|
||||
|
||||
|
@ -1062,7 +1062,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
}
|
||||
}
|
||||
checkUpdateDtermTransitionWarning(dtermTransitionNumberElement.val());
|
||||
|
||||
|
||||
//Use 'input' event for coupled controls to allow synchronized update
|
||||
dtermTransitionNumberElement.on('input', function () {
|
||||
checkUpdateDtermTransitionWarning($(this).val());
|
||||
|
@ -1383,18 +1383,18 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('.dialogCopyProfile').find('.contentProfile').show();
|
||||
$('.dialogCopyProfile').find('.contentRateProfile').hide();
|
||||
dialogCopyProfileMode = DIALOG_MODE_PROFILE;
|
||||
dialogCopyProfile.showModal();
|
||||
dialogCopyProfile.showModal();
|
||||
});
|
||||
|
||||
$('.copyrateprofilebtn').click(function() {
|
||||
$('.dialogCopyProfile').find('.contentProfile').hide();
|
||||
$('.dialogCopyProfile').find('.contentRateProfile').show();
|
||||
dialogCopyProfileMode = DIALOG_MODE_RATEPROFILE;
|
||||
dialogCopyProfile.showModal();
|
||||
dialogCopyProfile.showModal();
|
||||
});
|
||||
|
||||
$('.dialogCopyProfile-cancelbtn').click(function() {
|
||||
dialogCopyProfile.close();
|
||||
dialogCopyProfile.close();
|
||||
});
|
||||
|
||||
$('.dialogCopyProfile-confirmbtn').click(function() {
|
||||
|
@ -1407,7 +1407,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case DIALOG_MODE_RATEPROFILE:
|
||||
COPY_PROFILE.type = DIALOG_MODE_RATEPROFILE; // 1 = rate profile
|
||||
COPY_PROFILE.dstProfile = parseInt(selectRateProfile.val());
|
||||
|
@ -1423,7 +1423,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function close_dialog() {
|
||||
dialogCopyProfile.close();
|
||||
dialogCopyProfile.close();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -1431,7 +1431,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('.copyrateprofilebtn').hide();
|
||||
}
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
|
||||
if (semver.gte(CONFIG.apiVersion, "1.42.0")) {
|
||||
// filter and tuning sliders
|
||||
TuningSliders.initialize();
|
||||
|
||||
|
@ -1698,8 +1698,8 @@ TABS.pid_tuning.initRatesPreview = function () {
|
|||
this.keepRendering = true;
|
||||
this.model = new Model($('.rates_preview'), $('.rates_preview canvas'));
|
||||
|
||||
$('.tab-pid_tuning .tab_container .rates').on('click', $.proxy(this.model.resize, this.model));
|
||||
$('.tab-pid_tuning .tab_container .rates').on('click', $.proxy(this.updateRatesLabels, this));
|
||||
$('.tab-pid_tuning .tab-container .rates').on('click', $.proxy(this.model.resize, this.model));
|
||||
$('.tab-pid_tuning .tab-container .rates').on('click', $.proxy(this.updateRatesLabels, this));
|
||||
|
||||
$(window).on('resize', $.proxy(this.model.resize, this.model));
|
||||
$(window).on('resize', $.proxy(this.updateRatesLabels, this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue