Skip to content

Commit

Permalink
Merge pull request #1892 from shota3527/sh_vtol
Browse files Browse the repository at this point in the history
Detect profiles changes and refresh
  • Loading branch information
DzikuVx authored Nov 17, 2023
2 parents bbbecb2 + e691537 commit 413c1bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
6 changes: 3 additions & 3 deletions js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ var FC = {
i2cError: 0,
activeSensors: 0,
mode: [],
mixer_profile: 0,
profile: 0,
battery_profile: 0,
mixer_profile: -1,
profile: -1,
battery_profile: -1,
uid: [0, 0, 0],
accelerometerTrims: [0, 0],
armingFlags: 0,
Expand Down
8 changes: 7 additions & 1 deletion js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,16 @@ GUI_control.prototype.updateStatusBar = function() {
$('span.arming-flags').text(activeArmFlags.length ? activeArmFlags.join(', ') : '-');
};

GUI_control.prototype.updateProfileChange = function() {
GUI_control.prototype.updateProfileChange = function(refresh) {
$('#mixerprofilechange').val(CONFIG.mixer_profile);
$('#profilechange').val(CONFIG.profile);
$('#batteryprofilechange').val(CONFIG.battery_profile);
if (refresh) {
GUI.log(chrome.i18n.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1]));
GUI.log(chrome.i18n.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1]));
GUI.log(chrome.i18n.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1]));
updateActivatedTab();
}
};

GUI_control.prototype.fillSelect = function ($element, values, currentValue, unit) {
Expand Down
18 changes: 14 additions & 4 deletions js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var mspHelper = (function (gui) {
color;
if (!dataHandler.unsupported || dataHandler.unsupported) switch (dataHandler.code) {
case MSPCodes.MSPV2_INAV_STATUS:
let profile_changed = false;
CONFIG.cycleTime = data.getUint16(offset, true);
offset += 2;
CONFIG.i2cError = data.getUint16(offset, true);
Expand All @@ -76,19 +77,28 @@ var mspHelper = (function (gui) {
offset += 2;
CONFIG.cpuload = data.getUint16(offset, true);
offset += 2;

profile_byte = data.getUint8(offset++)
CONFIG.profile = profile_byte & 0x0F;
CONFIG.battery_profile = (profile_byte & 0xF0) >> 4;
let profile = profile_byte & 0x0F;
profile_changed |= (profile !== CONFIG.profile) && (CONFIG.profile !==-1);
CONFIG.profile = profile;

let battery_profile = (profile_byte & 0xF0) >> 4;
profile_changed |= (battery_profile !== CONFIG.battery_profile) && (CONFIG.battery_profile !==-1);
CONFIG.battery_profile = battery_profile;

CONFIG.armingFlags = data.getUint32(offset, true);
offset += 4;

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

gui.updateStatusBar();
gui.updateProfileChange();
gui.updateProfileChange(profile_changed);
break;

case MSPCodes.MSP_ACTIVEBOXES:
Expand Down

0 comments on commit 413c1bb

Please sign in to comment.