1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 19:40:22 +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

@ -107,6 +107,7 @@ sources.js = [
'./js/logicConditionsCollection.js',
'./js/globalFunctionsCollection.js',
'./js/logicConditionsStatus.js',
'./js/globalVariablesStatus.js',
'./js/vtx.js',
'./main.js',
'./js/tabs.js',

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);

View file

@ -414,7 +414,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}
function getLogicConditionsStatus() {
mspHelper.loadSensorStatus(onStatusPullDone);
mspHelper.loadLogicConditionsStatus(onStatusPullDone);
}
function onStatusPullDone() {

View file

@ -4,7 +4,8 @@ TABS.programming = {};
TABS.programming.initialize = function (callback, scrollPosition) {
let loadChainer = new MSPChainerClass(),
saveChainer = new MSPChainerClass();
saveChainer = new MSPChainerClass(),
statusChainer = new MSPChainerClass();
if (GUI.active_tab != 'programming') {
GUI.active_tab = 'programming';
@ -24,6 +25,12 @@ TABS.programming.initialize = function (callback, scrollPosition) {
mspHelper.saveToEeprom
]);
statusChainer.setChain([
mspHelper.loadLogicConditionsStatus,
mspHelper.loadGlobalVariablesStatus
]);
statusChainer.setExitPoint(onStatusPullDone);
function loadHtml() {
GUI.load("./tabs/programming.html", processHtml);
}
@ -45,16 +52,14 @@ TABS.programming.initialize = function (callback, scrollPosition) {
});
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
helper.mspBalancedInterval.add('logic_conditions_pull', 350, 1, getLogicConditionsStatus);
helper.mspBalancedInterval.add('logic_conditions_pull', 350, 1, function () {
statusChainer.execute();
});
}
GUI.content_ready(callback);
}
function getLogicConditionsStatus() {
mspHelper.loadSensorStatus(onStatusPullDone);
}
function onStatusPullDone() {
LOGIC_CONDITIONS.update(LOGIC_CONDITIONS_STATUS);
}