1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Fields for PID and rate profile names. (#3150)

* Fields for PID and rate profile names.

* Minor styling changes.
This commit is contained in:
Vasyl Demianov 2022-12-17 08:41:28 +02:00 committed by GitHub
parent e8ef9418e1
commit bc6307adf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 3 deletions

View file

@ -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;

View file

@ -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)) {
@ -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) {
@ -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) {
@ -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));