From 5adb12a8c878e88f3b3e9c60d00871fdd827f2b5 Mon Sep 17 00:00:00 2001 From: Marc Frank Date: Thu, 10 Apr 2025 15:50:47 +0200 Subject: [PATCH] hover point throttle curve adjustment (#4245) * hover point throttle curve adjustment * added throttle_HOVER reading/writing via MSP * moved throttle_HOVER position --- locales/en/messages.json | 3 +++ src/js/fc.js | 1 + src/js/msp/MSPHelper.js | 6 ++++++ src/js/tabs/pid_tuning.js | 18 ++++++++++++------ src/tabs/pid_tuning.html | 2 ++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index a13248ab..bdeb79a0 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2338,6 +2338,9 @@ "receiverThrottleExpo": { "message": "Throttle EXPO" }, + "receiverThrottleHover": { + "message": "Hover Point" + }, "receiverStickMin": { "message": "'Stick Low' Threshold" }, diff --git a/src/js/fc.js b/src/js/fc.js index bf7a71a6..ee492b84 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -295,6 +295,7 @@ const FC = { pitch_rate_limit: 1998, yaw_rate_limit: 1998, rates_type: 0, + throttle_HOVER: 0, }; this.AUX_CONFIG = []; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 21eca81d..ff2cdfe8 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -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++) { diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 5555d9c3..a6f89e1d 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -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 = diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index fd343de6..23e4eea4 100644 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -1062,12 +1062,14 @@ + +