diff --git a/locales/en/messages.json b/locales/en/messages.json index 4f4b7280..4c715b13 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -3707,6 +3707,15 @@ "pidTuningVbatSagValue": { "message": "%" }, + "pidTuningThrustLinearization": { + "message": "Thrust Linearization" + }, + "pidTuningThrustLinearizationHelp": { + "message": "Compensates for the non-linear relationship between throttle and thrust by applying an inverse motor curve to the motor output. The amount of compensation can be varied between 0 and 150%." + }, + "pidTuningThrustLinearValue": { + "message": "%" + }, "pidTuningItermRotation": { "message": "I Term Rotation" }, diff --git a/src/js/fc.js b/src/js/fc.js index 9ce73051..10b8b3d0 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -466,6 +466,7 @@ const FC = { ff_smooth_factor: 0, ff_boost: 0, vbat_sag_compensation: 0, + thrustLinearization: 0, }; this.ADVANCED_TUNING_ACTIVE = { ...this.ADVANCED_TUNING }; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index c280a85f..bb99b7a4 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1166,6 +1166,7 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.ADVANCED_TUNING.ff_smooth_factor = data.readU8(); FC.ADVANCED_TUNING.ff_boost = data.readU8(); FC.ADVANCED_TUNING.vbat_sag_compensation = data.readU8(); + FC.ADVANCED_TUNING.thrustLinearization = data.readU8(); } } } @@ -2112,7 +2113,8 @@ MspHelper.prototype.crunch = function(code) { buffer.push8(FC.ADVANCED_TUNING.ff_interpolate_sp) .push8(FC.ADVANCED_TUNING.ff_smooth_factor) .push8(FC.ADVANCED_TUNING.ff_boost) - .push8(FC.ADVANCED_TUNING.vbat_sag_compensation); + .push8(FC.ADVANCED_TUNING.vbat_sag_compensation) + .push8(FC.ADVANCED_TUNING.thrustLinearization); } } } diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 1d5e3b28..28501389 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -483,9 +483,21 @@ TABS.pid_tuning.initialize = function (callback) { const checked = $(this).is(':checked'); $('.vbatSagCompensation .suboption').toggle(checked); }).change(); + + // Thrust Linearization + const thrustLinearizationCheck = $('input[id="thrustLinearization"]'); + + thrustLinearizationCheck.prop('checked', FC.ADVANCED_TUNING.thrustLinearization !== 0); + $('input[name="thrustLinearValue"]').val(FC.ADVANCED_TUNING.thrustLinearization > 0 ? FC.ADVANCED_TUNING.thrustLinearization : 20); + + thrustLinearizationCheck.change(function() { + const checked = $(this).is(':checked'); + $('.thrustLinearization .suboption').toggle(checked); + }).change(); } else { $('.ffInterpolateSp').hide(); $('.vbatSagCompensation').hide(); + $('.thrustLinearization').hide(); } $('input[id="useIntegratedYaw"]').change(function() { @@ -955,6 +967,7 @@ TABS.pid_tuning.initialize = function (callback) { FC.ADVANCED_TUNING.ff_boost = parseInt($('input[name="ffBoost"]').val()); FC.FILTER_CONFIG.dyn_lpf_curve_expo = parseInt($('.pid_filter input[name="dtermLowpassDynExpo"]').val()); FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0; + FC.ADVANCED_TUNING.thrustLinearization = $('input[id="thrustLinearization"]').is(':checked') ? parseInt($('input[name="thrustLinearValue"]').val()) : 0; } } diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index f3406cbc..77df8f7c 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -610,6 +610,21 @@ + +