Skip to content

Commit c97deaf

Browse files
authored
Fix Angle Mode positioning (#3914)
1 parent 9e07b12 commit c97deaf

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/js/tabs/pid_tuning.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,35 +2705,53 @@ pid_tuning.updateRatesLabels = function() {
27052705
const rcRate = self.currentRates.rc_rate;
27062706
const rcRatePitch = self.currentRates.rc_rate_pitch;
27072707

2708+
function getOffsetForBalloon(value) {
2709+
return curveWidth - (Math.ceil(stickContext.measureText(value).width) / (stickContext.canvas.clientWidth / stickContext.canvas.clientHeight)) - 40;
2710+
}
2711+
2712+
const angleModeText = `Angle Mode`;
2713+
27082714
if (self.currentRatesType === FC.RATES_TYPE.ACTUAL) {
2709-
drawAxisLabel(stickContext, `Angle Mode`, (curveWidth - 10) / textScale, curveHeight - 250, 'right');
2715+
drawAxisLabel(stickContext, angleModeText, (curveWidth - 10) / textScale, curveHeight - 250, 'right');
27102716

27112717
const angleCenterSensitivityRoll = (rcRate / maxAngleRollRate * angleLimit).toFixed(1);
27122718
const angleCenterSensitivityPitch = (rcRatePitch / maxAnglePitchRate * angleLimit).toFixed(1);
27132719

2720+
const angleCenterSensitivityRollText = `${angleCenterSensitivityRoll}...${angleLimit}`;
2721+
const angleCenterSensitivityPitchText = `${angleCenterSensitivityPitch}...${angleLimit}`;
2722+
2723+
const angleCenterSensitivityRollOffset = getOffsetForBalloon(angleCenterSensitivityRollText);
2724+
const angleCenterSensitivityPitchOffset = getOffsetForBalloon(angleCenterSensitivityPitchText);
2725+
27142726
balloons.push(
2715-
{value: parseInt(angleCenterSensitivityRoll), balloon: function() {drawBalloonLabel(stickContext, `${angleCenterSensitivityRoll}...${angleLimit}`, ((curveWidth / 2) - 10) / textScale, curveHeight - 150, 'none', BALLOON_COLORS.roll, balloonsDirty);}},
2716-
{value: parseInt(angleCenterSensitivityPitch), balloon: function() {drawBalloonLabel(stickContext, `${angleCenterSensitivityPitch}...${angleLimit}`, ((curveWidth / 2) - 10) / textScale, curveHeight - 50, 'none', BALLOON_COLORS.pitch, balloonsDirty);}},
2727+
{value: parseInt(angleCenterSensitivityRoll), balloon: function() {drawBalloonLabel(stickContext, angleCenterSensitivityRollText, angleCenterSensitivityRollOffset, curveHeight - 150, 'none', BALLOON_COLORS.roll, balloonsDirty);}},
2728+
{value: parseInt(angleCenterSensitivityPitch), balloon: function() {drawBalloonLabel(stickContext, angleCenterSensitivityPitchText, angleCenterSensitivityPitchOffset, curveHeight - 50, 'none', BALLOON_COLORS.pitch, balloonsDirty);}},
27172729
);
27182730
}
27192731

27202732
if (self.currentRatesType === FC.RATES_TYPE.BETAFLIGHT) {
2721-
drawAxisLabel(stickContext, `Angle Mode`, (curveWidth - 10) / textScale, curveHeight - 250, 'right');
2733+
drawAxisLabel(stickContext, angleModeText, (curveWidth - 10) / textScale, curveHeight - 250, 'right');
27222734

27232735
const RC_RATE_INCREMENTAL = 14.54;
27242736

27252737
// ROLL
27262738
const expo = self.currentRates.rc_expo;
27272739
const rcRateModified = rcRate > 2.0 ? (rcRate - 2.0) * RC_RATE_INCREMENTAL + 2.0: rcRate;
27282740
const sensitivityFractionRoll = (angleLimit * ((1 - expo) * rcRateModified * 200 / maxAngleRollRate)).toFixed(1);
2741+
2742+
const sensitivityFractionRollText = `${sensitivityFractionRoll}...${angleLimit}`;
2743+
const sensitivityFractionRollOffset = getOffsetForBalloon(sensitivityFractionRollText);
27292744
// PITCH
27302745
const expoPitch = self.currentRates.rc_pitch_expo;
27312746
const rcRateModifiedPitch = rcRatePitch > 2.0 ? (rcRatePitch - 2.0) * RC_RATE_INCREMENTAL + 2.0: rcRatePitch;
27322747
const sensitivityFractionPitch = (angleLimit * ((1 - expoPitch) * rcRateModifiedPitch * 200 / maxAnglePitchRate)).toFixed(1);
27332748

2749+
const sensitivityFractionPitchText = `${sensitivityFractionPitch}...${angleLimit}`;
2750+
const sensitivityFractionPitchOffset = getOffsetForBalloon(sensitivityFractionPitchText);
2751+
27342752
balloons.push(
2735-
{value: parseInt(sensitivityFractionRoll), balloon: function() {drawBalloonLabel(stickContext, `${sensitivityFractionRoll}...${angleLimit}`, ((curveWidth / 2) - 10) / textScale, curveHeight - 150, 'none', BALLOON_COLORS.roll, balloonsDirty);}},
2736-
{value: parseInt(sensitivityFractionPitch), balloon: function() {drawBalloonLabel(stickContext, `${sensitivityFractionPitch}...${angleLimit}`, ((curveWidth / 2) - 10) / textScale, curveHeight - 50, 'none', BALLOON_COLORS.pitch, balloonsDirty);}},
2753+
{value: parseInt(sensitivityFractionRoll), balloon: function() {drawBalloonLabel(stickContext, sensitivityFractionRollText, sensitivityFractionRollOffset, curveHeight - 150, 'none', BALLOON_COLORS.roll, balloonsDirty);}},
2754+
{value: parseInt(sensitivityFractionPitch), balloon: function() {drawBalloonLabel(stickContext, sensitivityFractionPitchText, sensitivityFractionPitchOffset, curveHeight - 50, 'none', BALLOON_COLORS.pitch, balloonsDirty);}},
27372755
);
27382756
}
27392757

0 commit comments

Comments
 (0)