1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

Added ordering for operators in programming

This commit is contained in:
Darren Lines 2022-02-07 21:26:23 +00:00
parent 30bc21ccb5
commit 7cfcf0a24a
2 changed files with 122 additions and 39 deletions

106
js/fc.js
View file

@ -1045,222 +1045,266 @@ var FC = {
return { return {
0: { 0: {
name: "True", name: "True",
operandType: "Active",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
1: { 1: {
name: "Equal", name: "Equal",
operandType: "Comparison",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
2: { 2: {
name: "Greater Than", name: "Greater Than",
operandType: "Comparison",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
3: { 3: {
name: "Lower Than", name: "Lower Than",
operandType: "Comparison",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
4: { 4: {
name: "Low", name: "Low",
operandType: "RC Switch Check",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
5: { 5: {
name: "Mid", name: "Mid",
operandType: "RC Switch Check",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
6: { 6: {
name: "High", name: "High",
operandType: "RC Switch Check",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
7: { 7: {
name: "AND", name: "AND",
operandType: "Logic",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
8: { 8: {
name: "OR", name: "OR",
operandType: "Logic",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
9: { 9: {
name: "XOR", name: "XOR",
operandType: "Logic",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
10: { 10: {
name: "NAND", name: "NAND",
operandType: "Logic",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
11: { 11: {
name: "NOR", name: "NOR",
operandType: "Logic",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
12: { 12: {
name: "NOT", name: "NOT",
operandType: "Logic",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
13: { 13: {
name: "STICKY", name: "Sticky",
operandType: "Switches",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
14: { 14: {
name: "ADD", name: "Basic: Add",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
15: { 15: {
name: "SUB", name: "Basic: Subtract",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
16: { 16: {
name: "MUL", name: "Basic: Multiply",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
17: { 17: {
name: "DIV", name: "Basic: Divide",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
40: { 40: {
name: "MOD", name: "Modulo",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
18: { 18: {
name: "GVAR SET", name: "Set GVAR",
operandType: "Variables",
hasOperand: [true, true], hasOperand: [true, true],
output: "none" output: "none"
}, },
19: { 19: {
name: "GVAR INC", name: "Increase GVAR",
operandType: "Variables",
hasOperand: [true, true], hasOperand: [true, true],
output: "none" output: "none"
}, },
20: { 20: {
name: "GVAR DEC", name: "Decrease GVAR",
operandType: "Variables",
hasOperand: [true, true], hasOperand: [true, true],
output: "none" output: "none"
}, },
21: { 21: {
name: "IO PORT SET", name: "Set IO Port",
operandType: "Set Flight Parameter",
hasOperand: [true, true], hasOperand: [true, true],
output: "none" output: "none"
}, },
22: { 22: {
name: "OVERRIDE ARMING SAFETY", name: "Override Arming Safety",
operandType: "Set Flight Parameter",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
23: { 23: {
name: "OVERRIDE THROTTLE SCALE", name: "Override Throttle Scale",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
29: { 29: {
name: "OVERRIDE THROTTLE", name: "Override Throttle",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
24: { 24: {
name: "SWAP ROLL & YAW", name: "Swap Roll & Yaw",
operandType: "Set Flight Parameter",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
25: { 25: {
name: "SET VTX POWER LEVEL", name: "Set VTx Power Level",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
30: { 30: {
name: "SET VTX BAND", name: "Set VTx Band",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
31: { 31: {
name: "SET VTX CHANNEL", name: "Set VTx Channel",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
26: { 26: {
name: "INVERT ROLL", name: "Invert Roll",
operandType: "Set Flight Parameter",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
27: { 27: {
name: "INVERT PITCH", name: "Invert Pitch",
operandType: "Set Flight Parameter",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
28: { 28: {
name: "INVERT YAW", name: "Invert Yaw",
operandType: "Set Flight Parameter",
hasOperand: [false, false], hasOperand: [false, false],
output: "boolean" output: "boolean"
}, },
32: { 32: {
name: "SET OSD LAYOUT", name: "Set OSD Layout",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
33: { 33: {
name: "SIN", name: "Trigonometry: Sine",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
34: { 34: {
name: "COS", name: "Trigonometry: Cosine",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
35: { 35: {
name: "TAN", name: "Trigonometry: Tangent",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
36: { 36: {
name: "MAP INPUT", name: "Map Input",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
37: { 37: {
name: "MAP OUTPUT", name: "Map Output",
operandType: "Maths",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
38: { 38: {
name: "RC CHANNEL OVERRIDE", name: "Override RC Channel",
operandType: "Set Flight Parameter",
hasOperand: [true, true], hasOperand: [true, true],
output: "boolean" output: "boolean"
}, },
41: { 41: {
name: "LOITER RADIUS OVERRIDE", name: "Override Loiter Radius",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
42: { 42: {
name: "SET PROFILE", name: "Set Profile",
operandType: "Set Flight Parameter",
hasOperand: [true, false], hasOperand: [true, false],
output: "boolean" output: "boolean"
}, },
43: { 43: {
name: "MIN", name: "Use Lowest Value",
operandType: "Comparison",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },
44: { 44: {
name: "MAX", name: "Use Highest Value",
operandType: "Comparison",
hasOperand: [true, true], hasOperand: [true, true],
output: "raw" output: "raw"
}, },

View file

@ -256,16 +256,55 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
$row.find('.logic_cell__operation').html("<select class='logic_element__operation' ></select>"); $row.find('.logic_cell__operation').html("<select class='logic_element__operation' ></select>");
let $t = $row.find('.logic_element__operation'); let $t = $row.find('.logic_element__operation');
for (let k in FC.getLogicOperators()) { let lcOperators = [];
if (FC.getLogicOperators().hasOwnProperty(k)) {
let o = FC.getLogicOperators()[k]; for (let lcID in FC.getLogicOperators()) {
if (self.getOperation() == parseInt(k, 10)) { if (FC.getLogicOperators().hasOwnProperty(lcID)) {
$t.append('<option value="' + k + '" selected>' + o.name + '</option>'); let op = FC.getLogicOperators()[lcID];
lcOperators[parseInt(lcID, 10)] = {
id: parseInt(lcID, 10),
name: op.name,
operandType: op.operandType,
hasOperand: op.hasOperand,
output: op.output
};
}
}
lcOperators.sort((a, b) => {
let lcAT = a.operandType.toLowerCase(),
lcBT = b.operandType.toLowerCase(),
lcAN = a.name.toLowerCase(),
lcBN = b.name.toLowerCase();
if (lcAT == lcBT) {
return (lcAN < lcBN) ? -1 : (lcAN > lcBN) ? 1 : 0;
} else { } else {
$t.append('<option value="' + k + '">' + o.name + '</option>'); return (lcAT < lcBT) ? -1 : 1;
} }
});
let section = "";
lcOperators.forEach( val => {
if (section != val.operandType) {
if (section != "") {
$t.append('</optgroup>');
} }
section = val.operandType;
$t.append('<optgroup label="** ' + val.operandType + ' **">');
} }
if (self.getOperation() == val.id) {
$t.append('<option value="' + val.id + '" selected>' + val.name + '</option>');
} else {
$t.append('<option value="' + val.id + '">' + val.name + '</option>');
}
});
$t.append('</optgroup>');
$t.change(self.onOperatorChange); $t.change(self.onOperatorChange);
self.renderOperand(0); self.renderOperand(0);