Skip to content

Commit

Permalink
hover point throttle curve adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-frank authored and nerdCopter committed Feb 3, 2025
1 parent a15980a commit 1d7a250
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,9 @@
"receiverThrottleExpo": {
"message": "Throttle EXPO"
},
"receiverThrottleHover": {
"message": "Hover Point"
},
"receiverStickMin": {
"message": "'Stick Low' Threshold"
},
Expand Down
1 change: 1 addition & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const FC = {
dynamic_THR_PID: 0, // moved in 1.45 to ADVANCED_TUNING
throttle_MID: 0,
throttle_EXPO: 0,
throttle_HOVER: 0,
dynamic_THR_breakpoint: 0, // moved in 1.45 to ADVANCED_TUNING
RC_YAW_EXPO: 0,
rcYawRate: 0,
Expand Down
18 changes: 12 additions & 6 deletions src/js/tabs/pid_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1601,10 +1603,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);
Expand All @@ -1615,7 +1619,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 {
Expand All @@ -1631,11 +1637,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 =
Expand Down
2 changes: 2 additions & 0 deletions src/tabs/pid_tuning.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 1d7a250

Please sign in to comment.