Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,15 @@
"pidTuningVbatPidCompensationHelp": {
"message": "Increases the PID values to compensate when Vbat gets lower. This will give more constant flight characteristics throughout the flight. The amount of compensation that is applied is calculated from the $t(powerBatteryMaximum.message) set in the $t(tabPower.message) page, so make sure that is set to something appropriate."
},
"pidTuningVbatSagCompensation": {
"message": "Vbat Sag Compensation"
},
"pidTuningVbatSagCompensationHelp": {
"message": "Gives consistent throttle and PID performance over the usable battery voltage range by compensating for battery sag. The amount of compensation can be varied between 0 and 100%. Full compensation (100%) is recommended.<br><br>Visit <a href=\"https://github.com/betaflight/betaflight/wiki/4.2-Tuning-Notes#dynamic-battery-sag-compensation\"target=\"_blank\" rel=\"noopener noreferrer\">this wiki entry</a> for more info."
},
"pidTuningVbatSagValue": {
"message": "%"
},
"pidTuningItermRotation": {
"message": "I Term Rotation"
},
Expand Down
1 change: 1 addition & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ var FC = {
ff_interpolate_sp: 0,
ff_smooth_factor: 0,
ff_boost: 0,
vbat_sag_compensation: 0,
};
ADVANCED_TUNING_ACTIVE = { ...ADVANCED_TUNING };

Expand Down
4 changes: 3 additions & 1 deletion src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
ADVANCED_TUNING.ff_interpolate_sp = data.readU8();
ADVANCED_TUNING.ff_smooth_factor = data.readU8();
ADVANCED_TUNING.ff_boost = data.readU8();
ADVANCED_TUNING.vbat_sag_compensation = data.readU8();
}
}
}
Expand Down Expand Up @@ -2096,7 +2097,8 @@ MspHelper.prototype.crunch = function(code) {
if(semver.gte(CONFIG.apiVersion, API_VERSION_1_44)) {
buffer.push8(ADVANCED_TUNING.ff_interpolate_sp)
.push8(ADVANCED_TUNING.ff_smooth_factor)
.push8(ADVANCED_TUNING.ff_boost);
.push8(ADVANCED_TUNING.ff_boost)
.push8(ADVANCED_TUNING.vbat_sag_compensation);
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/js/tabs/pid_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,21 @@ TABS.pid_tuning.initialize = function (callback) {
ffInterpolateCheck.change(function() {
const checked = $(this).is(':checked');
$('.ffInterpolateSp .suboption').toggle(checked);
});
ffInterpolateCheck.change();
}).change();

// Vbat Sag Compensation
const vbatSagCompensationCheck = $('input[id="vbatSagCompensation"]');

vbatSagCompensationCheck.prop('checked', ADVANCED_TUNING.vbat_sag_compensation !== 0);
$('input[name="vbatSagValue"]').val(ADVANCED_TUNING.vbat_sag_compensation > 0 ? ADVANCED_TUNING.vbat_sag_compensation : 100);

vbatSagCompensationCheck.change(function() {
const checked = $(this).is(':checked');
$('.vbatSagCompensation .suboption').toggle(checked);
}).change();
} else {
$('.ffInterpolateSp').hide();
$('.vbatSagCompensation').hide();
}

$('input[id="useIntegratedYaw"]').change(function() {
Expand Down Expand Up @@ -921,6 +931,7 @@ TABS.pid_tuning.initialize = function (callback) {
ADVANCED_TUNING.ff_smooth_factor = parseInt($('input[name="ffSmoothFactor"]').val());
ADVANCED_TUNING.ff_boost = parseInt($('input[name="ffBoost"]').val());
FILTER_CONFIG.dyn_lpf_curve_expo = parseInt($('.pid_filter input[name="dtermLowpassDynExpo"]').val());
ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0;
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/tabs/pid_tuning.html
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,21 @@
</td>
</tr>

<tr class="vbatSagCompensation">
<td><input type="checkbox" id="vbatSagCompensation" class="toggle" /></td>
<td colspan="2">
<span i18n="pidTuningVbatSagCompensation"></span>
<div class="helpicon cf_tip" i18n_title="pidTuningVbatSagCompensationHelp"></div>

<span class="vbatSagValue suboption">
<input type="number" name="vbatSagValue" step="1" min="1" max="150" />
<label for="vbatSagValue">
<span i18n="pidTuningVbatSagValue"></span>
</label>
</span>
</td>
</tr>

<tr class="smartfeedforward">
<td><input type="checkbox" id="smartfeedforward" class="toggle" /></td>
<td colspan="2">
Expand Down