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

hover point throttle curve adjustment (#4245)

* hover point throttle curve adjustment

* added throttle_HOVER reading/writing via MSP

* moved throttle_HOVER position
This commit is contained in:
Marc Frank 2025-04-10 15:50:47 +02:00 committed by GitHub
parent dfad5b0f73
commit 5adb12a8c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 6 deletions

View file

@ -2338,6 +2338,9 @@
"receiverThrottleExpo": {
"message": "Throttle EXPO"
},
"receiverThrottleHover": {
"message": "Hover Point"
},
"receiverStickMin": {
"message": "'Stick Low' Threshold"
},

View file

@ -295,6 +295,7 @@ const FC = {
pitch_rate_limit: 1998,
yaw_rate_limit: 1998,
rates_type: 0,
throttle_HOVER: 0,
};
this.AUX_CONFIG = [];

View file

@ -466,6 +466,7 @@ MspHelper.prototype.process_data = function (dataHandler) {
FC.RC_TUNING.pitch_rate_limit = data.readU16();
FC.RC_TUNING.yaw_rate_limit = data.readU16();
FC.RC_TUNING.rates_type = data.readU8();
FC.RC_TUNING.throttle_HOVER = parseFloat((data.readU8() / 100).toFixed(2));
break;
case MSPCodes.MSP_PID:
// PID data arrived, we need to scale it and save to appropriate bank / array
@ -1839,6 +1840,11 @@ MspHelper.prototype.crunch = function (code, modifierCode = undefined) {
// Introduced in 1.43
buffer.push8(FC.RC_TUNING.rates_type);
// Introduced in 1.47
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
buffer.push8(Math.round(FC.RC_TUNING.throttle_HOVER * 100));
}
break;
case MSPCodes.MSP_SET_RX_MAP:
for (let i = 0; i < FC.RC_MAP.length; i++) {

View file

@ -123,6 +123,7 @@ pid_tuning.initialize = function (callback) {
$('.throttle input[name="mid"]').val(FC.RC_TUNING.throttle_MID.toFixed(2));
$('.throttle input[name="expo"]').val(FC.RC_TUNING.throttle_EXPO.toFixed(2));
$('.throttle input[name="hover"]').val(FC.RC_TUNING.throttle_HOVER.toFixed(2));
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// Moved tpa to profile
@ -890,6 +891,7 @@ pid_tuning.initialize = function (callback) {
FC.RC_TUNING.throttle_MID = parseFloat($('.throttle input[name="mid"]').val());
FC.RC_TUNING.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').val());
FC.RC_TUNING.throttle_HOVER = parseFloat($('.throttle input[name="hover"]').val());
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.ADVANCED_TUNING.tpaMode = $('select[id="tpaMode"]').val();
@ -1605,10 +1607,12 @@ pid_tuning.initialize = function (callback) {
// let global validation trigger and adjust the values first
const throttleMidE = $('.throttle input[name="mid"]');
const throttleExpoE = $('.throttle input[name="expo"]');
const throttleHoverE = $('.throttle input[name="hover"]');
const throttleLimitPercentE = $('.throttle_limit input[name="throttleLimitPercent"]');
const throttleLimitTypeE = $('.throttle_limit select[id="throttleLimitType"]');
const mid = parseFloat(throttleMidE.val());
const expo = parseFloat(throttleExpoE.val());
const hover = parseFloat(throttleHoverE.val());
const throttleLimitPercent = parseInt(throttleLimitPercentE.val()) / 100;
const throttleLimitType = parseInt(throttleLimitTypeE.val());
const throttleCurve = $(".throttle .throttle_curve canvas").get(0);
@ -1619,7 +1623,9 @@ pid_tuning.initialize = function (callback) {
mid >= parseFloat(throttleMidE.prop("min")) &&
mid <= parseFloat(throttleMidE.prop("max")) &&
expo >= parseFloat(throttleExpoE.prop("min")) &&
expo <= parseFloat(throttleExpoE.prop("max"))
expo <= parseFloat(throttleExpoE.prop("max")) &&
hover >= parseFloat(throttleHoverE.prop("min")) &&
hover <= parseFloat(throttleHoverE.prop("max"))
) {
// continue
} else {
@ -1635,11 +1641,11 @@ pid_tuning.initialize = function (callback) {
// math magic by englishman
const topY = canvasHeight * (1 - throttleScale);
const midX = canvasWidth * mid;
const midXl = midX * 0.5;
const midXr = (canvasWidth - midX) * 0.5 + midX;
const midY = canvasHeight - throttleScale * (midX * (canvasHeight / canvasWidth));
const midYl = canvasHeight - (canvasHeight - midY) * 0.5 * (expo + 1);
const midYr = topY + (midY - topY) * 0.5 * (expo + 1);
const midXl = midX * (1 - expo);
const midXr = (canvasWidth - midX) * expo + midX;
const midY = (canvasHeight - throttleScale) * (1 - hover);
const midYl = midY;
const midYr = midY;
let thrPercent = (FC.RC.channels[3] - 1000) / 1000,
thrpos =

View file

@ -1062,12 +1062,14 @@
<thead>
<tr>
<th i18n="receiverThrottleMid"></th>
<th i18n="receiverThrottleHover"></th>
<th i18n="receiverThrottleExpo"></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="number" name="mid" step="0.01" min="0" max="1" /></td>
<td><input type="number" name="hover" step="0.01" min="0" max="1" value="0.5"/></td>
<td><input type="number" name="expo" step="0.01" min="0" max="1" /></td>
</tr>
</tbody>