mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 04:15:28 +03:00
Drop Global Functions support
This commit is contained in:
parent
752cd2360e
commit
0dcf1a9e58
7 changed files with 43 additions and 441 deletions
|
@ -90,7 +90,6 @@ sources.js = [
|
|||
'./js/servoMixRule.js',
|
||||
'./js/motorMixRule.js',
|
||||
'./js/logicCondition.js',
|
||||
'./js/globalFunction.js',
|
||||
'./js/settings.js',
|
||||
'./js/outputMapping.js',
|
||||
'./js/model.js',
|
||||
|
@ -105,7 +104,6 @@ sources.js = [
|
|||
'./js/servoMixerRuleCollection.js',
|
||||
'./js/motorMixerRuleCollection.js',
|
||||
'./js/logicConditionsCollection.js',
|
||||
'./js/globalFunctionsCollection.js',
|
||||
'./js/logicConditionsStatus.js',
|
||||
'./js/globalVariablesStatus.js',
|
||||
'./js/vtx.js',
|
||||
|
|
49
js/fc.js
49
js/fc.js
|
@ -172,7 +172,6 @@ var FC = {
|
|||
SERVO_RULES = new ServoMixerRuleCollection();
|
||||
MOTOR_RULES = new MotorMixerRuleCollection();
|
||||
LOGIC_CONDITIONS = new LogicConditionsCollection();
|
||||
GLOBAL_FUNCTIONS = new GlobalFunctionsCollection();
|
||||
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
|
||||
GLOBAL_VARIABLES_STATUS = new GlobalVariablesStatus();
|
||||
|
||||
|
@ -1188,54 +1187,6 @@ var FC = {
|
|||
}
|
||||
}
|
||||
},
|
||||
getFunctionActions: function () {
|
||||
return {
|
||||
0: {
|
||||
name: "OVERRIDE ARMING SAFETY",
|
||||
hasOperand: false
|
||||
},
|
||||
1: {
|
||||
name: "OVERRIDE THROTTLE SCALE",
|
||||
hasOperand: true
|
||||
},
|
||||
2: {
|
||||
name: "SWAP ROLL & YAW",
|
||||
hasOperand: false
|
||||
},
|
||||
3: {
|
||||
name: "SET VTX POWER LEVEL",
|
||||
hasOperand: true
|
||||
},
|
||||
8: {
|
||||
name: "SET VTX BAND",
|
||||
hasOperand: true
|
||||
},
|
||||
9: {
|
||||
name: "SET VTX CHANNEL",
|
||||
hasOperand: true
|
||||
},
|
||||
4: {
|
||||
name: "INVERT ROLL",
|
||||
hasOperand: false
|
||||
},
|
||||
5: {
|
||||
name: "INVERT PITCH",
|
||||
hasOperand: false
|
||||
},
|
||||
6: {
|
||||
name: "INVERT YAW",
|
||||
hasOperand: false
|
||||
},
|
||||
7: {
|
||||
name: "OVERRIDE THROTTLE",
|
||||
hasOperand: true
|
||||
},
|
||||
10: {
|
||||
name: "SET OSD LAYOUT",
|
||||
hasOperand: true
|
||||
}
|
||||
}
|
||||
},
|
||||
getOperandTypes: function () {
|
||||
return {
|
||||
0: {
|
||||
|
|
|
@ -1,207 +0,0 @@
|
|||
/*global $,FC*/
|
||||
'use strict';
|
||||
|
||||
let GlobalFunction = function (enabled, conditionId, action, operandType, operandValue, flags) {
|
||||
let self = {};
|
||||
let $row;
|
||||
|
||||
self.getEnabled = function () {
|
||||
return !!enabled;
|
||||
}
|
||||
|
||||
self.setEnabled = function (data) {
|
||||
enabled = !!data;
|
||||
}
|
||||
|
||||
self.getConditionId = function () {
|
||||
return conditionId;
|
||||
}
|
||||
|
||||
self.setConditionId = function (data) {
|
||||
conditionId = data;
|
||||
}
|
||||
|
||||
self.getAction = function () {
|
||||
return action;
|
||||
}
|
||||
|
||||
self.setAction = function (data) {
|
||||
action = data;
|
||||
}
|
||||
|
||||
self.getOperandType = function () {
|
||||
return operandType;
|
||||
}
|
||||
|
||||
self.setOperandType = function (data) {
|
||||
operandType = data;
|
||||
}
|
||||
|
||||
self.getOperandValue = function () {
|
||||
return operandValue;
|
||||
}
|
||||
|
||||
self.setOperandValue = function (data) {
|
||||
operandValue = data;
|
||||
}
|
||||
|
||||
self.getFlags = function () {
|
||||
return flags;
|
||||
};
|
||||
|
||||
self.setFlags = function (data) {
|
||||
flags = data;
|
||||
};
|
||||
|
||||
self.onOperatorValueChange = function (event) {
|
||||
let $cT = $(event.currentTarget);
|
||||
self.setOperandValue($cT.val());
|
||||
};
|
||||
|
||||
self.onOperatorTypeChange = function (event) {
|
||||
let $cT = $(event.currentTarget),
|
||||
operand = $cT.data("operand"),
|
||||
$container = $cT.parent(),
|
||||
operandMetadata = FC.getOperandTypes()[$cT.val()];
|
||||
|
||||
self.setOperandType($cT.val());
|
||||
self.setOperandValue(operandMetadata.default);
|
||||
|
||||
GUI.renderOperandValue($container, operandMetadata, operand, operandMetadata.default, self.onOperatorValueChange);
|
||||
};
|
||||
|
||||
self.onEnabledChange = function (event) {
|
||||
let $cT = $(event.currentTarget),
|
||||
$parent = $cT.closest('tr');
|
||||
self.setEnabled(!!$cT.prop('checked'));
|
||||
|
||||
self.renderAction($parent);
|
||||
self.renderOperand($parent);
|
||||
self.renderLogicId($parent);
|
||||
};
|
||||
|
||||
self.onLogicIdChange = function(event) {
|
||||
let $cT = $(event.currentTarget);
|
||||
self.setConditionId($cT.val());
|
||||
};
|
||||
|
||||
self.onActionChange = function (event) {
|
||||
let $cT = $(event.currentTarget);
|
||||
self.setAction($cT.val());
|
||||
self.renderOperand($cT.closest('tr'));
|
||||
};
|
||||
|
||||
self.hasOperand = function () {
|
||||
|
||||
let actions = FC.getFunctionActions();
|
||||
|
||||
if (!self.getEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return actions[self.getAction()].hasOperand;
|
||||
};
|
||||
|
||||
self.renderOperand = function ($row) {
|
||||
let $container;
|
||||
|
||||
$container = $row.find('.function_cell__operand');
|
||||
|
||||
$container.html('');
|
||||
if (self.hasOperand()) {
|
||||
|
||||
$container.append('<select class="logic_element__operand--type" data-operand="0"></select>');
|
||||
let $t = $container.find('.logic_element__operand--type');
|
||||
|
||||
for (let k in FC.getOperandTypes()) {
|
||||
if (FC.getOperandTypes().hasOwnProperty(k)) {
|
||||
let op = FC.getOperandTypes()[k];
|
||||
|
||||
if (operandType == k) {
|
||||
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
||||
|
||||
/*
|
||||
* Render value element depending on type
|
||||
*/
|
||||
GUI.renderOperandValue($container, op, 0, operandValue, self.onOperatorValueChange);
|
||||
|
||||
} else {
|
||||
$t.append('<option value="' + k + '">' + op.name + '</option>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Bind events
|
||||
*/
|
||||
$t.change(self.onOperatorTypeChange);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
self.renderAction = function ($row) {
|
||||
|
||||
if (self.getEnabled()) {
|
||||
|
||||
$row.find('.function_cell__action').html("<select class='function__action' ></select>");
|
||||
let $t = $row.find(".function__action");
|
||||
|
||||
for (let k in FC.getFunctionActions()) {
|
||||
if (FC.getFunctionActions().hasOwnProperty(k)) {
|
||||
let o = FC.getFunctionActions()[k];
|
||||
if (self.getAction() == parseInt(k, 10)) {
|
||||
$t.append('<option value="' + k + '" selected>' + o.name + '</option>');
|
||||
} else {
|
||||
$t.append('<option value="' + k + '">' + o.name + '</option>');
|
||||
}
|
||||
}
|
||||
}
|
||||
$t.change(self.onActionChange);
|
||||
} else {
|
||||
$row.find('.function_cell__action').html("");
|
||||
}
|
||||
};
|
||||
|
||||
self.renderLogicId = function($row) {
|
||||
|
||||
if (self.getEnabled()) {
|
||||
GUI.renderLogicConditionSelect(
|
||||
$row.find('.function_cell__logicId'),
|
||||
LOGIC_CONDITIONS,
|
||||
self.getConditionId(),
|
||||
self.onLogicIdChange,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$row.find('.function_cell__logicId').html("");
|
||||
}
|
||||
}
|
||||
|
||||
self.render = function (index, $container) {
|
||||
|
||||
$container.find('tbody').append('<tr>\
|
||||
<td class="function_cell__index"></td>\
|
||||
<td class="function_cell__enabled"></td>\
|
||||
<td class="function_cell__logicId"></td>\
|
||||
<td class="function_cell__action"></td>\
|
||||
<td class="function_cell__operand"></td>\
|
||||
<td class="function_cell__flags"></td>\
|
||||
<td class="function_cell__status"><div class="logic_cell__active_marker"></div></td>\
|
||||
</tr>\
|
||||
');
|
||||
|
||||
$row = $container.find('tr:last');
|
||||
|
||||
$row.find('.function_cell__index').html(index);
|
||||
$row.find('.function_cell__enabled').html("<input type='checkbox' class='toggle function_element__enabled' />");
|
||||
$row.find('.function_element__enabled').
|
||||
prop('checked', self.getEnabled()).
|
||||
change(self.onEnabledChange);
|
||||
self.renderLogicId($row);
|
||||
self.renderAction($row);
|
||||
self.renderOperand($row);
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let GlobalFunctionsCollection = function () {
|
||||
let self = {},
|
||||
data = [],
|
||||
$container;
|
||||
|
||||
self.put = function (element) {
|
||||
data.push(element);
|
||||
};
|
||||
|
||||
self.get = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
self.flush = function () {
|
||||
data = [];
|
||||
};
|
||||
|
||||
self.getCount = function () {
|
||||
return data.length
|
||||
};
|
||||
|
||||
self.init = function ($element) {
|
||||
|
||||
if (semver.lt(CONFIG.flightControllerVersion, "2.4.0")) {
|
||||
return;
|
||||
}
|
||||
|
||||
$container = $element;
|
||||
};
|
||||
|
||||
self.render = function () {
|
||||
let $table = $container.find(".function__table")
|
||||
$table.find("tbody tr").remove();
|
||||
|
||||
for (let k in self.get()) {
|
||||
if (self.get().hasOwnProperty(k)) {
|
||||
self.get()[k].render(k, $table);
|
||||
}
|
||||
}
|
||||
|
||||
GUI.switchery();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
|
@ -552,26 +552,6 @@ var mspHelper = (function (gui) {
|
|||
console.log("Logic conditions saved");
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_GLOBAL_FUNCTIONS:
|
||||
GLOBAL_FUNCTIONS.flush();
|
||||
if (data.byteLength % 9 === 0) {
|
||||
for (i = 0; i < data.byteLength; i += 9) {
|
||||
GLOBAL_FUNCTIONS.put(new GlobalFunction(
|
||||
data.getInt8(i),
|
||||
data.getInt8(i + 1),
|
||||
data.getInt8(i + 2),
|
||||
data.getInt8(i + 3),
|
||||
data.getInt32(i + 4, true),
|
||||
data.getInt8(i + 8)
|
||||
));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_INAV_SET_GLOBAL_FUNCTIONS:
|
||||
console.log("Global functions saved");
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP2_COMMON_MOTOR_MIXER:
|
||||
MOTOR_RULES.flush();
|
||||
|
||||
|
@ -2380,48 +2360,6 @@ var mspHelper = (function (gui) {
|
|||
}
|
||||
};
|
||||
|
||||
self.loadGlobalFunctions = function (callback) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_GLOBAL_FUNCTIONS, false, false, callback);
|
||||
}
|
||||
|
||||
self.sendGlobalFunctions = function (onCompleteCallback) {
|
||||
let nextFunction = sendGlobalFunction,
|
||||
functionIndex = 0;
|
||||
|
||||
if (GLOBAL_FUNCTIONS.getCount() == 0) {
|
||||
onCompleteCallback();
|
||||
} else {
|
||||
nextFunction();
|
||||
}
|
||||
|
||||
function sendGlobalFunction() {
|
||||
|
||||
let buffer = [];
|
||||
|
||||
// send one at a time, with index, 14 bytes per one condition
|
||||
|
||||
let globalFunction = GLOBAL_FUNCTIONS.get()[functionIndex];
|
||||
|
||||
buffer.push(functionIndex);
|
||||
buffer.push(globalFunction.getEnabled());
|
||||
buffer.push(globalFunction.getConditionId());
|
||||
buffer.push(globalFunction.getAction());
|
||||
buffer.push(globalFunction.getOperandType());
|
||||
buffer.push(specificByte(globalFunction.getOperandValue(), 0));
|
||||
buffer.push(specificByte(globalFunction.getOperandValue(), 1));
|
||||
buffer.push(specificByte(globalFunction.getOperandValue(), 2));
|
||||
buffer.push(specificByte(globalFunction.getOperandValue(), 3));
|
||||
buffer.push(globalFunction.getFlags());
|
||||
|
||||
// prepare for next iteration
|
||||
functionIndex++;
|
||||
if (functionIndex == GLOBAL_FUNCTIONS.getCount()) { //This is the last rule. Not pretty, but we have to send all rules
|
||||
nextFunction = onCompleteCallback;
|
||||
}
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SET_GLOBAL_FUNCTIONS, buffer, false, nextFunction);
|
||||
}
|
||||
};
|
||||
|
||||
self.sendModeRanges = function (onCompleteCallback) {
|
||||
var nextFunction = send_next_mode_range;
|
||||
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
<div class="tab-configuration tab-programming toolbar_fixed_bottom">
|
||||
<div class="content_wrapper" id="programming-main-content">
|
||||
|
||||
<div class="tab_title subtab__header">
|
||||
<span class="subtab__header_label subtab__header_label--current" for="logic-wrapper" data-i18n="tabLogicConditions"></span>
|
||||
<span class="subtab__header_label" for="functions-wrapper" data-i18n="globalFunctions"></span>
|
||||
</div>
|
||||
|
||||
<div id="logic-wrapper" class="subtab__content subtab__content--current">
|
||||
|
||||
<div class="gvar__container">
|
||||
<div class="gvar__wrapper">
|
||||
<div class="gvar__cell">
|
||||
|
@ -51,25 +44,6 @@
|
|||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="functions-wrapper" class="subtab__content">
|
||||
<table class="mixer-table function__table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50px" data-i18n="functionId"></th>
|
||||
<th style="width: 80px" data-i18n="functionEnabled"></th>
|
||||
<th style="width: 120px" data-i18n="functionLogicId"></th>
|
||||
<th data-i18n="functionAction"></th>
|
||||
<th data-i18n="functionOperand"></th>
|
||||
<th data-i18n="functionFlags"></th>
|
||||
<th data-i18n="functionStatus"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="content_toolbar">
|
||||
|
|
|
@ -13,15 +13,13 @@ TABS.programming.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
loadChainer.setChain([
|
||||
mspHelper.loadLogicConditions,
|
||||
mspHelper.loadGlobalFunctions
|
||||
mspHelper.loadLogicConditions
|
||||
]);
|
||||
loadChainer.setExitPoint(loadHtml);
|
||||
loadChainer.execute();
|
||||
|
||||
saveChainer.setChain([
|
||||
mspHelper.sendLogicConditions,
|
||||
mspHelper.sendGlobalFunctions,
|
||||
mspHelper.saveToEeprom
|
||||
]);
|
||||
|
||||
|
@ -37,12 +35,9 @@ TABS.programming.initialize = function (callback, scrollPosition) {
|
|||
|
||||
function processHtml() {
|
||||
|
||||
LOGIC_CONDITIONS.init($('#logic-wrapper'));
|
||||
LOGIC_CONDITIONS.init($('#programming-main-content'));
|
||||
LOGIC_CONDITIONS.render();
|
||||
|
||||
GLOBAL_FUNCTIONS.init($('#functions-wrapper'));
|
||||
GLOBAL_FUNCTIONS.render();
|
||||
|
||||
helper.tabs.init($('.tab-programming'));
|
||||
|
||||
localize();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue