Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hover point throttle curve adjustment #4245

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,9 @@
"receiverThrottleExpo": {
"message": "Throttle EXPO"
},
"receiverThrottleHover": {
"message": "Hover Point"
},
"receiverStickMin": {
"message": "'Stick Low' Threshold"
},
Expand Down
14 changes: 9 additions & 5 deletions src/js/tabs/pid_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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.throttle_HOVER.toFixed(2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FC.THROTTLE_HOVER should be a member of some PG to be decided in firmware.


if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// Moved tpa to profile
Expand Down Expand Up @@ -806,6 +807,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 @@ -1429,10 +1431,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 @@ -1458,11 +1462,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 = thrPercent <= mid
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