Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix profile change not working #2197

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions js/configurator_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ $(function() {
mixerprofile_e.on('change', function () {
var mixerprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_MIXER_PROFILE, [mixerprofile], false, function () {
GUI.log(i18n.getMessage('loadedMixerProfile', [mixerprofile + 1]));
GUI.log(i18n.getMessage('setMixerProfile', [mixerprofile + 1]));
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect();
Expand All @@ -545,7 +545,7 @@ $(function() {
profile_e.on('change', function () {
var profile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [profile], false, function () {
GUI.log(i18n.getMessage('pidTuning_LoadedProfile', [profile + 1]));
GUI.log(i18n.getMessage('setControlProfile', [profile + 1]));
});
});

Expand All @@ -554,7 +554,7 @@ $(function() {
batteryprofile_e.on('change', function () {
var batteryprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [batteryprofile], false, function () {
GUI.log(i18n.getMessage('loadedBatteryProfile', [batteryprofile + 1]));
GUI.log(i18n.getMessage('setBatteryProfile', [batteryprofile + 1]));
});
});

Expand Down
62 changes: 14 additions & 48 deletions js/defaults_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var defaultsDialog = (function () {
};

privateScope.reboot = function () {
periodicStatusUpdater.resume();

GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
Expand All @@ -177,7 +178,6 @@ var defaultsDialog = (function () {
};

privateScope.finalize = function (selectedDefaultPreset) {

if (selectedDefaultPreset.wizardPages) {
privateScope.wizard(selectedDefaultPreset, 0);
} else {
Expand Down Expand Up @@ -221,60 +221,26 @@ var defaultsDialog = (function () {
});
});


chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, callback);
});
controlProfileSettings.forEach(input => {
// Set control and battery parameters on all 3 profiles
for (let profileIdx = 0; profileIdx < 3; profileIdx++){
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [1], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [2], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [profileIdx], false, callback);
});
});

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [0], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
});

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [1], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [profileIdx], false, callback);
});
});

chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [2], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
});
}

// Set Mixers
if (selectedDefaultPreset.mixerToApply) {
Expand Down
21 changes: 16 additions & 5 deletions js/gui.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
const { dialog } = require("@electron/remote");


const CONFIGURATOR = require('./data_storage');
const Switchery = require('./libraries/switchery/switchery')
const MSP = require('./msp');
Expand Down Expand Up @@ -55,6 +54,12 @@ var GUI_control = function () {
];
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;

this.PROFILES_CHANGED = {
'CONTROL' : 1,
'BATTERY' : 2,
'MIXER' : 4
};

// check which operating system is user running
if (navigator.appVersion.indexOf("Win") != -1) this.operating_system = "Windows";
else if (navigator.appVersion.indexOf("Mac") != -1) this.operating_system = "MacOS";
Expand Down Expand Up @@ -263,10 +268,16 @@ GUI_control.prototype.updateProfileChange = function(refresh) {
$('#mixerprofilechange').val(FC.CONFIG.mixer_profile);
$('#profilechange').val(FC.CONFIG.profile);
$('#batteryprofilechange').val(FC.CONFIG.battery_profile);
if (refresh) {
GUI.log(i18n.getMessage('loadedMixerProfile', [FC.CONFIG.mixer_profile + 1]));
GUI.log(i18n.getMessage('pidTuning_LoadedProfile', [FC.CONFIG.profile + 1]));
GUI.log(i18n.getMessage('loadedBatteryProfile', [FC.CONFIG.battery_profile + 1]));
if (refresh > 0) {
if (refresh & GUI.PROFILES_CHANGED.CONTROL) {
GUI.log(i18n.getMessage('pidTuning_LoadedProfile', [FC.CONFIG.profile + 1]));
}
if (refresh & GUI.PROFILES_CHANGED.MIXER) {
GUI.log(i18n.getMessage('loadedMixerProfile', [FC.CONFIG.mixer_profile + 1]));
}
if (refresh & GUI.PROFILES_CHANGED.BATTERY) {
GUI.log(i18n.getMessage('loadedBatteryProfile', [FC.CONFIG.battery_profile + 1]));
}
GUI.updateActivatedTab();
}
};
Expand Down
19 changes: 13 additions & 6 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var mspHelper = (function () {
color;
if (!dataHandler.unsupported || dataHandler.unsupported) switch (dataHandler.code) {
case MSPCodes.MSPV2_INAV_STATUS:
let profile_changed = false;
let profile_changed = 0;
FC.CONFIG.cycleTime = data.getUint16(offset, true);
offset += 2;
FC.CONFIG.i2cError = data.getUint16(offset, true);
Expand All @@ -85,11 +85,15 @@ var mspHelper = (function () {

let profile_byte = data.getUint8(offset++)
let profile = profile_byte & 0x0F;
profile_changed |= (profile !== FC.CONFIG.profile) && (FC.CONFIG.profile !==-1);
if (profile !== FC.CONFIG.profile) {
profile_changed |= GUI.PROFILES_CHANGED.CONTROL;
}
FC.CONFIG.profile = profile;

let battery_profile = (profile_byte & 0xF0) >> 4;
profile_changed |= (battery_profile !== FC.CONFIG.battery_profile) && (FC.CONFIG.battery_profile !==-1);
if (battery_profile !== FC.CONFIG.battery_profile) {
profile_changed |= GUI.PROFILES_CHANGED.BATTERY;
}
FC.CONFIG.battery_profile = battery_profile;

FC.CONFIG.armingFlags = data.getUint32(offset, true);
Expand All @@ -99,11 +103,14 @@ var mspHelper = (function () {
//read mixer profile as the last byte in the the message
profile_byte = data.getUint8(dataHandler.message_length_expected - 1);
let mixer_profile = profile_byte & 0x0F;
profile_changed |= (mixer_profile !== FC.CONFIG.mixer_profile) && (FC.CONFIG.mixer_profile !==-1);
if (mixer_profile !== FC.CONFIG.mixer_profile) {
profile_changed |= GUI.PROFILES_CHANGED.MIXER;
}
FC.CONFIG.mixer_profile = mixer_profile;

GUI.updateStatusBar();
GUI.updateProfileChange(profile_changed);
if (profile_changed > 0) {
GUI.updateProfileChange(profile_changed);
}
break;

case MSPCodes.MSP_ACTIVEBOXES:
Expand Down
4 changes: 4 additions & 0 deletions js/periodicStatusUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const mspQueue = require('./serial_queue');
stoppped = true;
}

publicScope.resume = function() {
stoppped = false;
}

return publicScope;
})();

Expand Down
1 change: 0 additions & 1 deletion js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ var SerialBackend = (function () {

}, 7000);
} else {

timeout.add('waiting_for_bootup', function waiting_for_bootup() {
MSP.send_message(MSPCodes.MSPV2_INAV_STATUS, false, false, function () {
//noinspection JSUnresolvedVariable
Expand Down
9 changes: 9 additions & 0 deletions locale/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,15 @@
"loadedBatteryProfile": {
"message": "Loaded Battery Profile: <strong style=\"color: #37a8db\">$1</strong>"
},
"setControlProfile" : {
"message": "Set Control Profile: <strong style=\"color: #37a8db\">$1</strong>"
},
"setMixerProfile": {
"message": "Setting Mixer Profile: <strong style=\"color: #37a8db\">$1</strong>"
},
"setBatteryProfile": {
"message": "Setting Battery Profile: <strong style=\"color: #37a8db\">$1</strong>"
},
"pidTuningDataRefreshed": {
"message": "PID data <strong>refreshed</strong>"
},
Expand Down
Loading