1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 12:25:13 +03:00

Get GVAR status from FC

This commit is contained in:
Pawel Spychalski (DzikuVx) 2020-04-10 21:37:24 +02:00
parent 1f92a1383a
commit f85a17d1ad
7 changed files with 61 additions and 8 deletions

View file

@ -20,7 +20,9 @@ var CONFIG,
SERVO_RULES,
MOTOR_RULES,
LOGIC_CONDITIONS,
LOGIC_CONDITIONS_STATUS,
GLOBAL_FUNCTIONS,
GLOBAL_VARIABLES_STATUS,
SERIAL_CONFIG,
SENSOR_DATA,
MOTOR_DATA,
@ -172,6 +174,7 @@ var FC = {
LOGIC_CONDITIONS = new LogicConditionsCollection();
GLOBAL_FUNCTIONS = new GlobalFunctionsCollection();
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
GLOBAL_VARIABLES_STATUS = new GlobalVariablesStatus();
MIXER_CONFIG = {
yawMotorDirection: 0,

View file

@ -0,0 +1,25 @@
'use strict';
let GlobalVariablesStatus = function () {
let self = {},
data = [];
self.set = function (condition, value) {
data[condition] = value;
}
self.get = function (condition) {
if (typeof data[condition] !== 'undefined') {
return data[condition];
} else {
return null;
}
}
self.getAll = function() {
return data;
}
return self;
};

View file

@ -210,6 +210,7 @@ var MSPCodes = {
MSP2_INAV_GLOBAL_FUNCTIONS: 0x2024,
MSP2_INAV_SET_GLOBAL_FUNCTIONS: 0x2025,
MSP2_INAV_LOGIC_CONDITIONS_STATUS: 0x2026,
MSP2_INAV_GVAR_STATUS: 0x2027,
MSP2_PID: 0x2030,
MSP2_SET_PID: 0x2031,

View file

@ -535,6 +535,16 @@ var mspHelper = (function (gui) {
}
break;
case MSPCodes.MSP2_INAV_GVAR_STATUS:
if (data.byteLength % 4 === 0) {
let index = 0;
for (i = 0; i < data.byteLength; i += 4) {
GLOBAL_VARIABLES_STATUS.set(index, data.getInt32(i, true));
index++;
}
}
break;
case MSPCodes.MSP2_INAV_SET_LOGIC_CONDITIONS:
console.log("Logic conditions saved");
break;
@ -3305,7 +3315,7 @@ var mspHelper = (function (gui) {
MSP.send_message(MSPCodes.MSP2_INAV_MC_BRAKING, false, false, callback);
}
self.loadSensorStatus = function (callback) {
self.loadLogicConditionsStatus = function (callback) {
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_STATUS, false, false, callback);
} else {
@ -3313,5 +3323,13 @@ var mspHelper = (function (gui) {
}
};
self.loadGlobalVariablesStatus = function (callback) {
if (semver.gte(CONFIG.flightControllerVersion, "2.5.0")) {
MSP.send_message(MSPCodes.MSP2_INAV_GVAR_STATUS, false, false, callback);
} else {
callback();
}
};
return self;
})(GUI);