mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 11:59:51 +03:00
Fix bug in MSP_ACTIVEBOXES decoding
In JS `(1<<32) == 1` so it was causing an issue when the FC was advertising more than 32 mode boxes
This commit is contained in:
parent
83bd7ac67f
commit
1b453762a1
6 changed files with 37 additions and 37 deletions
15
js/fc.js
15
js/fc.js
|
@ -95,7 +95,7 @@ var FC = {
|
|||
cycleTime: 0,
|
||||
i2cError: 0,
|
||||
activeSensors: 0,
|
||||
mode: 0,
|
||||
mode: [],
|
||||
profile: 0,
|
||||
uid: [0, 0, 0],
|
||||
accelerometerTrims: [0, 0],
|
||||
|
@ -1081,5 +1081,18 @@ var FC = {
|
|||
},
|
||||
getServoMixInputName: function (input) {
|
||||
return getServoMixInputNames()[input];
|
||||
},
|
||||
getModeId: function (name) {
|
||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||
if (AUX_CONFIG[i] == name)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
isModeBitSet: function (i) {
|
||||
return bit_check(CONFIG.mode[Math.trunc(i / 32)], i % 32);
|
||||
},
|
||||
isModeEnabled: function (name) {
|
||||
return FC.isModeBitSet(FC.getModeId(name));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -124,16 +124,9 @@ var mspHelper = (function (gui) {
|
|||
case MSPCodes.MSP_ACTIVEBOXES:
|
||||
var words = dataHandler.message_length_expected / 4;
|
||||
|
||||
CONFIG.mode = 0;
|
||||
if (words == 1) {
|
||||
CONFIG.mode = data.getUint32(0, true);
|
||||
}
|
||||
else if (words == 2) {
|
||||
CONFIG.mode = data.getUint32(0, true) | (data.getUint32(4, true) << 32);
|
||||
}
|
||||
else {
|
||||
console.log('MSP_ACTIVEBOXES doesn\'t support more than 53 bits at the moment');
|
||||
}
|
||||
CONFIG.mode = [];
|
||||
for (i = 0; i < words; ++i)
|
||||
CONFIG.mode.push(data.getUint32(i * 4, true));
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_SENSOR_STATUS:
|
||||
|
|
|
@ -37,9 +37,7 @@ helper.periodicStatusUpdater = (function () {
|
|||
|
||||
var active = ((Date.now() - MSP.analog_last_received_timestamp) < publicScope.getUpdateInterval(serial.bitrate) * 3);
|
||||
|
||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||
if (AUX_CONFIG[i] == 'ARM') {
|
||||
if (bit_check(CONFIG.mode, i))
|
||||
if (FC.isModeEnabled('ARM'))
|
||||
$(".armedicon").css({
|
||||
'background-image': 'url("../images/icons/cf_icon_armed_active.svg")'
|
||||
});
|
||||
|
@ -47,9 +45,7 @@ helper.periodicStatusUpdater = (function () {
|
|||
$(".armedicon").css({
|
||||
'background-image': 'url("../images/icons/cf_icon_armed_grey.svg")'
|
||||
});
|
||||
}
|
||||
if (AUX_CONFIG[i] == 'FAILSAFE') {
|
||||
if (bit_check(CONFIG.mode, i))
|
||||
if (FC.isModeEnabled('FAILSAFE'))
|
||||
$(".failsafeicon").css({
|
||||
'background-image': 'url("../images/icons/cf_icon_failsafe_active.svg")'
|
||||
});
|
||||
|
@ -57,8 +53,6 @@ helper.periodicStatusUpdater = (function () {
|
|||
$(".failsafeicon").css({
|
||||
'background-image': 'url("../images/icons/cf_icon_failsafe_grey.svg")'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (ANALOG != undefined) {
|
||||
var nbCells;
|
||||
|
|
|
@ -285,7 +285,7 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (bit_check(CONFIG.mode, i)) {
|
||||
if (FC.isModeBitSet(i)) {
|
||||
$('.mode .name').eq(i).data('modeElement').addClass('on').removeClass('off');
|
||||
} else {
|
||||
$('.mode .name').eq(i).data('modeElement').removeClass('on').addClass('off');
|
||||
|
|
|
@ -121,7 +121,7 @@ TABS.modes.initialize = function (callback) {
|
|||
|
||||
function update_ui() {
|
||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||
if (bit_check(CONFIG.mode, i)) {
|
||||
if (FC.isModeBitSet(i)) {
|
||||
$('td.name').eq(i).addClass('on').removeClass('off');
|
||||
} else {
|
||||
$('td.name').eq(i).removeClass('on').removeClass('off');
|
||||
|
|
|
@ -50,7 +50,7 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function update_arm_status() {
|
||||
self.armed = bit_check(CONFIG.mode, 0);
|
||||
self.armed = FC.isModeEnabled('ARM');
|
||||
}
|
||||
|
||||
function initSensorData() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue