mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Refactor programming defines and extract definitions to separate modules
This commit is contained in:
parent
71817afc08
commit
18912e031d
5 changed files with 479 additions and 472 deletions
458
js/fc.js
458
js/fc.js
|
@ -961,464 +961,6 @@ var FC = {
|
||||||
isModeEnabled: function (name) {
|
isModeEnabled: function (name) {
|
||||||
return this.isModeBitSet(this.getModeId(name));
|
return this.isModeBitSet(this.getModeId(name));
|
||||||
},
|
},
|
||||||
getLogicOperators: function () {
|
|
||||||
return {
|
|
||||||
0: {
|
|
||||||
name: "True",
|
|
||||||
operandType: "Active",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
1: {
|
|
||||||
name: "Equal (A = B)",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
2: {
|
|
||||||
name: "Greater Than (A > B)",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
3: {
|
|
||||||
name: "Lower Than (A < B)",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
4: {
|
|
||||||
name: "Low",
|
|
||||||
operandType: "RC Switch Check",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
5: {
|
|
||||||
name: "Mid",
|
|
||||||
operandType: "RC Switch Check",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
6: {
|
|
||||||
name: "High",
|
|
||||||
operandType: "RC Switch Check",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
7: {
|
|
||||||
name: "AND",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
8: {
|
|
||||||
name: "OR",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
9: {
|
|
||||||
name: "XOR",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
10: {
|
|
||||||
name: "NAND",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
11: {
|
|
||||||
name: "NOR",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
12: {
|
|
||||||
name: "NOT",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
13: {
|
|
||||||
name: "Sticky",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
14: {
|
|
||||||
name: "Basic: Add",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
15: {
|
|
||||||
name: "Basic: Subtract",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
16: {
|
|
||||||
name: "Basic: Multiply",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
17: {
|
|
||||||
name: "Basic: Divide",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
40: {
|
|
||||||
name: "Modulo",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
18: {
|
|
||||||
name: "Set GVAR",
|
|
||||||
operandType: "Variables",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "none"
|
|
||||||
},
|
|
||||||
19: {
|
|
||||||
name: "Increase GVAR",
|
|
||||||
operandType: "Variables",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "none"
|
|
||||||
},
|
|
||||||
20: {
|
|
||||||
name: "Decrease GVAR",
|
|
||||||
operandType: "Variables",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "none"
|
|
||||||
},
|
|
||||||
21: {
|
|
||||||
name: "Set IO Port",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "none"
|
|
||||||
},
|
|
||||||
22: {
|
|
||||||
name: "Override Arming Safety",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
23: {
|
|
||||||
name: "Override Throttle Scale",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
29: {
|
|
||||||
name: "Override Throttle",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
24: {
|
|
||||||
name: "Swap Roll & Yaw",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
25: {
|
|
||||||
name: "Set VTx Power Level",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
30: {
|
|
||||||
name: "Set VTx Band",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
31: {
|
|
||||||
name: "Set VTx Channel",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
26: {
|
|
||||||
name: "Invert Roll",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
27: {
|
|
||||||
name: "Invert Pitch",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
28: {
|
|
||||||
name: "Invert Yaw",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
32: {
|
|
||||||
name: "Set OSD Layout",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
33: {
|
|
||||||
name: "Trigonometry: Sine",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
34: {
|
|
||||||
name: "Trigonometry: Cosine",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
35: {
|
|
||||||
name: "Trigonometry: Tangent",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
36: {
|
|
||||||
name: "Map Input",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
37: {
|
|
||||||
name: "Map Output",
|
|
||||||
operandType: "Maths",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
38: {
|
|
||||||
name: "Override RC Channel",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
|
|
||||||
41: {
|
|
||||||
name: "Override Loiter Radius",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
42: {
|
|
||||||
name: "Set Profile",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
43: {
|
|
||||||
name: "Use Lowest Value",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
44: {
|
|
||||||
name: "Use Highest Value",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
45: {
|
|
||||||
name: "Flight Axis Angle Override",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
46: {
|
|
||||||
name: "Flight Axis Rate Override",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
47: {
|
|
||||||
name: "Edge",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
48: {
|
|
||||||
name: "Delay",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
49: {
|
|
||||||
name: "Timer",
|
|
||||||
operandType: "Logic Switches",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
50: {
|
|
||||||
name: "Delta (|A| >= B)",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
51: {
|
|
||||||
name: "Approx Equals (A ~ B)",
|
|
||||||
operandType: "Comparison",
|
|
||||||
hasOperand: [true, true],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
52: {
|
|
||||||
name: "LED Pin PWM",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "raw"
|
|
||||||
},
|
|
||||||
53: {
|
|
||||||
name: "Disable GPS Sensor Fix",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [true, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
54: {
|
|
||||||
name: "Mag calibration",
|
|
||||||
operandType: "Set Flight Parameter",
|
|
||||||
hasOperand: [false, false],
|
|
||||||
output: "boolean"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getOperandTypes: function () {
|
|
||||||
return {
|
|
||||||
0: {
|
|
||||||
name: "Value",
|
|
||||||
type: "value",
|
|
||||||
min: -1000000,
|
|
||||||
max: 1000000,
|
|
||||||
step: 1,
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
1: {
|
|
||||||
name: "Get RC Channel",
|
|
||||||
type: "range",
|
|
||||||
range: [1, 16],
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
2: {
|
|
||||||
name: "Flight",
|
|
||||||
type: "dictionary",
|
|
||||||
default: 0,
|
|
||||||
values: {
|
|
||||||
0: "ARM timer [s]",
|
|
||||||
1: "Home distance [m]",
|
|
||||||
2: "Trip distance [m]",
|
|
||||||
3: "RSSI",
|
|
||||||
4: "Vbat [centi-Volt] [1V = 100]",
|
|
||||||
5: "Cell voltage [centi-Volt] [1V = 100]",
|
|
||||||
6: "Current [centi-Amp] [1A = 100]",
|
|
||||||
7: "Current drawn [mAh]",
|
|
||||||
8: "GPS Sats",
|
|
||||||
9: "Ground speed [cm/s]",
|
|
||||||
10: "3D speed [cm/s]",
|
|
||||||
11: "Air speed [cm/s]",
|
|
||||||
12: "Altitude [cm]",
|
|
||||||
13: "Vertical speed [cm/s]",
|
|
||||||
14: "Throttle position [%]",
|
|
||||||
15: "Roll [deg]",
|
|
||||||
16: "Pitch [deg]",
|
|
||||||
17: "Is Armed",
|
|
||||||
18: "Is Autolaunch",
|
|
||||||
19: "Is Controlling Altitude",
|
|
||||||
20: "Is Controlling Position",
|
|
||||||
21: "Is Emergency Landing",
|
|
||||||
22: "Is RTH",
|
|
||||||
23: "Is Landing",
|
|
||||||
24: "Is Failsafe",
|
|
||||||
25: "Stabilized Roll",
|
|
||||||
26: "Stabilized Pitch",
|
|
||||||
27: "Stabilized Yaw",
|
|
||||||
28: "3D home distance [m]",
|
|
||||||
29: "CRSF LQ",
|
|
||||||
30: "CRSF SNR",
|
|
||||||
31: "GPS Valid Fix",
|
|
||||||
32: "Loiter Radius [cm]",
|
|
||||||
33: "Active PIDProfile",
|
|
||||||
34: "Battery cells",
|
|
||||||
35: "AGL status [0/1]",
|
|
||||||
36: "AGL [cm]",
|
|
||||||
37: "Rangefinder [cm]",
|
|
||||||
38: "Active MixerProfile",
|
|
||||||
39: "MixerTransition Active",
|
|
||||||
40: "Yaw [deg]",
|
|
||||||
41: "FW Land State"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
3: {
|
|
||||||
name: "Flight Mode",
|
|
||||||
type: "dictionary",
|
|
||||||
default: 0,
|
|
||||||
values: {
|
|
||||||
0: "Failsafe",
|
|
||||||
1: "Manual",
|
|
||||||
2: "RTH",
|
|
||||||
3: "Position Hold",
|
|
||||||
4: "Cruise",
|
|
||||||
5: "Altitude Hold",
|
|
||||||
6: "Angle",
|
|
||||||
7: "Horizon",
|
|
||||||
8: "Air",
|
|
||||||
9: "USER 1",
|
|
||||||
10: "USER 2",
|
|
||||||
11: "Course Hold",
|
|
||||||
12: "USER 3",
|
|
||||||
13: "USER 4",
|
|
||||||
14: "Acro",
|
|
||||||
15: "Waypoint Mission",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
4: {
|
|
||||||
name: "Logic Condition",
|
|
||||||
type: "range",
|
|
||||||
range: [0, (this.LOGIC_CONDITIONS.getMaxLogicConditionCount()-1)],
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
5: {
|
|
||||||
name: "Get Global Variable",
|
|
||||||
type: "range",
|
|
||||||
range: [0, 7],
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
6: {
|
|
||||||
name: "Programming PID",
|
|
||||||
type: "range",
|
|
||||||
range: [0, 3],
|
|
||||||
default: 0
|
|
||||||
},
|
|
||||||
7: {
|
|
||||||
name: "Waypoints",
|
|
||||||
type: "dictionary",
|
|
||||||
default: 0,
|
|
||||||
values: {
|
|
||||||
0: "Is WP",
|
|
||||||
1: "Current Waypoint Index",
|
|
||||||
2: "Current Waypoint Action",
|
|
||||||
3: "Next Waypoint Action",
|
|
||||||
4: "Distance to next Waypoint [m]",
|
|
||||||
5: "Distance from last Waypoint [m]",
|
|
||||||
6: "Current WP has User Action 1",
|
|
||||||
7: "Current WP has User Action 2",
|
|
||||||
8: "Current WP has User Action 3",
|
|
||||||
9: "Current WP has User Action 4",
|
|
||||||
10: "Next WP has User Action 1",
|
|
||||||
11: "Next WP has User Action 2",
|
|
||||||
12: "Next WP has User Action 3",
|
|
||||||
13: "Next WP has User Action 4",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getBatteryProfileParameters: function () {
|
getBatteryProfileParameters: function () {
|
||||||
return [
|
return [
|
||||||
'bat_cells',
|
'bat_cells',
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
const FC = require('./fc');
|
const FC = require('./fc');
|
||||||
const { GUI } = require('./../js/gui');
|
const { GUI } = require('./../js/gui');
|
||||||
|
const { LOGIC_OPERATORS } = require('./logicConditionOperators');
|
||||||
|
const { OPERAND_TYPES } = require('./logicConditionOperantTypes');
|
||||||
|
|
||||||
let LogicCondition = function (enabled, activatorId, operation, operandAType, operandAValue, operandBType, operandBValue, flags) {
|
let LogicCondition = function (enabled, activatorId, operation, operandAType, operandAValue, operandBType, operandBValue, flags) {
|
||||||
let self = {};
|
let self = {};
|
||||||
|
@ -79,7 +81,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getOperatorMetadata = function () {
|
self.getOperatorMetadata = function () {
|
||||||
return FC.getLogicOperators()[self.getOperation()];
|
return LOGIC_OPERATORS[self.getOperation()];
|
||||||
};
|
};
|
||||||
|
|
||||||
self.hasOperand = function (val) {
|
self.hasOperand = function (val) {
|
||||||
|
@ -103,7 +105,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
let $cT = $(event.currentTarget),
|
let $cT = $(event.currentTarget),
|
||||||
operand = $cT.data("operand"),
|
operand = $cT.data("operand"),
|
||||||
$container = $cT.parent(),
|
$container = $cT.parent(),
|
||||||
operandMetadata = FC.getOperandTypes()[$cT.val()];
|
operandMetadata = OPERAND_TYPES[$cT.val()];
|
||||||
|
|
||||||
if (operand == 0) {
|
if (operand == 0) {
|
||||||
self.setOperandAType($cT.val());
|
self.setOperandAType($cT.val());
|
||||||
|
@ -145,9 +147,9 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
$container.append('<select class="logic_element__operand--type" data-operand="' + operand + '"></select>');
|
$container.append('<select class="logic_element__operand--type" data-operand="' + operand + '"></select>');
|
||||||
let $t = $container.find('.logic_element__operand--type');
|
let $t = $container.find('.logic_element__operand--type');
|
||||||
|
|
||||||
for (let k in FC.getOperandTypes()) {
|
for (let k in OPERAND_TYPES) {
|
||||||
if (FC.getOperandTypes().hasOwnProperty(k)) {
|
if (OPERAND_TYPES.hasOwnProperty(k)) {
|
||||||
let op = FC.getOperandTypes()[k];
|
let op = OPERAND_TYPES[k];
|
||||||
|
|
||||||
if (type == k) {
|
if (type == k) {
|
||||||
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
||||||
|
@ -173,7 +175,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
|
|
||||||
self.renderStatus = function () {
|
self.renderStatus = function () {
|
||||||
let $e = $row.find('.logic_cell__status'),
|
let $e = $row.find('.logic_cell__status'),
|
||||||
displayType = FC.getLogicOperators()[self.getOperation()].output;
|
displayType = LOGIC_OPERATORS[self.getOperation()].output;
|
||||||
|
|
||||||
if (self.getEnabled() && displayType == "boolean") {
|
if (self.getEnabled() && displayType == "boolean") {
|
||||||
$e.html('<div class="logic_cell__active_marker"></div>');
|
$e.html('<div class="logic_cell__active_marker"></div>');
|
||||||
|
@ -189,7 +191,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let displayType = FC.getLogicOperators()[self.getOperation()].output,
|
let displayType = LOGIC_OPERATORS[self.getOperation()].output,
|
||||||
$marker;
|
$marker;
|
||||||
|
|
||||||
if (self.getEnabled() && displayType == "boolean") {
|
if (self.getEnabled() && displayType == "boolean") {
|
||||||
|
@ -261,9 +263,9 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
|
||||||
|
|
||||||
let lcOperators = [];
|
let lcOperators = [];
|
||||||
|
|
||||||
for (let lcID in FC.getLogicOperators()) {
|
for (let lcID in LOGIC_OPERATORS) {
|
||||||
if (FC.getLogicOperators().hasOwnProperty(lcID)) {
|
if (LOGIC_OPERATORS.hasOwnProperty(lcID)) {
|
||||||
let op = FC.getLogicOperators()[lcID];
|
let op = LOGIC_OPERATORS[lcID];
|
||||||
lcOperators[parseInt(lcID, 10)] = {
|
lcOperators[parseInt(lcID, 10)] = {
|
||||||
id: parseInt(lcID, 10),
|
id: parseInt(lcID, 10),
|
||||||
name: op.name,
|
name: op.name,
|
||||||
|
|
131
js/logicConditionOperantTypes.js
Normal file
131
js/logicConditionOperantTypes.js
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const OPERAND_TYPES = {
|
||||||
|
0: {
|
||||||
|
name: "Value",
|
||||||
|
type: "value",
|
||||||
|
min: -1000000,
|
||||||
|
max: 1000000,
|
||||||
|
step: 1,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
name: "Get RC Channel",
|
||||||
|
type: "range",
|
||||||
|
range: [1, 16],
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "Flight",
|
||||||
|
type: "dictionary",
|
||||||
|
default: 0,
|
||||||
|
values: {
|
||||||
|
0: "ARM timer [s]",
|
||||||
|
1: "Home distance [m]",
|
||||||
|
2: "Trip distance [m]",
|
||||||
|
3: "RSSI",
|
||||||
|
4: "Vbat [centi-Volt] [1V = 100]",
|
||||||
|
5: "Cell voltage [centi-Volt] [1V = 100]",
|
||||||
|
6: "Current [centi-Amp] [1A = 100]",
|
||||||
|
7: "Current drawn [mAh]",
|
||||||
|
8: "GPS Sats",
|
||||||
|
9: "Ground speed [cm/s]",
|
||||||
|
10: "3D speed [cm/s]",
|
||||||
|
11: "Air speed [cm/s]",
|
||||||
|
12: "Altitude [cm]",
|
||||||
|
13: "Vertical speed [cm/s]",
|
||||||
|
14: "Throttle position [%]",
|
||||||
|
15: "Roll [deg]",
|
||||||
|
16: "Pitch [deg]",
|
||||||
|
17: "Is Armed",
|
||||||
|
18: "Is Autolaunch",
|
||||||
|
19: "Is Controlling Altitude",
|
||||||
|
20: "Is Controlling Position",
|
||||||
|
21: "Is Emergency Landing",
|
||||||
|
22: "Is RTH",
|
||||||
|
23: "Is Landing",
|
||||||
|
24: "Is Failsafe",
|
||||||
|
25: "Stabilized Roll",
|
||||||
|
26: "Stabilized Pitch",
|
||||||
|
27: "Stabilized Yaw",
|
||||||
|
28: "3D home distance [m]",
|
||||||
|
29: "CRSF LQ",
|
||||||
|
30: "CRSF SNR",
|
||||||
|
31: "GPS Valid Fix",
|
||||||
|
32: "Loiter Radius [cm]",
|
||||||
|
33: "Active PIDProfile",
|
||||||
|
34: "Battery cells",
|
||||||
|
35: "AGL status [0/1]",
|
||||||
|
36: "AGL [cm]",
|
||||||
|
37: "Rangefinder [cm]",
|
||||||
|
38: "Active MixerProfile",
|
||||||
|
39: "MixerTransition Active",
|
||||||
|
40: "Yaw [deg]",
|
||||||
|
41: "FW Land State"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
name: "Flight Mode",
|
||||||
|
type: "dictionary",
|
||||||
|
default: 0,
|
||||||
|
values: {
|
||||||
|
0: "Failsafe",
|
||||||
|
1: "Manual",
|
||||||
|
2: "RTH",
|
||||||
|
3: "Position Hold",
|
||||||
|
4: "Cruise",
|
||||||
|
5: "Altitude Hold",
|
||||||
|
6: "Angle",
|
||||||
|
7: "Horizon",
|
||||||
|
8: "Air",
|
||||||
|
9: "USER 1",
|
||||||
|
10: "USER 2",
|
||||||
|
11: "Course Hold",
|
||||||
|
12: "USER 3",
|
||||||
|
13: "USER 4",
|
||||||
|
14: "Acro",
|
||||||
|
15: "Waypoint Mission",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
name: "Logic Condition",
|
||||||
|
type: "range",
|
||||||
|
range: [0, 63],
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
5: {
|
||||||
|
name: "Get Global Variable",
|
||||||
|
type: "range",
|
||||||
|
range: [0, 7],
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
6: {
|
||||||
|
name: "Programming PID",
|
||||||
|
type: "range",
|
||||||
|
range: [0, 3],
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
7: {
|
||||||
|
name: "Waypoints",
|
||||||
|
type: "dictionary",
|
||||||
|
default: 0,
|
||||||
|
values: {
|
||||||
|
0: "Is WP",
|
||||||
|
1: "Current Waypoint Index",
|
||||||
|
2: "Current Waypoint Action",
|
||||||
|
3: "Next Waypoint Action",
|
||||||
|
4: "Distance to next Waypoint [m]",
|
||||||
|
5: "Distance from last Waypoint [m]",
|
||||||
|
6: "Current WP has User Action 1",
|
||||||
|
7: "Current WP has User Action 2",
|
||||||
|
8: "Current WP has User Action 3",
|
||||||
|
9: "Current WP has User Action 4",
|
||||||
|
10: "Next WP has User Action 1",
|
||||||
|
11: "Next WP has User Action 2",
|
||||||
|
12: "Next WP has User Action 3",
|
||||||
|
13: "Next WP has User Action 4",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { OPERAND_TYPES };
|
331
js/logicConditionOperators.js
Normal file
331
js/logicConditionOperators.js
Normal file
|
@ -0,0 +1,331 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const LOGIC_OPERATORS = {
|
||||||
|
0: {
|
||||||
|
name: "True",
|
||||||
|
operandType: "Active",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
1: {
|
||||||
|
name: "Equal (A = B)",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
name: "Greater Than (A > B)",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
name: "Lower Than (A < B)",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
name: "Low",
|
||||||
|
operandType: "RC Switch Check",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
5: {
|
||||||
|
name: "Mid",
|
||||||
|
operandType: "RC Switch Check",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
6: {
|
||||||
|
name: "High",
|
||||||
|
operandType: "RC Switch Check",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
7: {
|
||||||
|
name: "AND",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
8: {
|
||||||
|
name: "OR",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
9: {
|
||||||
|
name: "XOR",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
10: {
|
||||||
|
name: "NAND",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
11: {
|
||||||
|
name: "NOR",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
12: {
|
||||||
|
name: "NOT",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
13: {
|
||||||
|
name: "Sticky",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
14: {
|
||||||
|
name: "Basic: Add",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
15: {
|
||||||
|
name: "Basic: Subtract",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
16: {
|
||||||
|
name: "Basic: Multiply",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
17: {
|
||||||
|
name: "Basic: Divide",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
40: {
|
||||||
|
name: "Modulo",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
18: {
|
||||||
|
name: "Set GVAR",
|
||||||
|
operandType: "Variables",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "none"
|
||||||
|
},
|
||||||
|
19: {
|
||||||
|
name: "Increase GVAR",
|
||||||
|
operandType: "Variables",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "none"
|
||||||
|
},
|
||||||
|
20: {
|
||||||
|
name: "Decrease GVAR",
|
||||||
|
operandType: "Variables",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "none"
|
||||||
|
},
|
||||||
|
21: {
|
||||||
|
name: "Set IO Port",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "none"
|
||||||
|
},
|
||||||
|
22: {
|
||||||
|
name: "Override Arming Safety",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
23: {
|
||||||
|
name: "Override Throttle Scale",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
29: {
|
||||||
|
name: "Override Throttle",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
24: {
|
||||||
|
name: "Swap Roll & Yaw",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
25: {
|
||||||
|
name: "Set VTx Power Level",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
30: {
|
||||||
|
name: "Set VTx Band",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
31: {
|
||||||
|
name: "Set VTx Channel",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
26: {
|
||||||
|
name: "Invert Roll",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
27: {
|
||||||
|
name: "Invert Pitch",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
28: {
|
||||||
|
name: "Invert Yaw",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
32: {
|
||||||
|
name: "Set OSD Layout",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
33: {
|
||||||
|
name: "Trigonometry: Sine",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
34: {
|
||||||
|
name: "Trigonometry: Cosine",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
35: {
|
||||||
|
name: "Trigonometry: Tangent",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
36: {
|
||||||
|
name: "Map Input",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
37: {
|
||||||
|
name: "Map Output",
|
||||||
|
operandType: "Maths",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
38: {
|
||||||
|
name: "Override RC Channel",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
|
||||||
|
41: {
|
||||||
|
name: "Override Loiter Radius",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
42: {
|
||||||
|
name: "Set Profile",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
43: {
|
||||||
|
name: "Use Lowest Value",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
44: {
|
||||||
|
name: "Use Highest Value",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
45: {
|
||||||
|
name: "Flight Axis Angle Override",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
46: {
|
||||||
|
name: "Flight Axis Rate Override",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
47: {
|
||||||
|
name: "Edge",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
48: {
|
||||||
|
name: "Delay",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
49: {
|
||||||
|
name: "Timer",
|
||||||
|
operandType: "Logic Switches",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
50: {
|
||||||
|
name: "Delta (|A| >= B)",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
51: {
|
||||||
|
name: "Approx Equals (A ~ B)",
|
||||||
|
operandType: "Comparison",
|
||||||
|
hasOperand: [true, true],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
52: {
|
||||||
|
name: "LED Pin PWM",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "raw"
|
||||||
|
},
|
||||||
|
53: {
|
||||||
|
name: "Disable GPS Sensor Fix",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [true, false],
|
||||||
|
output: "boolean"
|
||||||
|
},
|
||||||
|
54: {
|
||||||
|
name: "Mag calibration",
|
||||||
|
operandType: "Set Flight Parameter",
|
||||||
|
hasOperand: [false, false],
|
||||||
|
output: "boolean"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { LOGIC_OPERATORS };
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const FC = require('./fc');
|
const FC = require('./fc');
|
||||||
const { GUI } = require('./gui');
|
const { GUI } = require('./gui');
|
||||||
|
const { OPERAND_TYPES } = require('./logicConditionOperantTypes');
|
||||||
|
|
||||||
let ProgrammingPid = function (enabled, setpointType, setpointValue, measurementType, measurementValue, gainP, gainI, gainD, gainFF) {
|
let ProgrammingPid = function (enabled, setpointType, setpointValue, measurementType, measurementValue, gainP, gainI, gainD, gainFF) {
|
||||||
let self = {};
|
let self = {};
|
||||||
|
@ -159,7 +160,7 @@ let ProgrammingPid = function (enabled, setpointType, setpointValue, measurement
|
||||||
let $cT = $(event.currentTarget),
|
let $cT = $(event.currentTarget),
|
||||||
operand = $cT.data("operand"),
|
operand = $cT.data("operand"),
|
||||||
$container = $cT.parent(),
|
$container = $cT.parent(),
|
||||||
operandMetadata = FC.getOperandTypes()[$cT.val()];
|
operandMetadata = OPERAND_TYPES[$cT.val()];
|
||||||
|
|
||||||
if (operand == 0) {
|
if (operand == 0) {
|
||||||
self.setSetpointType($cT.val());
|
self.setSetpointType($cT.val());
|
||||||
|
@ -189,9 +190,9 @@ let ProgrammingPid = function (enabled, setpointType, setpointValue, measurement
|
||||||
$container.append('<select class="logic_element__operand--type" data-operand="' + operand + '"></select>');
|
$container.append('<select class="logic_element__operand--type" data-operand="' + operand + '"></select>');
|
||||||
let $t = $container.find('.logic_element__operand--type');
|
let $t = $container.find('.logic_element__operand--type');
|
||||||
|
|
||||||
for (let k in FC.getOperandTypes()) {
|
for (let k in OPERAND_TYPES) {
|
||||||
if (FC.getOperandTypes().hasOwnProperty(k)) {
|
if (OPERAND_TYPES.hasOwnProperty(k)) {
|
||||||
let op = FC.getOperandTypes()[k];
|
let op = OPERAND_TYPES[k];
|
||||||
|
|
||||||
if (type == k) {
|
if (type == k) {
|
||||||
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue