Skip to content

Commit 413c1bb

Browse files
authored
Merge pull request #1892 from shota3527/sh_vtol
Detect profiles changes and refresh
2 parents bbbecb2 + e691537 commit 413c1bb

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

js/fc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ var FC = {
118118
i2cError: 0,
119119
activeSensors: 0,
120120
mode: [],
121-
mixer_profile: 0,
122-
profile: 0,
123-
battery_profile: 0,
121+
mixer_profile: -1,
122+
profile: -1,
123+
battery_profile: -1,
124124
uid: [0, 0, 0],
125125
accelerometerTrims: [0, 0],
126126
armingFlags: 0,

js/gui.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,16 @@ GUI_control.prototype.updateStatusBar = function() {
260260
$('span.arming-flags').text(activeArmFlags.length ? activeArmFlags.join(', ') : '-');
261261
};
262262

263-
GUI_control.prototype.updateProfileChange = function() {
263+
GUI_control.prototype.updateProfileChange = function(refresh) {
264264
$('#mixerprofilechange').val(CONFIG.mixer_profile);
265265
$('#profilechange').val(CONFIG.profile);
266266
$('#batteryprofilechange').val(CONFIG.battery_profile);
267+
if (refresh) {
268+
GUI.log(chrome.i18n.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1]));
269+
GUI.log(chrome.i18n.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1]));
270+
GUI.log(chrome.i18n.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1]));
271+
updateActivatedTab();
272+
}
267273
};
268274

269275
GUI_control.prototype.fillSelect = function ($element, values, currentValue, unit) {

js/msp/MSPHelper.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var mspHelper = (function (gui) {
6868
color;
6969
if (!dataHandler.unsupported || dataHandler.unsupported) switch (dataHandler.code) {
7070
case MSPCodes.MSPV2_INAV_STATUS:
71+
let profile_changed = false;
7172
CONFIG.cycleTime = data.getUint16(offset, true);
7273
offset += 2;
7374
CONFIG.i2cError = data.getUint16(offset, true);
@@ -76,19 +77,28 @@ var mspHelper = (function (gui) {
7677
offset += 2;
7778
CONFIG.cpuload = data.getUint16(offset, true);
7879
offset += 2;
80+
7981
profile_byte = data.getUint8(offset++)
80-
CONFIG.profile = profile_byte & 0x0F;
81-
CONFIG.battery_profile = (profile_byte & 0xF0) >> 4;
82+
let profile = profile_byte & 0x0F;
83+
profile_changed |= (profile !== CONFIG.profile) && (CONFIG.profile !==-1);
84+
CONFIG.profile = profile;
85+
86+
let battery_profile = (profile_byte & 0xF0) >> 4;
87+
profile_changed |= (battery_profile !== CONFIG.battery_profile) && (CONFIG.battery_profile !==-1);
88+
CONFIG.battery_profile = battery_profile;
89+
8290
CONFIG.armingFlags = data.getUint32(offset, true);
8391
offset += 4;
8492

8593
//As there are 8 bytes for mspBoxModeFlags (number of bytes is actually variable)
8694
//read mixer profile as the last byte in the the message
8795
profile_byte = data.getUint8(dataHandler.message_length_expected - 1);
88-
CONFIG.mixer_profile = profile_byte & 0x0F;
96+
let mixer_profile = profile_byte & 0x0F;
97+
profile_changed |= (mixer_profile !== CONFIG.mixer_profile) && (CONFIG.mixer_profile !==-1);
98+
CONFIG.mixer_profile = mixer_profile;
8999

90100
gui.updateStatusBar();
91-
gui.updateProfileChange();
101+
gui.updateProfileChange(profile_changed);
92102
break;
93103

94104
case MSPCodes.MSP_ACTIVEBOXES:

0 commit comments

Comments
 (0)