@ -1,5 +0,0 @@
|
|||||||
<span>1.0.2</span>
|
|
||||||
<ul>
|
|
||||||
<li>PID scaling in Configurator removed</li>
|
|
||||||
<li>Improved anonymous tracking</li>
|
|
||||||
</ul>
|
|
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,279 @@
|
|||||||
|
/*global mspHelper,$,GUI,MSP,BF_CONFIG,chrome*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var helper = helper || {};
|
||||||
|
|
||||||
|
helper.defaultsDialog = (function() {
|
||||||
|
|
||||||
|
let publicScope = {},
|
||||||
|
privateScope = {};
|
||||||
|
|
||||||
|
let $container;
|
||||||
|
|
||||||
|
let data = [{
|
||||||
|
"title": 'Mini Quad with 3"-7" propellers',
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "gyro_hardware_lpf",
|
||||||
|
value: "256HZ"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "looptime",
|
||||||
|
value: 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_lpf_hz",
|
||||||
|
value: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_lpf_type",
|
||||||
|
value: "PT1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "gyro_stage2_lowpass_hz",
|
||||||
|
value: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "dterm_lpf_hz",
|
||||||
|
value: 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "use_dterm_fir_filter",
|
||||||
|
value: "OFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_iterm_relax_type",
|
||||||
|
value: "SETPOINT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_iterm_relax",
|
||||||
|
value: "RP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "d_boost_factor",
|
||||||
|
value: 1.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "antigravity_gain",
|
||||||
|
value: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "antigravity_accelerator",
|
||||||
|
value: 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_yaw_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "roll_rate",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "pitch_rate",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "yaw_rate",
|
||||||
|
value: 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_pitch",
|
||||||
|
value: 44
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_pitch",
|
||||||
|
value: 60
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_d_pitch",
|
||||||
|
value: 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_roll",
|
||||||
|
value: 40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_roll",
|
||||||
|
value: 50
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_d_roll",
|
||||||
|
value: 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_p_yaw",
|
||||||
|
value: 45
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_i_yaw",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "mc_airmode_type",
|
||||||
|
value: "THROTTLE_THRESHOLD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
bit: 5, // Enable DYNAMIC_FILTERS
|
||||||
|
state: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": 'Airplane',
|
||||||
|
"id": 3,
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "rc_yaw_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "rc_expo",
|
||||||
|
value: 70
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "roll_rate",
|
||||||
|
value: 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "pitch_rate",
|
||||||
|
value: 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "yaw_rate",
|
||||||
|
value: 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "small_angle",
|
||||||
|
value: 180
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
bit: 4, // Enable MOTOR_STOP
|
||||||
|
state: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": 'Custom UAV - INAV legacy defaults',
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": 'Keep current settings',
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
key: "applied_defaults",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
publicScope.init = function() {
|
||||||
|
mspHelper.getSetting("applied_defaults").then(privateScope.onInitSettingReturned);
|
||||||
|
$container = $("#defaults-wrapper");
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.setFeaturesBits = function (selectedDefaultPreset) {
|
||||||
|
|
||||||
|
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
|
||||||
|
helper.features.reset();
|
||||||
|
|
||||||
|
for (const feature of selectedDefaultPreset.features) {
|
||||||
|
if (feature.state) {
|
||||||
|
helper.features.set(feature.bit);
|
||||||
|
} else {
|
||||||
|
helper.features.unset(feature.bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.features.execute(function () {
|
||||||
|
privateScope.setSettings(selectedDefaultPreset);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
privateScope.setSettings(selectedDefaultPreset);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.setSettings = function (selectedDefaultPreset) {
|
||||||
|
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||||
|
return mspHelper.getSetting(input.key);
|
||||||
|
}).then(function () {
|
||||||
|
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||||
|
return mspHelper.setSetting(input.key, input.value);
|
||||||
|
}).then(function () {
|
||||||
|
mspHelper.saveToEeprom(function () {
|
||||||
|
//noinspection JSUnresolvedVariable
|
||||||
|
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
|
GUI.tab_switch_cleanup(function() {
|
||||||
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
|
||||||
|
//noinspection JSUnresolvedVariable
|
||||||
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||||
|
GUI.handleReconnect();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.onPresetClick = function(event) {
|
||||||
|
$container.hide();
|
||||||
|
let selectedDefaultPreset = data[$(event.currentTarget).data("index")];
|
||||||
|
if (selectedDefaultPreset && selectedDefaultPreset.settings) {
|
||||||
|
|
||||||
|
mspHelper.loadBfConfig(function () {
|
||||||
|
privateScope.setFeaturesBits(selectedDefaultPreset)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.render = function() {
|
||||||
|
let $place = $container.find('.defaults-dialog__options');
|
||||||
|
$place.html("");
|
||||||
|
for (let i in data) {
|
||||||
|
if (data.hasOwnProperty(i)) {
|
||||||
|
let preset = data[i];
|
||||||
|
let $element = $("<div class='default_btn defaults_btn'>\
|
||||||
|
<a class='confirm' href='#'></a>\
|
||||||
|
</div>")
|
||||||
|
|
||||||
|
$element.find("a").html(preset.title);
|
||||||
|
$element.data("index", i).click(privateScope.onPresetClick)
|
||||||
|
$element.appendTo($place);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
privateScope.onInitSettingReturned = function(promise) {
|
||||||
|
if (promise.value > 0) {
|
||||||
|
return; //Defaults were applied, we can just ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
privateScope.render();
|
||||||
|
$container.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return publicScope;
|
||||||
|
})();
|
@ -0,0 +1,87 @@
|
|||||||
|
/*global mspHelper,BF_CONFIG*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var helper = helper || {};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Helper to work with FEATURES via MSP
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
1. Reset everything
|
||||||
|
helper.features.reset();
|
||||||
|
|
||||||
|
2. Push feature bits you want to set
|
||||||
|
helper.features.set(5);
|
||||||
|
|
||||||
|
3. Push feature bits you want to unset
|
||||||
|
helper.features.set(8);
|
||||||
|
|
||||||
|
4. Execute and provide a callback that will be executed after MSP is done
|
||||||
|
helper.features.execute(function () {
|
||||||
|
//Do things crap over here
|
||||||
|
});
|
||||||
|
|
||||||
|
*/
|
||||||
|
helper.features = (function() {
|
||||||
|
|
||||||
|
let publicScope = {},
|
||||||
|
privateScope = {};
|
||||||
|
|
||||||
|
let toSet = [],
|
||||||
|
toUnset = [],
|
||||||
|
exitPoint;
|
||||||
|
|
||||||
|
publicScope.reset = function () {
|
||||||
|
toSet = [];
|
||||||
|
toUnset = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.set = function (bit) {
|
||||||
|
toSet.push(bit);
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.unset = function (bit) {
|
||||||
|
toUnset.push(bit);
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.updateUI = function ($container, values) {
|
||||||
|
$container.find('[data-bit].feature').each(function () {
|
||||||
|
let $this = $(this);
|
||||||
|
$this.prop('checked', bit_check(values, $this.attr("data-bit")));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.fromUI = function ($container) {
|
||||||
|
|
||||||
|
$container.find('[data-bit].feature').each(function () {
|
||||||
|
let $this = $(this);
|
||||||
|
if ($this.is(":checked")) {
|
||||||
|
publicScope.set($this.attr("data-bit"));
|
||||||
|
} else {
|
||||||
|
publicScope.unset($this.attr("data-bit"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
publicScope.execute = function(callback) {
|
||||||
|
exitPoint = callback;
|
||||||
|
mspHelper.loadBfConfig(privateScope.setBits);
|
||||||
|
};
|
||||||
|
|
||||||
|
privateScope.setBits = function () {
|
||||||
|
|
||||||
|
for (const bit of toSet) {
|
||||||
|
BF_CONFIG.features = bit_set(BF_CONFIG.features, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const bit of toUnset) {
|
||||||
|
BF_CONFIG.features = bit_clear(BF_CONFIG.features, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
mspHelper.saveBfConfig(exitPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
return publicScope;
|
||||||
|
})();
|
@ -0,0 +1,125 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var nwdialog = {
|
||||||
|
|
||||||
|
_context: (typeof global === 'undefined' || typeof global.DOMDocument === 'undefined') ? document : global.DOMDocument,
|
||||||
|
|
||||||
|
setContext: function(context) {
|
||||||
|
this._context = context;
|
||||||
|
},
|
||||||
|
|
||||||
|
openFileDialog: function(filter, multiple, workdir, callback) {
|
||||||
|
|
||||||
|
var fn = callback;
|
||||||
|
var node = this._context.createElement('input');
|
||||||
|
node.type = 'file';
|
||||||
|
node.id = 'open-file-dialog';
|
||||||
|
node.style = 'display: none';
|
||||||
|
|
||||||
|
if (typeof filter === 'function') {
|
||||||
|
fn = filter;
|
||||||
|
} else if (typeof filter === 'string') {
|
||||||
|
node.setAttribute('accept', filter);
|
||||||
|
} else if (typeof filter === 'boolean' && filter === true) {
|
||||||
|
node.setAttribute('multiple', '');
|
||||||
|
} else if (this.isArray(filter)) {
|
||||||
|
node.setAttribute('accept', filter.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof multiple === 'function') {
|
||||||
|
fn = multiple;
|
||||||
|
} else if (typeof multiple === 'string') {
|
||||||
|
node.setAttribute('nwworkingdir', multiple);
|
||||||
|
} else if (typeof multiple === 'boolean' && multiple === true) {
|
||||||
|
node.setAttribute('multiple', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof workdir === 'function') {
|
||||||
|
fn = workdir;
|
||||||
|
} else if (typeof workdir === 'string') {
|
||||||
|
node.setAttribute('nwworkingdir', workdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._context.body.appendChild(node);
|
||||||
|
node.addEventListener('change', function(e) {
|
||||||
|
fn(node.value);
|
||||||
|
node.remove();
|
||||||
|
});
|
||||||
|
node.click();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
saveFileDialog: function(name, accept, directory, callback) {
|
||||||
|
|
||||||
|
var fn = callback;
|
||||||
|
var node = this._context.createElement('input');
|
||||||
|
node.type = 'file';
|
||||||
|
node.id = 'save-file-dialog';
|
||||||
|
node.style = 'display: none';
|
||||||
|
node.setAttribute('nwsaveas', '');
|
||||||
|
|
||||||
|
if (typeof name === 'function') {
|
||||||
|
fn = name;
|
||||||
|
} else if (typeof name === 'string') {
|
||||||
|
node.setAttribute('nwsaveas', name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof accept === 'function') {
|
||||||
|
fn = accept;
|
||||||
|
} else if (typeof accept === 'string') {
|
||||||
|
node.setAttribute('accept', accept);
|
||||||
|
} else if (this.isArray(accept)) {
|
||||||
|
node.setAttribute('accept', accept.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof directory === 'function') {
|
||||||
|
fn = directory;
|
||||||
|
} else if (typeof directory === 'string') {
|
||||||
|
node.setAttribute('nwworkingdir', directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._context.body.appendChild(node);
|
||||||
|
node.addEventListener('change', function() {
|
||||||
|
fn(node.value);
|
||||||
|
node.remove();
|
||||||
|
});
|
||||||
|
node.click();
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
folderBrowserDialog: function(workdir, callback) {
|
||||||
|
var fn = callback;
|
||||||
|
var node = this._context.createElement('input');
|
||||||
|
node.type = 'file';
|
||||||
|
node.id = 'folder-browser-dialog';
|
||||||
|
node.style = 'display: none';
|
||||||
|
node.nwdirectory= true;
|
||||||
|
|
||||||
|
if (typeof workdir === 'function') {
|
||||||
|
fn = workdir
|
||||||
|
} else if (typeof workdir === 'string') {
|
||||||
|
node.setAttribute('nwworkingdir', workdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._context.body.appendChild(node);
|
||||||
|
node.addEventListener('change', function() {
|
||||||
|
fn(node.value);
|
||||||
|
node.remove();
|
||||||
|
});
|
||||||
|
node.click();
|
||||||
|
},
|
||||||
|
|
||||||
|
isArray: function(value) {
|
||||||
|
return Object.prototype.toString.call(value) === '[object Array]';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof nw !== 'undefined') {
|
||||||
|
if (typeof exports == 'undefined') {
|
||||||
|
nw.Dialog = nwdialog;
|
||||||
|
window.dialog = nwdialog;
|
||||||
|
} else {
|
||||||
|
module.exports = nwdialog;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,253 @@
|
|||||||
|
/*global $,FC*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
let LogicCondition = function (enabled, operation, operandAType, operandAValue, operandBType, operandBValue, flags) {
|
||||||
|
let self = {};
|
||||||
|
let $row;
|
||||||
|
|
||||||
|
self.getEnabled = function () {
|
||||||
|
return !!enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setEnabled = function (data) {
|
||||||
|
enabled = !!data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperation = function () {
|
||||||
|
return operation;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOperation = function (data) {
|
||||||
|
operation = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperandAType = function () {
|
||||||
|
return operandAType;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOperandAType = function (data) {
|
||||||
|
operandAType = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperandAValue = function () {
|
||||||
|
return operandAValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOperandAValue = function (data) {
|
||||||
|
operandAValue = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperandBType = function () {
|
||||||
|
return operandBType;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOperandBType = function (data) {
|
||||||
|
operandBType = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperandBValue = function () {
|
||||||
|
return operandBValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setOperandBValue = function (data) {
|
||||||
|
operandBValue = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getFlags = function () {
|
||||||
|
return flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setFlags = function (data) {
|
||||||
|
flags = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onEnabledChange = function (event) {
|
||||||
|
let $cT = $(event.currentTarget);
|
||||||
|
self.setEnabled(!!$cT.prop('checked'));
|
||||||
|
};
|
||||||
|
|
||||||
|
self.getOperatorMetadata = function () {
|
||||||
|
return FC.getLogicOperators()[self.getOperation()];
|
||||||
|
};
|
||||||
|
|
||||||
|
self.hasOperand = function (val) {
|
||||||
|
return self.getOperatorMetadata().hasOperand[val];
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onOperatorChange = function (event) {
|
||||||
|
let $cT = $(event.currentTarget);
|
||||||
|
|
||||||
|
self.setOperation($cT.val());
|
||||||
|
self.setOperandAType(0);
|
||||||
|
self.setOperandBType(0);
|
||||||
|
self.setOperandAValue(0);
|
||||||
|
self.setOperandBValue(0);
|
||||||
|
self.renderOperand(0);
|
||||||
|
self.renderOperand(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onOperatorTypeChange = function (event) {
|
||||||
|
let $cT = $(event.currentTarget),
|
||||||
|
operand = $cT.data("operand"),
|
||||||
|
$container = $cT.parent(),
|
||||||
|
operandMetadata = FC.getOperandTypes()[$cT.val()];
|
||||||
|
|
||||||
|
if (operand == 0) {
|
||||||
|
self.setOperandAType($cT.val());
|
||||||
|
self.setOperandAValue(operandMetadata.default);
|
||||||
|
} else {
|
||||||
|
self.setOperandBType($cT.val());
|
||||||
|
self.setOperandBValue(operandMetadata.default);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.renderOperandValue($container, operandMetadata, operand, operandMetadata.default);
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onOperatorValueChange = function (event) {
|
||||||
|
let $cT = $(event.currentTarget),
|
||||||
|
operand = $cT.data("operand");
|
||||||
|
|
||||||
|
if (operand == 0) {
|
||||||
|
self.setOperandAValue($cT.val());
|
||||||
|
} else {
|
||||||
|
self.setOperandBValue($cT.val());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.renderOperandValue = function ($container, operandMetadata, operand, value) {
|
||||||
|
|
||||||
|
$container.find('.logic_element__operand--value').remove();
|
||||||
|
|
||||||
|
switch (operandMetadata.type) {
|
||||||
|
case "value":
|
||||||
|
$container.append('<input type="number" class="logic_element__operand--value" data-operand="' + operand + '" step="' + operandMetadata.step + '" min="' + operandMetadata.min + '" max="' + operandMetadata.max + '" value="' + value + '" />');
|
||||||
|
break;
|
||||||
|
case "range":
|
||||||
|
case "dictionary":
|
||||||
|
$container.append('<select class="logic_element__operand--value" data-operand="' + operand + '"></select>');
|
||||||
|
let $t = $container.find('.logic_element__operand--value');
|
||||||
|
|
||||||
|
if (operandMetadata.type == "range") {
|
||||||
|
for (let i = operandMetadata.range[0]; i <= operandMetadata.range[1]; i++) {
|
||||||
|
$t.append('<option value="' + i + '">' + i + '</option>');
|
||||||
|
}
|
||||||
|
} else if (operandMetadata.type == "dictionary") {
|
||||||
|
for (let k in operandMetadata.values) {
|
||||||
|
if (operandMetadata.values.hasOwnProperty(k)) {
|
||||||
|
$t.append('<option value="' + k + '">' + operandMetadata.values[k] + '</option>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$t.val(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container.find('.logic_element__operand--value').change(self.onOperatorValueChange);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
self.renderOperand = function (operand) {
|
||||||
|
let type, value, $container;
|
||||||
|
if (operand == 0) {
|
||||||
|
type = operandAType;
|
||||||
|
value = operandAValue;
|
||||||
|
$container = $row.find('.logic_cell__operandA');
|
||||||
|
} else {
|
||||||
|
type = operandBType;
|
||||||
|
value = operandBValue;
|
||||||
|
$container = $row.find('.logic_cell__operandB');
|
||||||
|
}
|
||||||
|
|
||||||
|
$container.html('');
|
||||||
|
if (self.hasOperand(operand)) {
|
||||||
|
|
||||||
|
$container.append('<select class="logic_element__operand--type" data-operand="' + operand + '"></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 (type == k) {
|
||||||
|
$t.append('<option value="' + k + '" selected>' + op.name + '</option>');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Render value element depending on type
|
||||||
|
*/
|
||||||
|
self.renderOperandValue($container, op, operand, value);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$t.append('<option value="' + k + '">' + op.name + '</option>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind events
|
||||||
|
*/
|
||||||
|
$t.change(self.onOperatorTypeChange);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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>\
|
||||||
|
<td class="logic_cell__index"></td>\
|
||||||
|
<td class="logic_cell__enabled"></td>\
|
||||||
|
<td class="logic_cell__operation"></td>\
|
||||||
|
<td class="logic_cell__operandA"></td>\
|
||||||
|
<td class="logic_cell__operandB"></td>\
|
||||||
|
<td class="logic_cell__flags"><div class="logic_cell__active_marker"></div></td>\
|
||||||
|
</tr>\
|
||||||
|
');
|
||||||
|
|
||||||
|
$row = $container.find('tr:last');
|
||||||
|
|
||||||
|
$row.find('.logic_cell__index').html(index);
|
||||||
|
$row.find('.logic_cell__enabled').html("<input type='checkbox' class='toggle logic_element__enabled' />");
|
||||||
|
$row.find('.logic_element__enabled').
|
||||||
|
prop('checked', self.getEnabled()).
|
||||||
|
change(self.onEnabledChange);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Operator select
|
||||||
|
*/
|
||||||
|
$row.find('.logic_cell__operation').html("<select class='logic_element__operation' ></select>");
|
||||||
|
let $t = $row.find('.logic_element__operation');
|
||||||
|
|
||||||
|
for (let k in FC.getLogicOperators()) {
|
||||||
|
if (FC.getLogicOperators().hasOwnProperty(k)) {
|
||||||
|
let o = FC.getLogicOperators()[k];
|
||||||
|
if (self.getOperation() == parseInt(k, 10)) {
|
||||||
|
$t.append('<option value="' + k + '" selected>' + o.name + '</option>');
|
||||||
|
} else {
|
||||||
|
$t.append('<option value="' + k + '">' + o.name + '</option>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$t.change(self.onOperatorChange);
|
||||||
|
|
||||||
|
self.renderOperand(0);
|
||||||
|
self.renderOperand(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
@ -0,0 +1,87 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
let LogicConditionsCollection = 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.open = function () {
|
||||||
|
|
||||||
|
if (semver.lt(CONFIG.flightControllerVersion, "2.2.0")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.render();
|
||||||
|
$container.show();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.render = function () {
|
||||||
|
let $table = $container.find(".logic__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();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onSave = function () {
|
||||||
|
let chain = new MSPChainerClass()
|
||||||
|
|
||||||
|
chain.setChain([
|
||||||
|
mspHelper.sendLogicConditions,
|
||||||
|
mspHelper.saveToEeprom
|
||||||
|
]);
|
||||||
|
|
||||||
|
chain.execute();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.onClose = function() {
|
||||||
|
$container.hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.init = function ($element) {
|
||||||
|
|
||||||
|
if (semver.lt(CONFIG.flightControllerVersion, "2.2.0")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = $element;
|
||||||
|
|
||||||
|
$container.find('.logic__save').click(self.onSave);
|
||||||
|
$container.find('.logic__close').click(self.onClose);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
@ -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;
|
||||||
|
};
|
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var helper = helper || {};
|
||||||
|
|
||||||
|
helper.tabs = (function () {
|
||||||
|
let self = {},
|
||||||
|
$container;
|
||||||
|
|
||||||
|
function onHeaderClick(event) {
|
||||||
|
let $cT = $(event.currentTarget),
|
||||||
|
attrFor = $cT.attr("for");
|
||||||
|
|
||||||
|
$container.find('.subtab__header_label').removeClass("subtab__header_label--current");
|
||||||
|
$cT.addClass("subtab__header_label--current");
|
||||||
|
$container.find(".subtab__content--current").removeClass("subtab__content--current");
|
||||||
|
$container.find("#" + attrFor).addClass("subtab__content--current");
|
||||||
|
};
|
||||||
|
|
||||||
|
self.init = function ($dom) {
|
||||||
|
$container = $dom;
|
||||||
|
|
||||||
|
$container.find(".subtab__header_label").click(onHeaderClick);
|
||||||
|
};
|
||||||
|
|
||||||
|
return self;
|
||||||
|
|
||||||
|
})();
|
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 240 B |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 219 B |
After Width: | Height: | Size: 208 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 236 B |
After Width: | Height: | Size: 236 B |
After Width: | Height: | Size: 253 B |
After Width: | Height: | Size: 247 B |
After Width: | Height: | Size: 214 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 253 B |
After Width: | Height: | Size: 253 B |
After Width: | Height: | Size: 261 B |
After Width: | Height: | Size: 258 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 184 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 208 B |
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 277 B |
After Width: | Height: | Size: 272 B |
After Width: | Height: | Size: 271 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 194 B |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 192 B |
After Width: | Height: | Size: 213 B |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 192 B |
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 221 B |
After Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 201 B |