mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 03:49:53 +03:00
Report logic condiotion activation status
This commit is contained in:
parent
e3b89453e8
commit
9c627f7445
9 changed files with 109 additions and 1 deletions
|
@ -102,6 +102,7 @@ sources.js = [
|
|||
'./js/servoMixerRuleCollection.js',
|
||||
'./js/motorMixerRuleCollection.js',
|
||||
'./js/logicConditionsCollection.js',
|
||||
'./js/logicConditionsStatus.js',
|
||||
'./js/vtx.js',
|
||||
'./main.js',
|
||||
'./tabs/*.js',
|
||||
|
|
1
js/fc.js
1
js/fc.js
|
@ -176,6 +176,7 @@ var FC = {
|
|||
SERVO_RULES = new ServoMixerRuleCollection();
|
||||
MOTOR_RULES = new MotorMixerRuleCollection();
|
||||
LOGIC_CONDITIONS = new LogicConditionsCollection();
|
||||
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
|
||||
|
||||
MIXER_CONFIG = {
|
||||
yawMotorDirection: 0,
|
||||
|
|
|
@ -191,6 +191,22 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue,
|
|||
}
|
||||
}
|
||||
|
||||
self.update = function (index, value, $container) {
|
||||
if (typeof $row === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
let $marker = $row.find('.logic_cell__active_marker');
|
||||
|
||||
if (!!value) {
|
||||
$marker.addClass("logic_cell__active_marker--active");
|
||||
$marker.removeClass("logic_cell__active_marker--inactive");
|
||||
} else {
|
||||
$marker.removeClass("logic_cell__active_marker--active");
|
||||
$marker.addClass("logic_cell__active_marker--inactive");
|
||||
}
|
||||
}
|
||||
|
||||
self.render = function (index, $container) {
|
||||
|
||||
$container.find('tbody').append('<tr>\
|
||||
|
@ -199,7 +215,7 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue,
|
|||
<td class="logic_cell__operation"></td>\
|
||||
<td class="logic_cell__operandA"></td>\
|
||||
<td class="logic_cell__operandB"></td>\
|
||||
<td class="logic_cell__flags"></td>\
|
||||
<td class="logic_cell__flags"><div class="logic_cell__active_marker"></div></td>\
|
||||
</tr>\
|
||||
');
|
||||
|
||||
|
|
|
@ -73,5 +73,15 @@ let LogicConditionsCollection = function () {
|
|||
|
||||
};
|
||||
|
||||
self.update = function(statuses) {
|
||||
let $table = $container.find(".logic__table")
|
||||
|
||||
for (let k in self.get()) {
|
||||
if (self.get().hasOwnProperty(k)) {
|
||||
self.get()[k].update(k, statuses.get(k), $table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
25
js/logicConditionsStatus.js
Normal file
25
js/logicConditionsStatus.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
let LogicConditionsStatus = 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;
|
||||
};
|
|
@ -207,6 +207,7 @@ var MSPCodes = {
|
|||
MSP2_INAV_SET_SERVO_MIXER: 0x2021,
|
||||
MSP2_INAV_LOGIC_CONDITIONS: 0x2022,
|
||||
MSP2_INAV_SET_LOGIC_CONDITIONS: 0x2023,
|
||||
MSP2_INAV_LOGIC_CONDITIONS_STATUS: 0x2026,
|
||||
|
||||
MSP2_PID: 0x2030,
|
||||
MSP2_SET_PID: 0x2031,
|
||||
|
|
|
@ -564,6 +564,16 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_STATUS:
|
||||
if (data.byteLength % 4 === 0) {
|
||||
let index = 0;
|
||||
for (i = 0; i < data.byteLength; i += 4) {
|
||||
LOGIC_CONDITIONS_STATUS.set(index, data.getInt32(i, true));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_SET_LOGIC_CONDITIONS:
|
||||
console.log("Logic conditions saved");
|
||||
break;
|
||||
|
@ -3335,5 +3345,21 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
};
|
||||
|
||||
self.loadBrakingConfig = function(callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "2.1.0")) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_MC_BRAKING, false, false, callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
self.loadSensorStatus = function (callback) {
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_STATUS, false, false, callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
})(GUI);
|
||||
|
|
|
@ -45,3 +45,19 @@ input.logic_element__operand--value {
|
|||
.logic_cell__operandB {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.logic_cell__active_marker {
|
||||
border: 1px solid #aaa;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 6px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.logic_cell__active_marker--active {
|
||||
background-color:rgb(55, 168, 219);
|
||||
}
|
||||
|
||||
.logic_cell__active_marker--inactive {
|
||||
background-color:transparent;
|
||||
}
|
|
@ -373,9 +373,21 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
|
||||
localize();
|
||||
|
||||
if (semver.gte(CONFIG.flightControllerVersion, "2.3.0")) {
|
||||
helper.mspBalancedInterval.add('logic_conditions_pull', 350, 1, getLogicConditionsStatus);
|
||||
}
|
||||
|
||||
GUI.content_ready(callback);
|
||||
}
|
||||
|
||||
function getLogicConditionsStatus() {
|
||||
mspHelper.loadSensorStatus(onStatusPullDone);
|
||||
}
|
||||
|
||||
function onStatusPullDone() {
|
||||
LOGIC_CONDITIONS.update(LOGIC_CONDITIONS_STATUS);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TABS.mixer.cleanup = function (callback) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue