1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-18 05:45:25 +03:00

Merge pull request #566 from basdelfos/copy-profile

Added copy profile to another profile in PID Tuning tab
This commit is contained in:
borisbstyle 2017-08-06 21:58:25 +02:00 committed by GitHub
commit e0438d2e8c
7 changed files with 215 additions and 4 deletions

View file

@ -1021,6 +1021,24 @@
"pidTuningControllerHead": {
"message": "PID Controller"
},
"pidTuningCopyProfile": {
"message": "Copy profile values"
},
"pidTuningCopyRateProfile": {
"message": "Copy rateprofile values"
},
"dialogCopyProfileTitle": {
"message": "Copy Profile Values"
},
"dialogCopyProfileNote": {
"message": "All values on the destination profile will be wiped and overwritten"
},
"dialogCopyProfileConfirm": {
"message": "Copy"
},
"dialogCopyProfileClose": {
"message": "Cancel"
},
"pidTuningResetProfile": {
"message": "Reset all profile values"
},

View file

@ -55,6 +55,7 @@ var PID_ADVANCED_CONFIG;
var FILTER_CONFIG;
var ADVANCED_TUNING;
var SENSOR_CONFIG;
var COPY_PROFILE;
var FC = {
resetState: function() {
@ -81,12 +82,18 @@ var FC = {
};
BF_CONFIG = {
currentscale: 0,
currentoffset: 0,
currentmetertype: 0,
batterycapacity: 0,
currentscale: 0,
currentoffset: 0,
currentmetertype: 0,
batterycapacity: 0,
};
COPY_PROFILE = {
type: 0,
dstProfile: 0,
srcProfile: 0,
};
FEATURE_CONFIG = {
features: 0,
};

View file

@ -117,6 +117,8 @@ var MSPCodes = {
MSP_DISPLAYPORT: 182,
MSP_COPY_PROFILE: 183,
MSP_BEEPER_CONFIG: 184,
MSP_SET_BEEPER_CONFIG: 185,

View file

@ -1138,6 +1138,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_SET_SENSOR_CONFIG:
console.log('Sensor config parameters set');
break;
case MSPCodes.MSP_COPY_PROFILE:
console.log('Copy profile');
break;
default:
console.log('Unknown code detected: ' + code);
} else {
@ -1494,6 +1497,12 @@ MspHelper.prototype.crunch = function(code) {
}
break;
case MSPCodes.MSP_COPY_PROFILE:
buffer.push8(COPY_PROFILE.type)
.push8(COPY_PROFILE.dstProfile)
.push8(COPY_PROFILE.srcProfile)
break;
default:
return false;
}

View file

@ -548,6 +548,18 @@
float: right;
}
.tab-pid_tuning .copyprofilebtn {
width: 150px;
float: right;
margin-right:10px;
}
.tab-pid_tuning .copyrateprofilebtn {
width: 150px;
float: right;
margin-right:10px;
}
.tab-pid_tuning .right {
float: right;
}
@ -753,3 +765,61 @@ width: 40%;
border-top: 0px solid silver;
background: #f9f9f9;
}
.tab-pid_tuning dialog {
width: 40em;
border-radius: 5px;
}
.tab-pid_tuning dialog .buttons {
position: static;
margin-top: 2em;
}
.tab-pid_tuning dialog h3 {
margin-bottom: 0.5em;
}
.tab-pid_tuning .regular-button {
margin-top: 8px;
margin-bottom: 8px;
margin-right: 10px;
background-color: #ffbb00;
border-radius: 3px;
border: 1px solid #dba718;
color: #000;
font-family: 'open_sansbold', Arial;
font-size: 12px;
text-shadow: 0px 1px rgba(255, 255, 255, 0.25);
display: inline-block;
cursor: pointer;
transition: all ease 0.2s;
padding: 0px;
padding-left: 9px;
padding-right: 9px;
line-height: 28px;
}
.tab-pid_tuning .regular-button:hover {
background-color: #ffcc3e;
transition: all ease 0.2s;
}
.tab-pid_tuning .regular-button:active {
background-color: #ffcc3e;
transition: all ease 0.0s;
box-shadow: inset 0px 1px 5px rgba(0, 0, 0, 0.35);
}
.tab-pid_tuning .regular-button.disabled {
cursor: default;
color: #fff;
background-color: #AFAFAF;
border: 1px solid #AFAFAF;
pointer-events: none;
text-shadow: none;
opacity: 0.5;
}
.tab-pid_tuning dialog select {
border: 1px solid silver;
margin-left: 5px;
width: 120px;
}

View file

@ -43,6 +43,12 @@
<div class="default_btn resetbt">
<a href="#" id="resetProfile" i18n="pidTuningResetProfile"></a>
</div>
<div class="default_btn copyrateprofilebtn">
<a href="#" id="copyRateProfile" i18n="pidTuningCopyRateProfile"></a>
</div>
<div class="default_btn copyprofilebtn">
<a href="#" id="copyProfile" i18n="pidTuningCopyProfile"></a>
</div>
</div>
</div>
<div class="tab_container" style="background-color: #fff;">
@ -617,4 +623,29 @@
<a class="refresh" href="#" i18n="pidTuningButtonRefresh"></a>
</div>
</div>
<dialog class="dialogCopyProfile">
<h3 i18n="dialogCopyProfileTitle"></h3>
<div class="content">
<div i18n="dialogCopyProfileNote" style="margin-top: 10px"></div>
<div class="contentProfile" style="margin-top:20px;">
<div>
Copy values from current profile to <select class="selectProfile"></select>
</div>
</div>
<div class="contentRateProfile" style="margin-top:20px;">
<div>
Copy values from current rateprofile to <select class="selectRateProfile"></select>
</div>
</div>
</div>
<div class="buttons">
<a href="#" class="dialogCopyProfile-confirmbtn regular-button" i18n="dialogCopyProfileConfirm"></a>
<a href="#" class="dialogCopyProfile-cancelbtn regular-button" i18n="dialogCopyProfileClose"></a>
</div>
</dialog>
</div>

View file

@ -834,6 +834,80 @@ TABS.pid_tuning.initialize = function (callback) {
}
});
var dialogCopyProfile = $('.dialogCopyProfile')[0];
var DIALOG_MODE_PROFILE = 0;
var DIALOG_MODE_RATEPROFILE = 1;
var dialogCopyProfileMode;
var selectProfileValues = { "0": "Profile 1", "1": "Profile 2", "2": "Profile 3" };
var selectRateProfileValues = { "0": "Rateprofile 1", "1": "Rateprofile 2", "2": "Rateprofile 3" };
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
var selectProfile = $('.selectProfile');
var selectRateProfile = $('.selectRateProfile');
$.each(selectProfileValues, function(key, value) {
if (key != CONFIG.profile)
selectProfile.append(new Option(value, key));
});
$.each(selectRateProfileValues, function(key, value) {
if (key != CONFIG.rateProfile)
selectRateProfile.append(new Option(value, key));
});
$('.copyprofilebtn').click(function() {
$('.dialogCopyProfile').find('.contentProfile').show();
$('.dialogCopyProfile').find('.contentRateProfile').hide();
dialogCopyProfileMode = DIALOG_MODE_PROFILE;
dialogCopyProfile.showModal();
});
$('.copyrateprofilebtn').click(function() {
$('.dialogCopyProfile').find('.contentProfile').hide();
$('.dialogCopyProfile').find('.contentRateProfile').show();
dialogCopyProfileMode = DIALOG_MODE_RATEPROFILE;
dialogCopyProfile.showModal();
});
$('.dialogCopyProfile-cancelbtn').click(function() {
dialogCopyProfile.close();
});
$('.dialogCopyProfile-confirmbtn').click(function() {
switch(dialogCopyProfileMode) {
case DIALOG_MODE_PROFILE:
COPY_PROFILE.type = DIALOG_MODE_PROFILE; // 0 = pid profile
COPY_PROFILE.dstProfile = parseInt(selectProfile.val());
COPY_PROFILE.srcProfile = CONFIG.profile;
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
break;
case DIALOG_MODE_RATEPROFILE:
COPY_PROFILE.type = DIALOG_MODE_RATEPROFILE; // 1 = rate profile
COPY_PROFILE.dstProfile = parseInt(selectRateProfile.val());
COPY_PROFILE.srcProfile = CONFIG.profile;
MSP.send_message(MSPCodes.MSP_COPY_PROFILE, mspHelper.crunch(MSPCodes.MSP_COPY_PROFILE), false, close_dialog);
break;
default:
close_dialog();
break;
}
function close_dialog() {
dialogCopyProfile.close();
}
});
} else {
$('.copyprofilebtn').hide();
$('.copyrateprofilebtn').hide();
}
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
$('#pid-tuning .delta select').change(function() {
self.setDirty(true);