mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-25 17:25:16 +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:
parent
dfad5b0f73
commit
5adb12a8c8
5 changed files with 24 additions and 6 deletions
|
@ -2338,6 +2338,9 @@
|
||||||
"receiverThrottleExpo": {
|
"receiverThrottleExpo": {
|
||||||
"message": "Throttle EXPO"
|
"message": "Throttle EXPO"
|
||||||
},
|
},
|
||||||
|
"receiverThrottleHover": {
|
||||||
|
"message": "Hover Point"
|
||||||
|
},
|
||||||
"receiverStickMin": {
|
"receiverStickMin": {
|
||||||
"message": "'Stick Low' Threshold"
|
"message": "'Stick Low' Threshold"
|
||||||
},
|
},
|
||||||
|
|
|
@ -295,6 +295,7 @@ const FC = {
|
||||||
pitch_rate_limit: 1998,
|
pitch_rate_limit: 1998,
|
||||||
yaw_rate_limit: 1998,
|
yaw_rate_limit: 1998,
|
||||||
rates_type: 0,
|
rates_type: 0,
|
||||||
|
throttle_HOVER: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.AUX_CONFIG = [];
|
this.AUX_CONFIG = [];
|
||||||
|
|
|
@ -466,6 +466,7 @@ MspHelper.prototype.process_data = function (dataHandler) {
|
||||||
FC.RC_TUNING.pitch_rate_limit = data.readU16();
|
FC.RC_TUNING.pitch_rate_limit = data.readU16();
|
||||||
FC.RC_TUNING.yaw_rate_limit = data.readU16();
|
FC.RC_TUNING.yaw_rate_limit = data.readU16();
|
||||||
FC.RC_TUNING.rates_type = data.readU8();
|
FC.RC_TUNING.rates_type = data.readU8();
|
||||||
|
FC.RC_TUNING.throttle_HOVER = parseFloat((data.readU8() / 100).toFixed(2));
|
||||||
break;
|
break;
|
||||||
case MSPCodes.MSP_PID:
|
case MSPCodes.MSP_PID:
|
||||||
// PID data arrived, we need to scale it and save to appropriate bank / array
|
// 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
|
// Introduced in 1.43
|
||||||
buffer.push8(FC.RC_TUNING.rates_type);
|
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;
|
break;
|
||||||
case MSPCodes.MSP_SET_RX_MAP:
|
case MSPCodes.MSP_SET_RX_MAP:
|
||||||
for (let i = 0; i < FC.RC_MAP.length; i++) {
|
for (let i = 0; i < FC.RC_MAP.length; i++) {
|
||||||
|
|
|
@ -123,6 +123,7 @@ pid_tuning.initialize = function (callback) {
|
||||||
|
|
||||||
$('.throttle input[name="mid"]').val(FC.RC_TUNING.throttle_MID.toFixed(2));
|
$('.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="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)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
// Moved tpa to profile
|
// 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_MID = parseFloat($('.throttle input[name="mid"]').val());
|
||||||
FC.RC_TUNING.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').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)) {
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
|
||||||
FC.ADVANCED_TUNING.tpaMode = $('select[id="tpaMode"]').val();
|
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
|
// let global validation trigger and adjust the values first
|
||||||
const throttleMidE = $('.throttle input[name="mid"]');
|
const throttleMidE = $('.throttle input[name="mid"]');
|
||||||
const throttleExpoE = $('.throttle input[name="expo"]');
|
const throttleExpoE = $('.throttle input[name="expo"]');
|
||||||
|
const throttleHoverE = $('.throttle input[name="hover"]');
|
||||||
const throttleLimitPercentE = $('.throttle_limit input[name="throttleLimitPercent"]');
|
const throttleLimitPercentE = $('.throttle_limit input[name="throttleLimitPercent"]');
|
||||||
const throttleLimitTypeE = $('.throttle_limit select[id="throttleLimitType"]');
|
const throttleLimitTypeE = $('.throttle_limit select[id="throttleLimitType"]');
|
||||||
const mid = parseFloat(throttleMidE.val());
|
const mid = parseFloat(throttleMidE.val());
|
||||||
const expo = parseFloat(throttleExpoE.val());
|
const expo = parseFloat(throttleExpoE.val());
|
||||||
|
const hover = parseFloat(throttleHoverE.val());
|
||||||
const throttleLimitPercent = parseInt(throttleLimitPercentE.val()) / 100;
|
const throttleLimitPercent = parseInt(throttleLimitPercentE.val()) / 100;
|
||||||
const throttleLimitType = parseInt(throttleLimitTypeE.val());
|
const throttleLimitType = parseInt(throttleLimitTypeE.val());
|
||||||
const throttleCurve = $(".throttle .throttle_curve canvas").get(0);
|
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("min")) &&
|
||||||
mid <= parseFloat(throttleMidE.prop("max")) &&
|
mid <= parseFloat(throttleMidE.prop("max")) &&
|
||||||
expo >= parseFloat(throttleExpoE.prop("min")) &&
|
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
|
// continue
|
||||||
} else {
|
} else {
|
||||||
|
@ -1635,11 +1641,11 @@ pid_tuning.initialize = function (callback) {
|
||||||
// math magic by englishman
|
// math magic by englishman
|
||||||
const topY = canvasHeight * (1 - throttleScale);
|
const topY = canvasHeight * (1 - throttleScale);
|
||||||
const midX = canvasWidth * mid;
|
const midX = canvasWidth * mid;
|
||||||
const midXl = midX * 0.5;
|
const midXl = midX * (1 - expo);
|
||||||
const midXr = (canvasWidth - midX) * 0.5 + midX;
|
const midXr = (canvasWidth - midX) * expo + midX;
|
||||||
const midY = canvasHeight - throttleScale * (midX * (canvasHeight / canvasWidth));
|
const midY = (canvasHeight - throttleScale) * (1 - hover);
|
||||||
const midYl = canvasHeight - (canvasHeight - midY) * 0.5 * (expo + 1);
|
const midYl = midY;
|
||||||
const midYr = topY + (midY - topY) * 0.5 * (expo + 1);
|
const midYr = midY;
|
||||||
|
|
||||||
let thrPercent = (FC.RC.channels[3] - 1000) / 1000,
|
let thrPercent = (FC.RC.channels[3] - 1000) / 1000,
|
||||||
thrpos =
|
thrpos =
|
||||||
|
|
|
@ -1062,12 +1062,14 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th i18n="receiverThrottleMid"></th>
|
<th i18n="receiverThrottleMid"></th>
|
||||||
|
<th i18n="receiverThrottleHover"></th>
|
||||||
<th i18n="receiverThrottleExpo"></th>
|
<th i18n="receiverThrottleExpo"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="number" name="mid" step="0.01" min="0" max="1" /></td>
|
<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>
|
<td><input type="number" name="expo" step="0.01" min="0" max="1" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue