Skip to content

Commit

Permalink
Fields for PID and rate profile names. (#3150)
Browse files Browse the repository at this point in the history
* Fields for PID and rate profile names.

* Minor styling changes.
  • Loading branch information
Vasyl Demianov committed Dec 17, 2022
1 parent e8ef941 commit bc6307a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
12 changes: 12 additions & 0 deletions locales/en/messages.json
Expand Up @@ -1608,6 +1608,18 @@
"pidTuningSubTabFilter": {
"message": "Filter Settings"
},
"pidProfileName": {
"message": "PID profile name"
},
"pidProfileNameHelp": {
"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."
},
"rateProfileName": {
"message": "Rate profile name"
},
"rateProfileNameHelp": {
"message": "Rate profile name which can describe what type of flying this profile is for: cine, race, freestyle, etc."
},
"pidTuningShowAllPids": {
"message": "Show all PIDs"
},
Expand Down
4 changes: 2 additions & 2 deletions src/js/msp/MSPHelper.js
Expand Up @@ -2033,10 +2033,10 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.profile], 8);
break;
case MSPCodes.RATE_PROFILE_NAME:
self.setText(buffer, modifierCode, FC.CONFIG.pidProfileNames[FC.CONFIG.rateProfile], 8);
self.setText(buffer, modifierCode, FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile], 8);
break;
default:
console.log('Unsupport text type');
console.log('Unsupported text type');
break;
}
break;
Expand Down
22 changes: 22 additions & 0 deletions src/js/tabs/pid_tuning.js
Expand Up @@ -48,6 +48,10 @@ pid_tuning.initialize = function (callback) {
.then(() => MSP.promise(MSPCodes.MSP_FILTER_CONFIG))
.then(() => MSP.promise(MSPCodes.MSP_RC_DEADBAND))
.then(() => MSP.promise(MSPCodes.MSP_MOTOR_CONFIG))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.PID_PROFILE_NAME)) : true)
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_GET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.RATE_PROFILE_NAME)) : true)
.then(() => {
let promise;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
Expand All @@ -68,6 +72,14 @@ pid_tuning.initialize = function (callback) {
self.setProfile();
self.setRateProfile();

// Profile names
if (semver.gte(FC.CONFIG.apiVersion, "1.45.0")) {
$('input[name="pidProfileName"]').val(FC.CONFIG.pidProfileNames[FC.CONFIG.profile]);
$('input[name="rateProfileName"]').val(FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile]);
} else {
$('.profile_name').hide();
}

// Fill in the data from PIDs array for each pid name
FC.PID_NAMES.forEach(function(elementPid, indexPid) {

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

// Profile names
if (semver.gte(FC.CONFIG.apiVersion, "1.45.0")) {
FC.CONFIG.pidProfileNames[FC.CONFIG.profile] = $('input[name="pidProfileName"]').val().trim();
FC.CONFIG.rateProfileNames[FC.CONFIG.rateProfile] = $('input[name="rateProfileName"]').val().trim();
}

// For each pid name
FC.PID_NAMES.forEach(function(elementPid, indexPid) {

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

MSP.promise(MSPCodes.MSP_SET_PID, mspHelper.crunch(MSPCodes.MSP_SET_PID))
.then(() => MSP.promise(MSPCodes.MSP_SET_PID_ADVANCED, mspHelper.crunch(MSPCodes.MSP_SET_PID_ADVANCED)))
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_SET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.PID_PROFILE_NAME)) : true)
.then(() => semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? MSP.promise(MSPCodes.MSP2_SET_TEXT,
mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.RATE_PROFILE_NAME)) : true)
.then(() => {
self.updatePIDColors();
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
Expand Down
17 changes: 16 additions & 1 deletion src/tabs/pid_tuning.html
Expand Up @@ -63,6 +63,14 @@
<div class="subtab-pid">
<div class="clear-both"></div>
<div class="cf_column">
<div class="profile_name">
<div class="number">
<label> <input type="text" name="pidProfileName" maxlength="8" style="width:100px;"/> <span
i18n="pidProfileName"></span>
</label>
<div class="helpicon cf_tip" i18n_title="pidProfileNameHelp"></div>
</div>
</div>
<div class="note dMinDisabledNote">
<p i18n="pidTuningDMinDisabledNote"></p>
</div>
Expand Down Expand Up @@ -919,7 +927,14 @@
<div class="subtab-rates" style="display: none;">
<div class="clear-both"></div>
<div class="cf_column">

<div class="profile_name">
<div class="number">
<label> <input type="text" name="rateProfileName" maxlength="8" style="width:100px;"/> <span
i18n="rateProfileName"></span>
</label>
<div class="helpicon cf_tip" i18n_title="rateProfileNameHelp"></div>
</div>
</div>
<div class="gui_box rates_type pid_tuning">
<table class="cf">
<thead>
Expand Down

0 comments on commit bc6307a

Please sign in to comment.