diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f81e54b5..74eefc19 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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" }, diff --git a/js/fc.js b/js/fc.js index 820b7f6b..b1adf513 100644 --- a/js/fc.js +++ b/js/fc.js @@ -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, }; diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js index f50f03b7..a7a636f2 100644 --- a/js/msp/MSPCodes.js +++ b/js/msp/MSPCodes.js @@ -117,6 +117,8 @@ var MSPCodes = { MSP_DISPLAYPORT: 182, + MSP_COPY_PROFILE: 183, + MSP_BEEPER_CONFIG: 184, MSP_SET_BEEPER_CONFIG: 185, diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index a50bdc2c..f99af1b6 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -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; } diff --git a/tabs/pid_tuning.css b/tabs/pid_tuning.css index 151f737e..1a163673 100644 --- a/tabs/pid_tuning.css +++ b/tabs/pid_tuning.css @@ -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; +} diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 97a4713a..e4ff2ee7 100755 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -43,6 +43,12 @@
+
+ +
+
+ +
@@ -617,4 +623,29 @@
+ + +

+
+
+ +
+
+ Copy values from current profile to +
+
+ +
+
+ Copy values from current rateprofile to +
+
+ +
+
+ + +
+
+ diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 6a624317..d1a38a7e 100755 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -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);