mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 03:49:53 +03:00
Get GVAR status from FC
This commit is contained in:
parent
1f92a1383a
commit
f85a17d1ad
7 changed files with 61 additions and 8 deletions
|
@ -107,6 +107,7 @@ sources.js = [
|
||||||
'./js/logicConditionsCollection.js',
|
'./js/logicConditionsCollection.js',
|
||||||
'./js/globalFunctionsCollection.js',
|
'./js/globalFunctionsCollection.js',
|
||||||
'./js/logicConditionsStatus.js',
|
'./js/logicConditionsStatus.js',
|
||||||
|
'./js/globalVariablesStatus.js',
|
||||||
'./js/vtx.js',
|
'./js/vtx.js',
|
||||||
'./main.js',
|
'./main.js',
|
||||||
'./js/tabs.js',
|
'./js/tabs.js',
|
||||||
|
|
3
js/fc.js
3
js/fc.js
|
@ -20,7 +20,9 @@ var CONFIG,
|
||||||
SERVO_RULES,
|
SERVO_RULES,
|
||||||
MOTOR_RULES,
|
MOTOR_RULES,
|
||||||
LOGIC_CONDITIONS,
|
LOGIC_CONDITIONS,
|
||||||
|
LOGIC_CONDITIONS_STATUS,
|
||||||
GLOBAL_FUNCTIONS,
|
GLOBAL_FUNCTIONS,
|
||||||
|
GLOBAL_VARIABLES_STATUS,
|
||||||
SERIAL_CONFIG,
|
SERIAL_CONFIG,
|
||||||
SENSOR_DATA,
|
SENSOR_DATA,
|
||||||
MOTOR_DATA,
|
MOTOR_DATA,
|
||||||
|
@ -172,6 +174,7 @@ var FC = {
|
||||||
LOGIC_CONDITIONS = new LogicConditionsCollection();
|
LOGIC_CONDITIONS = new LogicConditionsCollection();
|
||||||
GLOBAL_FUNCTIONS = new GlobalFunctionsCollection();
|
GLOBAL_FUNCTIONS = new GlobalFunctionsCollection();
|
||||||
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
|
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
|
||||||
|
GLOBAL_VARIABLES_STATUS = new GlobalVariablesStatus();
|
||||||
|
|
||||||
MIXER_CONFIG = {
|
MIXER_CONFIG = {
|
||||||
yawMotorDirection: 0,
|
yawMotorDirection: 0,
|
||||||
|
|
25
js/globalVariablesStatus.js
Normal file
25
js/globalVariablesStatus.js
Normal 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;
|
||||||
|
};
|
|
@ -210,6 +210,7 @@ var MSPCodes = {
|
||||||
MSP2_INAV_GLOBAL_FUNCTIONS: 0x2024,
|
MSP2_INAV_GLOBAL_FUNCTIONS: 0x2024,
|
||||||
MSP2_INAV_SET_GLOBAL_FUNCTIONS: 0x2025,
|
MSP2_INAV_SET_GLOBAL_FUNCTIONS: 0x2025,
|
||||||
MSP2_INAV_LOGIC_CONDITIONS_STATUS: 0x2026,
|
MSP2_INAV_LOGIC_CONDITIONS_STATUS: 0x2026,
|
||||||
|
MSP2_INAV_GVAR_STATUS: 0x2027,
|
||||||
|
|
||||||
MSP2_PID: 0x2030,
|
MSP2_PID: 0x2030,
|
||||||
MSP2_SET_PID: 0x2031,
|
MSP2_SET_PID: 0x2031,
|
||||||
|
|
|
@ -535,6 +535,16 @@ var mspHelper = (function (gui) {
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case MSPCodes.MSP2_INAV_SET_LOGIC_CONDITIONS:
|
||||||
console.log("Logic conditions saved");
|
console.log("Logic conditions saved");
|
||||||
break;
|
break;
|
||||||
|
@ -3305,7 +3315,7 @@ var mspHelper = (function (gui) {
|
||||||
MSP.send_message(MSPCodes.MSP2_INAV_MC_BRAKING, false, false, callback);
|
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")) {
|
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
|
||||||
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_STATUS, false, false, callback);
|
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_STATUS, false, false, callback);
|
||||||
} else {
|
} 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;
|
return self;
|
||||||
})(GUI);
|
})(GUI);
|
||||||
|
|
|
@ -414,7 +414,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLogicConditionsStatus() {
|
function getLogicConditionsStatus() {
|
||||||
mspHelper.loadSensorStatus(onStatusPullDone);
|
mspHelper.loadLogicConditionsStatus(onStatusPullDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStatusPullDone() {
|
function onStatusPullDone() {
|
||||||
|
|
|
@ -4,7 +4,8 @@ TABS.programming = {};
|
||||||
|
|
||||||
TABS.programming.initialize = function (callback, scrollPosition) {
|
TABS.programming.initialize = function (callback, scrollPosition) {
|
||||||
let loadChainer = new MSPChainerClass(),
|
let loadChainer = new MSPChainerClass(),
|
||||||
saveChainer = new MSPChainerClass();
|
saveChainer = new MSPChainerClass(),
|
||||||
|
statusChainer = new MSPChainerClass();
|
||||||
|
|
||||||
if (GUI.active_tab != 'programming') {
|
if (GUI.active_tab != 'programming') {
|
||||||
GUI.active_tab = 'programming';
|
GUI.active_tab = 'programming';
|
||||||
|
@ -24,6 +25,12 @@ TABS.programming.initialize = function (callback, scrollPosition) {
|
||||||
mspHelper.saveToEeprom
|
mspHelper.saveToEeprom
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
statusChainer.setChain([
|
||||||
|
mspHelper.loadLogicConditionsStatus,
|
||||||
|
mspHelper.loadGlobalVariablesStatus
|
||||||
|
]);
|
||||||
|
statusChainer.setExitPoint(onStatusPullDone);
|
||||||
|
|
||||||
function loadHtml() {
|
function loadHtml() {
|
||||||
GUI.load("./tabs/programming.html", processHtml);
|
GUI.load("./tabs/programming.html", processHtml);
|
||||||
}
|
}
|
||||||
|
@ -45,16 +52,14 @@ TABS.programming.initialize = function (callback, scrollPosition) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
|
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);
|
GUI.content_ready(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLogicConditionsStatus() {
|
|
||||||
mspHelper.loadSensorStatus(onStatusPullDone);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onStatusPullDone() {
|
function onStatusPullDone() {
|
||||||
LOGIC_CONDITIONS.update(LOGIC_CONDITIONS_STATUS);
|
LOGIC_CONDITIONS.update(LOGIC_CONDITIONS_STATUS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue