Skip to content

Commit bc6307a

Browse files
author
Vasyl Demianov
authored
Fields for PID and rate profile names. (#3150)
* Fields for PID and rate profile names. * Minor styling changes.
1 parent e8ef941 commit bc6307a

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

locales/en/messages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,18 @@
16081608
"pidTuningSubTabFilter": {
16091609
"message": "Filter Settings"
16101610
},
1611+
"pidProfileName": {
1612+
"message": "PID profile name"
1613+
},
1614+
"pidProfileNameHelp": {
1615+
"message": "PID profile name which can describe what conditions this profile was tuned to: lighter/heavier battery, action camera/no action camera, higher elevation, etc."
1616+
},
1617+
"rateProfileName": {
1618+
"message": "Rate profile name"
1619+
},
1620+
"rateProfileNameHelp": {
1621+
"message": "Rate profile name which can describe what type of flying this profile is for: cine, race, freestyle, etc."
1622+
},
16111623
"pidTuningShowAllPids": {
16121624
"message": "Show all PIDs"
16131625
},

src/js/msp/MSPHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,10 +2033,10 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
20332033
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.profile], 8);
20342034
break;
20352035
case MSPCodes.RATE_PROFILE_NAME:
2036-
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.rateProfile], 8);
2036+
self.setText(buffer, modifierCode, FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile], 8);
20372037
break;
20382038
default:
2039-
console.log('Unsupport text type');
2039+
console.log('Unsupported text type');
20402040
break;
20412041
}
20422042
break;

src/js/tabs/pid_tuning.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ pid_tuning.initialize = function (callback) {
4848
.then(() => MSP.promise(MSPCodes.MSP_FILTER_CONFIG))
4949
.then(() => MSP.promise(MSPCodes.MSP_RC_DEADBAND))
5050
.then(() => MSP.promise(MSPCodes.MSP_MOTOR_CONFIG))
51+
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_TEXT,
52+
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PID_PROFILE_NAME)) : true)
53+
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_TEXT,
54+
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.RATE_PROFILE_NAME)) : true)
5155
.then(() => {
5256
let promise;
5357
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
@@ -68,6 +72,14 @@ pid_tuning.initialize = function (callback) {
6872
self.setProfile();
6973
self.setRateProfile();
7074

75+
// Profile names
76+
if (semver.gte(FC.CONFIG.apiVersion, "1.45.0")) {
77+
$('input[name="pidProfileName"]').val(FC.CONFIG.pidProfileNames[FC.CONFIG.profile]);
78+
$('input[name="rateProfileName"]').val(FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile]);
79+
} else {
80+
$('.profile_name').hide();
81+
}
82+
7183
// Fill in the data from PIDs array for each pid name
7284
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
7385

@@ -1000,6 +1012,12 @@ pid_tuning.initialize = function (callback) {
10001012
// Fill in the data from PIDs array
10011013
// Catch all the changes and stuff the inside PIDs array
10021014

1015+
// Profile names
1016+
if (semver.gte(FC.CONFIG.apiVersion, "1.45.0")) {
1017+
FC.CONFIG.pidProfileNames[FC.CONFIG.profile] = $('input[name="pidProfileName"]').val().trim();
1018+
FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile] = $('input[name="rateProfileName"]').val().trim();
1019+
}
1020+
10031021
// For each pid name
10041022
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
10051023

@@ -2188,6 +2206,10 @@ pid_tuning.initialize = function (callback) {
21882206

21892207
MSP.promise(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID))
21902208
.then(() => MSP.promise(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED)))
2209+
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_SET_TEXT,
2210+
mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.PID_PROFILE_NAME)) : true)
2211+
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_SET_TEXT,
2212+
mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.RATE_PROFILE_NAME)) : true)
21912213
.then(() => {
21922214
self.updatePIDColors();
21932215
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));

src/tabs/pid_tuning.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
<div class="subtab-pid">
6464
<div class="clear-both"></div>
6565
<div class="cf_column">
66+
<div class="profile_name">
67+
<div class="number">
68+
<label> <input type="text" name="pidProfileName" maxlength="8" style="width:100px;"/> <span
69+
i18n="pidProfileName"></span>
70+
</label>
71+
<div class="helpicon cf_tip" i18n_title="pidProfileNameHelp"></div>
72+
</div>
73+
</div>
6674
<div class="note dMinDisabledNote">
6775
<p i18n="pidTuningDMinDisabledNote"></p>
6876
</div>
@@ -919,7 +927,14 @@
919927
<div class="subtab-rates" style="display: none;">
920928
<div class="clear-both"></div>
921929
<div class="cf_column">
922-
930+
<div class="profile_name">
931+
<div class="number">
932+
<label> <input type="text" name="rateProfileName" maxlength="8" style="width:100px;"/> <span
933+
i18n="rateProfileName"></span>
934+
</label>
935+
<div class="helpicon cf_tip" i18n_title="rateProfileNameHelp"></div>
936+
</div>
937+
</div>
923938
<div class="gui_box rates_type pid_tuning">
924939
<table class="cf">
925940
<thead>

0 commit comments

Comments
 (0)