1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 00:05:22 +03:00

Merge pull request #353 from mikeller/remove_pid_controller_selection

Removed PID controller selection for firmware >= 3.1.0.
This commit is contained in:
Michael Keller 2016-12-12 12:49:47 +13:00 committed by GitHub
commit dc14455e81

View file

@ -339,7 +339,7 @@ TABS.pid_tuning.initialize = function (callback) {
RC_tuning.rcYawRate = parseFloat($('.pid_tuning input[name="rc_rate_yaw"]').val()); RC_tuning.rcYawRate = parseFloat($('.pid_tuning input[name="rc_rate_yaw"]').val());
RC_tuning.throttle_MID = parseFloat($('.throttle input[name="mid"]').val()); RC_tuning.throttle_MID = parseFloat($('.throttle input[name="mid"]').val());
RC_tuning.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').val()) RC_tuning.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').val());
RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val()); RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val());
RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val()); RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val());
@ -612,27 +612,29 @@ TABS.pid_tuning.initialize = function (callback) {
var pidController_e = $('select[name="controller"]'); var pidController_e = $('select[name="controller"]');
if (semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
var pidControllerList; var pidControllerList;
if (semver.lt(CONFIG.apiVersion, "1.14.0")) { if (semver.lt(CONFIG.apiVersion, "1.14.0")) {
pidControllerList = [ pidControllerList = [
{ name: "MultiWii (Old)"}, {name: "MultiWii (Old)"},
{ name: "MultiWii (rewrite)"}, {name: "MultiWii (rewrite)"},
{ name: "LuxFloat"}, {name: "LuxFloat"},
{ name: "MultiWii (2.3 - latest)"}, {name: "MultiWii (2.3 - latest)"},
{ name: "MultiWii (2.3 - hybrid)"}, {name: "MultiWii (2.3 - hybrid)"},
{ name: "Harakiri"} {name: "Harakiri"}
] ]
} else if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { } else if (semver.lt(CONFIG.flightControllerVersion, "3.0.0")) {
pidControllerList = [ pidControllerList = [
{ name: "Legacy"}, {name: ""},
{ name: "Betaflight"}, {name: "Integer"},
{name: "Float"}
] ]
} else { } else {
pidControllerList = [ pidControllerList = [
{ name: ""}, {name: "Legacy"},
{ name: "Integer"}, {name: "Betaflight"}
{ name: "Float"},
] ]
} }
@ -652,6 +654,11 @@ TABS.pid_tuning.initialize = function (callback) {
pidController_e.prop('disabled', true); pidController_e.prop('disabled', true);
} }
} else {
$('.tab-pid_tuning div.controller').hide();
self.updatePidControllerParameters();
}
if (semver.lt(CONFIG.apiVersion, "1.7.0")) { if (semver.lt(CONFIG.apiVersion, "1.7.0")) {
$('.tpa .tpa-breakpoint').hide(); $('.tpa .tpa-breakpoint').hide();
@ -743,7 +750,7 @@ TABS.pid_tuning.initialize = function (callback) {
updateNeeded = false; updateNeeded = false;
} }
}, 0); }, 0);
}; }
// UI Hooks // UI Hooks
// curves // curves
@ -814,11 +821,13 @@ TABS.pid_tuning.initialize = function (callback) {
}); });
} }
if (semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
pidController_e.change(function () { pidController_e.change(function () {
self.setDirty(true); self.setDirty(true);
self.updatePidControllerParameters(); self.updatePidControllerParameters();
}); });
}
// update == save. // update == save.
$('a.update').click(function () { $('a.update').click(function () {
@ -828,7 +837,7 @@ TABS.pid_tuning.initialize = function (callback) {
Promise.resolve(true) Promise.resolve(true)
.then(function () { .then(function () {
var promise; var promise;
if (semver.gte(CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion)) { if (semver.gte(CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion) && semver.lt(CONFIG.flightControllerVersion, "3.1.0")) {
PID.controller = pidController_e.val(); PID.controller = pidController_e.val();
promise = MSP.promise(MSPCodes.MSP_SET_PID_CONTROLLER, mspHelper.crunch(MSPCodes.MSP_SET_PID_CONTROLLER)); promise = MSP.promise(MSPCodes.MSP_SET_PID_CONTROLLER, mspHelper.crunch(MSPCodes.MSP_SET_PID_CONTROLLER));
} }
@ -939,21 +948,21 @@ TABS.pid_tuning.refresh = function (callback) {
callback(); callback();
} }
}); });
} };
TABS.pid_tuning.setProfile = function () { TABS.pid_tuning.setProfile = function () {
var self = this; var self = this;
self.currentProfile = CONFIG.profile; self.currentProfile = CONFIG.profile;
$('.tab-pid_tuning select[name="profile"]').val(self.currentProfile); $('.tab-pid_tuning select[name="profile"]').val(self.currentProfile);
} };
TABS.pid_tuning.setRateProfile = function () { TABS.pid_tuning.setRateProfile = function () {
var self = this; var self = this;
self.currentRateProfile = CONFIG.rateProfile; self.currentRateProfile = CONFIG.rateProfile;
$('.tab-pid_tuning select[name="rate_profile"]').val(self.currentRateProfile); $('.tab-pid_tuning select[name="rate_profile"]').val(self.currentRateProfile);
} };
TABS.pid_tuning.setDirty = function (isDirty) { TABS.pid_tuning.setDirty = function (isDirty) {
var self = this; var self = this;
@ -963,7 +972,7 @@ TABS.pid_tuning.setDirty = function (isDirty) {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) {
$('.tab-pid_tuning select[name="rate_profile"]').prop('disabled', isDirty); $('.tab-pid_tuning select[name="rate_profile"]').prop('disabled', isDirty);
} }
} };
TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) { TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) {
var self = this; var self = this;
@ -1004,7 +1013,7 @@ TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) {
} }
} }
} }
} };
TABS.pid_tuning.checkRC = function() { TABS.pid_tuning.checkRC = function() {
// Function monitors for change in the primary axes rc received data and returns true if a change is detected. // Function monitors for change in the primary axes rc received data and returns true if a change is detected.
@ -1023,8 +1032,7 @@ TABS.pid_tuning.checkRC = function() {
}; };
TABS.pid_tuning.updatePidControllerParameters = function () { TABS.pid_tuning.updatePidControllerParameters = function () {
if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { if (semver.gte(CONFIG.flightControllerVersion, "3.0.0") && semver.lt(CONFIG.flightControllerVersion, "3.1.0") && $('.tab-pid_tuning select[name="controller"]').val() === '0') {
if ($('.tab-pid_tuning select[name="controller"]').val() === '0') {
$('.pid_tuning .YAW_JUMP_PREVENTION').show(); $('.pid_tuning .YAW_JUMP_PREVENTION').show();
$('#pid-tuning .delta').show(); $('#pid-tuning .delta').show();
@ -1039,8 +1047,7 @@ TABS.pid_tuning.updatePidControllerParameters = function () {
$('#pid-tuning .delta').hide(); $('#pid-tuning .delta').hide();
} }
} };
}
TABS.pid_tuning.updateRatesLabels = function() { TABS.pid_tuning.updateRatesLabels = function() {
var self = this; var self = this;
@ -1051,7 +1058,8 @@ TABS.pid_tuning.updateRatesLabels = function() {
context.fillStyle = color || '#000000' ; context.fillStyle = color || '#000000' ;
context.textAlign = align || 'center'; context.textAlign = align || 'center';
context.fillText(axisLabel, x, y); context.fillText(axisLabel, x, y);
} };
var drawBalloonLabel = function(context, axisLabel, x, y, align, colors, dirty) { var drawBalloonLabel = function(context, axisLabel, x, y, align, colors, dirty) {
/** /**
@ -1138,7 +1146,7 @@ TABS.pid_tuning.updateRatesLabels = function() {
// and add the label // and add the label
drawAxisLabel(context, axisLabel, x + (width/2), y + (height + fontSize)/2 - 4, 'center', colors.text); drawAxisLabel(context, axisLabel, x + (width/2), y + (height + fontSize)/2 - 4, 'center', colors.text);
} };
const BALLOON_COLORS = { const BALLOON_COLORS = {
roll : {color: 'rgba(255,128,128,0.4)', border: 'rgba(255,128,128,0.6)', text: '#000000'}, roll : {color: 'rgba(255,128,128,0.4)', border: 'rgba(255,128,128,0.6)', text: '#000000'},
@ -1190,10 +1198,10 @@ TABS.pid_tuning.updateRatesLabels = function() {
currentValues = []; currentValues = [];
} }
stickContext.lineWidth = 1 * lineScale; stickContext.lineWidth = lineScale;
// use a custom scale so that the text does not appear stretched // use a custom scale so that the text does not appear stretched
stickContext.scale(textScale,1); stickContext.scale(textScale, 1);
// add the maximum range label // add the maximum range label
drawAxisLabel(stickContext, maxAngularVel.toFixed(0) + ' deg/s', ((curveWidth / 2) - 10) / textScale, parseInt(stickContext.font)*1.2, 'right'); drawAxisLabel(stickContext, maxAngularVel.toFixed(0) + ' deg/s', ((curveWidth / 2) - 10) / textScale, parseInt(stickContext.font)*1.2, 'right');