Merge branch 'master' of https://github.com/iNavFlight/inav-configurator into Electron
commit
ca13eefa1b
@ -1,16 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="283.46px" height="141.73px" viewBox="0 0 283.46 141.73" enable-background="new 0 0 283.46 141.73" xml:space="preserve">
|
||||
<g>
|
||||
<circle fill="#999999" cx="141.73" cy="100.25" r="5.271"/>
|
||||
<path fill="#999999" d="M160.347,114.468h-37.234c0.025,7.52-4.19,12.583-9.941,16.749h57.114
|
||||
C163.099,126.682,160.447,120.906,160.347,114.468z"/>
|
||||
<path fill="#999999" d="M213.125,6H70.336c-2.261,0-4.104,1.843-4.104,4.104v94.594c0,2.262,1.843,4.104,4.104,4.104h142.789
|
||||
c2.262,0,4.104-1.844,4.104-4.104V10.104C217.228,7.843,215.386,6,213.125,6z M141.73,105.521c-2.912,0-5.271-2.359-5.271-5.271
|
||||
s2.359-5.271,5.271-5.271s5.272,2.359,5.272,5.271S144.642,105.521,141.73,105.521z M208.515,88.036
|
||||
c0,1.99-1.633,3.624-3.623,3.624H78.581c-1.99,0-3.625-1.634-3.625-3.624V17.354c-0.012-1.991,1.622-3.625,3.625-3.625h126.311
|
||||
c2.002,0,3.623,1.634,3.623,3.625V88.036z"/>
|
||||
</g>
|
||||
<svg width="100%" height="100%" viewBox="0 0 142 142" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<use xlink:href="#_Image1" x="3.8" y="3.613" width="135px" height="135px"/>
|
||||
<defs>
|
||||
<image id="_Image1" width="135px" height="135px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIcAAACHCAYAAAA850oKAAAACXBIWXMAAA7EAAAOxAGVKw4bAAALOklEQVR4nO2de4xdVRWHv97yqjwCooWl9QEEiI/yxhZplUd4Ci0FRP8ApIIYBGlNUBIIWEACxKDyFKEx0dKIQcEC1oq8CmjQUFBAtBpAgfADCgam8iq14x/7TDPvOefM3mefc8/+kslkcs9da83c3+x9zl57rT2BRCVI2hDYC5gJ7ANsCUwEOtnXxH7f3wFuBa4zs54oAQMbxHLc7UjaDCeCmdnXNGBSARPTgX2B2f6jy8eEWI67FUkfB84FjsPPP980M/uTBzuFSSOHJyTtApwHHI2bHnwx2aOtQiRxjBNJe+JEMQv/I/GrwAOebeYmiaMkkqYAPwIOD+SiF5hnZq8Hsj8mSRwlkPQZ4GbCDfm9wKlmtjiQ/Vz4nBtbgaQzgLsIL4yFgeznJj2t5ETSxsAPgbkB3dRGGJDEkQtJHwRuAT4V0E2thAFJHGMi6WPAvcA2Ad3UThiQxDEqkiYDfwQ+GtBNLYUB6YZ0RCRNAm6npcKAJI5hkdQBbqRl9xiDSeIYngtwy+ChqL0wIN1zDEHSrsDDhFsgbIQwII0cA8imkxtIwgCSOAZzBrB3INuNEgakaWU9WSLtSWDzAOYbJwxII0d/ziYJYwBp5AAkbQk8D2zq2XRjhQFp5OjjVJIwhtD6kUPSBsAzwBTPpk83s2s926yUNHLAHPwLA+ClADYrJYkDjgpkd04gu5XR6mklW/R6CXhfAPOvAZPN7N0Atiuh7SPHnoQRBriKtv0D2a6EtovjkMD2Q01ZldB2cRwY2P5sSY2dutsujp0D2/8Arka2kbS2biXb6bVtBa7mAA9V4KcUWcH3+bik4/+AXwBnmNkbbR45tqOap7XaPtJmwlgGfBPXAWAz4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tPIdmimMvhrWJAzPTID1/TH+TPPWMnpxpxsuih1IN9InhvNonjAA5idhhGNCtlv8VYpVvL+JKz1YgVtT2B7YA3cMeFXZ2gvMbEFFvlrJBEmHA78u8J77gJPN7OnBL0jaFteLe7af8EbkKjNLPdAD06FYd+A7cW0VhwgDwMxeNLOjgJ/4CG4EbgRS6r0COuTfMd4DnDJW6+aM+bgWzb65HbfFL08MiXHSIX+jtuvzrjya2WvA5aWjGp6UYa2YDvnPYH24oO2i14/GI6QMa+V0yH8WyF8L2i56/UisxK1+9niyl8hJB3eeRx6KNpD10XD2OeDglHqPQwd3UnEedi9ou+j1g+nLsD47TjuJknRwFeZ5ODE7HGdMsmO3TikdFazGNVDxdphdojgdXDP6POwEXJTz2vnAPqUichnWWUWP1k74Z4KkKbi5PQ/rgPOBy4Z7pMx6gJ2Ge4wtU8KwFteL67YS7014pi8r+yiwW4H3PQJcln1/CnfzuTtu5XK/krGkDGvN6BPHCbjD68rwLn66Ec8zsys92El4oi9Nv5jy6xI+hHFhEkb96ACY2TrcQbkxuMrMvh3Jd2IU1m/wMbMluMq2KllMyrDWlsG7v07HdeqpgjvIcUBvIh5DShAkTcZ17Nk5oN9lwJyUSKs3Q/aNmtnLwHTcBxiCK4AjkjDqz2i1sh3gEly9rI/Nx2/gNgQv9GArUQFjVrZJ+iSupqXsvtB3cTe6F5lZ3iRfogbkLnuUNA2YC3yOfB0En8DddC40s6fKhZeISamaWEm7ANNwu8i2BbbEpdiF2zv6gJk94yvIRBz+D3jMN0x55FT1AAAAAElFTkSuQmCC"/>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 4.5 KiB |
@ -0,0 +1,107 @@
|
||||
/*global $*/
|
||||
'use strict';
|
||||
|
||||
const ApproachDirection = Object.freeze({
|
||||
LEFT: 0,
|
||||
RIGHT: 1,
|
||||
})
|
||||
|
||||
let FwApproach = function (number, approachAltAsl = 0, landAltAsl = 0, approachDirection = 0, landHeading1 = 0, landHeading2 = 0, isSeaLevelRef = 0, elevation = 0) {
|
||||
|
||||
var self = {};
|
||||
|
||||
self.getNumber = function () {
|
||||
return number;
|
||||
};
|
||||
|
||||
self.setNumber = function (data) {
|
||||
number = data;
|
||||
};
|
||||
|
||||
self.getApproachAltAsl = function () {
|
||||
return approachAltAsl;
|
||||
}
|
||||
|
||||
self.setApproachAltAsl = function (data) {
|
||||
approachAltAsl = data;
|
||||
}
|
||||
|
||||
self.getLandAltAsl = function () {
|
||||
return landAltAsl;
|
||||
}
|
||||
|
||||
self.setLandAltAsl = function (data) {
|
||||
landAltAsl = data;
|
||||
}
|
||||
|
||||
self.getApproachDirection = function () {
|
||||
return approachDirection;
|
||||
}
|
||||
|
||||
self.setApproachDirection = function (data) {
|
||||
approachDirection = data;
|
||||
}
|
||||
|
||||
self.getLandHeading1 = function () {
|
||||
return landHeading1;
|
||||
}
|
||||
|
||||
self.setLandHeading1 = function (data) {
|
||||
landHeading1 = data;
|
||||
}
|
||||
|
||||
self.getLandHeading2 = function () {
|
||||
return landHeading2;
|
||||
}
|
||||
|
||||
self.setLandHeading2 = function (data) {
|
||||
landHeading2 = data;
|
||||
}
|
||||
|
||||
self.getIsSeaLevelRef = function () {
|
||||
return isSeaLevelRef;
|
||||
}
|
||||
|
||||
self.setIsSeaLevelRef = function (data) {
|
||||
isSeaLevelRef = data;
|
||||
}
|
||||
|
||||
self.getElevation = function() {
|
||||
return elevation;
|
||||
}
|
||||
|
||||
self.setElevation = function (data) {
|
||||
elevation = data;
|
||||
}
|
||||
|
||||
self.cleanup = function () {
|
||||
approachAltAsl = 0;
|
||||
landAltAsl = 0;
|
||||
approachDirection = 0;
|
||||
landHeading1 = 0;
|
||||
landHeading2 = 0;
|
||||
isSeaLevelRef = 0;
|
||||
elevation = 0
|
||||
};
|
||||
|
||||
self.getElevationFromServer = async function (lon, lat, globalSettings) {
|
||||
let elevation = "N/A";
|
||||
if (globalSettings.mapProviderType == 'bing') {
|
||||
let elevationEarthModel = $('#elevationEarthModel').prop("checked") ? "ellipsoid" : "sealevel";
|
||||
|
||||
const response = await fetch('http://dev.virtualearth.net/REST/v1/Elevation/List?points='+lat+','+lon+'&heights='+elevationEarthModel+'&key='+globalSettings.mapApiKey);
|
||||
const myJson = await response.json();
|
||||
elevation = myJson.resourceSets[0].resources[0].elevations[0];
|
||||
}
|
||||
else {
|
||||
const response = await fetch('https://api.opentopodata.org/v1/aster30m?locations='+lat+','+lon);
|
||||
const myJson = await response.json();
|
||||
if (myJson.status == "OK" && myJson.results[0].elevation != null) {
|
||||
elevation = myJson.results[0].elevation;
|
||||
}
|
||||
}
|
||||
return elevation;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
let FwApproachCollection = function () {
|
||||
|
||||
let self = {},
|
||||
data = [],
|
||||
maxFwApproachCount = 17;
|
||||
|
||||
self.setMaxFwApproachCount = function (value) {
|
||||
maxFwApproachCount = value;
|
||||
};
|
||||
|
||||
self.getMaxFwApproachCount = function () {
|
||||
return maxFwApproachCount;
|
||||
}
|
||||
|
||||
self.put = function (element) {
|
||||
element.setNumber(data.length);
|
||||
data.push(element);
|
||||
};
|
||||
|
||||
self.get = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
self.clean = function (index){
|
||||
data[index].cleanup();
|
||||
};
|
||||
|
||||
self.flush = function () {
|
||||
data = [];
|
||||
};
|
||||
|
||||
self.isEmpty = () => {
|
||||
return data.length == 0;
|
||||
};
|
||||
|
||||
self.fwApproachCount = () => {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
self.drop = (idx) => {
|
||||
data.forEach(f => {
|
||||
if (f.getNumber() >= idx) {
|
||||
f.setNumber(f.getNumber() - 1);
|
||||
}
|
||||
});
|
||||
data.splice(idx, 1);
|
||||
}
|
||||
|
||||
self.insert = (fwApprach, idx) => {
|
||||
data.forEach(f => {
|
||||
if (f.getNumber() >= idx) {
|
||||
f.setNumber(f.getNumber() + 1);
|
||||
}
|
||||
});
|
||||
data.splice(idx, 0, fwApprach);
|
||||
}
|
||||
|
||||
self.updateFwApproach = function(newFwApproach) {
|
||||
data[newFwApproach.getNumber()] = newFwApproach;
|
||||
};
|
||||
|
||||
self.extractBuffer = function(fwApproachId) {
|
||||
let buffer = [];
|
||||
let fwApproach = data[fwApproachId];
|
||||
if (fwApproachId < self.fwApproachCount()) {
|
||||
buffer.push(fwApproach.getNumber()); // sbufReadU8(src); // number
|
||||
buffer.push(specificByte(fwApproach.getApproachAltAsl(), 0));
|
||||
buffer.push(specificByte(fwApproach.getApproachAltAsl(), 1));
|
||||
buffer.push(specificByte(fwApproach.getApproachAltAsl(), 2));
|
||||
buffer.push(specificByte(fwApproach.getApproachAltAsl(), 3));
|
||||
buffer.push(specificByte(fwApproach.getLandAltAsl(), 0));
|
||||
buffer.push(specificByte(fwApproach.getLandAltAsl(), 1));
|
||||
buffer.push(specificByte(fwApproach.getLandAltAsl(), 2));
|
||||
buffer.push(specificByte(fwApproach.getLandAltAsl(), 3));
|
||||
buffer.push(fwApproach.getApproachDirection());
|
||||
buffer.push(specificByte(fwApproach.getLandHeading1(), 0));
|
||||
buffer.push(specificByte(fwApproach.getLandHeading1(), 1));
|
||||
buffer.push(specificByte(fwApproach.getLandHeading2(), 0));
|
||||
buffer.push(specificByte(fwApproach.getLandHeading2(), 1));
|
||||
buffer.push(fwApproach.getIsSeaLevelRef());
|
||||
} else {
|
||||
buffer = Array(15).fill(0);
|
||||
buffer[0] = safehomeId;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
@ -0,0 +1,351 @@
|
||||
'use strict';
|
||||
|
||||
var helper = helper || {};
|
||||
|
||||
helper.serialPortHelper = (function () {
|
||||
|
||||
let publicScope = {},
|
||||
privateScope = {};
|
||||
|
||||
privateScope.namesGenerated = false;
|
||||
|
||||
// This is a list of all the rules for the serial ports as well as their names
|
||||
privateScope.rules = [
|
||||
{
|
||||
name: 'MSP',
|
||||
groups: ['data']
|
||||
},
|
||||
{
|
||||
name: 'GPS',
|
||||
groups: ['sensors'],
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_FRSKY',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_HOTT',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_SMARTPORT',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_LTM',
|
||||
groups: ['telemetry']
|
||||
},
|
||||
{
|
||||
name: 'RX_SERIAL',
|
||||
groups: ['rx'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'BLACKBOX',
|
||||
groups: ['peripherals']
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_MAVLINK',
|
||||
groups: ['telemetry'],
|
||||
},
|
||||
{
|
||||
name: 'TELEMETRY_IBUS',
|
||||
groups: ['telemetry'],
|
||||
},
|
||||
{
|
||||
name: 'RANGEFINDER',
|
||||
groups: ['sensors'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'GSM_SMS',
|
||||
groups: ['telemetry'],
|
||||
},
|
||||
{
|
||||
name: 'RUNCAM_DEVICE_CONTROL',
|
||||
groups: ['peripherals'],
|
||||
},
|
||||
{
|
||||
name: 'TBS_SMARTAUDIO',
|
||||
groups: ['peripherals'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'IRC_TRAMP',
|
||||
groups: ['peripherals'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'VTX_FFPV',
|
||||
groups: ['peripherals'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'ESC',
|
||||
groups: ['peripherals'],
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'OPFLOW',
|
||||
groups: ['sensors'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'FRSKY_OSD',
|
||||
groups: ['peripherals'],
|
||||
defaultBaud: 250000,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'DJI_FPV',
|
||||
groups: ['peripherals'],
|
||||
defaultBaud: 115200,
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'MSP_DISPLAYPORT',
|
||||
groups: ['peripherals'],
|
||||
isUnique: true
|
||||
},
|
||||
{
|
||||
name: 'SMARTPORT_MASTER',
|
||||
groups: ['peripherals'],
|
||||
defaultBaud: 57600
|
||||
},
|
||||
{
|
||||
name: 'SBUS_OUTPUT',
|
||||
groups: ['peripherals'],
|
||||
defaultBaud: 115200
|
||||
}
|
||||
];
|
||||
|
||||
// This is a mapping of the function names to their IDs required by the firmware and MSP protocol
|
||||
privateScope.functionIDs = {
|
||||
'MSP': 0,
|
||||
'GPS': 1,
|
||||
'TELEMETRY_FRSKY': 2,
|
||||
'TELEMETRY_HOTT': 3,
|
||||
'TELEMETRY_LTM': 4, // LTM replaced MSP
|
||||
'TELEMETRY_SMARTPORT': 5,
|
||||
'RX_SERIAL': 6,
|
||||
'BLACKBOX': 7,
|
||||
'TELEMETRY_MAVLINK': 8,
|
||||
'TELEMETRY_IBUS': 9,
|
||||
'RUNCAM_DEVICE_CONTROL': 10,
|
||||
'TBS_SMARTAUDIO': 11,
|
||||
'IRC_TRAMP': 12,
|
||||
'OPFLOW': 14,
|
||||
'LOG': 15,
|
||||
'RANGEFINDER': 16,
|
||||
'VTX_FFPV': 17,
|
||||
'ESC': 18,
|
||||
'GSM_SMS': 19,
|
||||
'FRSKY_OSD': 20,
|
||||
'DJI_FPV': 21,
|
||||
'SBUS_OUTPUT': 22,
|
||||
'SMARTPORT_MASTER': 23,
|
||||
'MSP_DISPLAYPORT': 25,
|
||||
};
|
||||
|
||||
privateScope.identifierToName = {
|
||||
0: 'UART1',
|
||||
1: 'UART2',
|
||||
2: 'UART3',
|
||||
3: 'UART4',
|
||||
4: 'UART5',
|
||||
5: 'UART6',
|
||||
6: 'UART7',
|
||||
7: 'UART8',
|
||||
20: 'USB VCP',
|
||||
30: 'SOFTSERIAL1',
|
||||
31: 'SOFTSERIAL2'
|
||||
};
|
||||
|
||||
privateScope.bauds = {
|
||||
'SENSOR': [
|
||||
'9600',
|
||||
'19200',
|
||||
'38400',
|
||||
'57600',
|
||||
'115200',
|
||||
'230400'
|
||||
],
|
||||
'MSP': [
|
||||
'2400',
|
||||
'4800',
|
||||
'9600',
|
||||
'19200',
|
||||
'38400',
|
||||
'57600',
|
||||
'115200'
|
||||
],
|
||||
'TELEMETRY': [
|
||||
'AUTO',
|
||||
'1200',
|
||||
'2400',
|
||||
'4800',
|
||||
'9600',
|
||||
'19200',
|
||||
'38400',
|
||||
'57600',
|
||||
'115200'
|
||||
],
|
||||
'PERIPHERAL': [
|
||||
'19200',
|
||||
'38400',
|
||||
'57600',
|
||||
'115200',
|
||||
'230400',
|
||||
'250000'
|
||||
]
|
||||
};
|
||||
|
||||
privateScope.generateNames = function () {
|
||||
if (privateScope.namesGenerated) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < privateScope.rules.length; i++) {
|
||||
privateScope.rules[i].displayName = chrome.i18n.getMessage('portsFunction_' + privateScope.rules[i].name);
|
||||
}
|
||||
|
||||
privateScope.namesGenerated = true;
|
||||
};
|
||||
|
||||
publicScope.getRules = function () {
|
||||
privateScope.generateNames();
|
||||
|
||||
return privateScope.rules;
|
||||
};
|
||||
|
||||
publicScope.getRuleByName = function (name) {
|
||||
for (var i = 0; i < privateScope.rules.length; i++) {
|
||||
if (privateScope.rules[i].name === name) {
|
||||
return privateScope.rules[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {array} functions
|
||||
* @returns {number}
|
||||
*/
|
||||
publicScope.functionsToMask = function (functions) {
|
||||
let mask = 0;
|
||||
for (let index = 0; index < functions.length; index++) {
|
||||
let key = functions[index];
|
||||
let bitIndex = privateScope.functionIDs[key];
|
||||
if (bitIndex >= 0) {
|
||||
mask = bit_set(mask, bitIndex);
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} mask
|
||||
* @returns {array}
|
||||
*/
|
||||
publicScope.maskToFunctions = function (mask) {
|
||||
let functions = [];
|
||||
|
||||
let keys = Object.keys(privateScope.functionIDs);
|
||||
for (let index = 0; index < keys.length; index++) {
|
||||
let key = keys[index];
|
||||
let bit = privateScope.functionIDs[key];
|
||||
if (bit_check(mask, bit)) {
|
||||
functions.push(key);
|
||||
}
|
||||
}
|
||||
return functions;
|
||||
};
|
||||
|
||||
publicScope.getPortName = function (identifier) {
|
||||
return privateScope.identifierToName[identifier];
|
||||
};
|
||||
|
||||
publicScope.getPortIdentifiersForFunction = function (functionName) {
|
||||
let identifiers = [];
|
||||
|
||||
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||
let config = SERIAL_CONFIG.ports[index];
|
||||
if (config.functions.indexOf(functionName) != -1) {
|
||||
identifiers.push(config.identifier);
|
||||
}
|
||||
}
|
||||
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
publicScope.getPortList = function () {
|
||||
|
||||
let list = [];
|
||||
|
||||
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||
let config = SERIAL_CONFIG.ports[index];
|
||||
|
||||
//exclude USB VCP port
|
||||
if (config.identifier == 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let port = {
|
||||
identifier: config.identifier,
|
||||
displayName: privateScope.identifierToName[config.identifier]
|
||||
};
|
||||
list.push(port);
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
publicScope.getBauds = function (functionName) {
|
||||
return privateScope.bauds[functionName];
|
||||
};
|
||||
|
||||
publicScope.getPortByIdentifier = function (identifier) {
|
||||
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||
let config = SERIAL_CONFIG.ports[index];
|
||||
if (config.identifier == identifier) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
publicScope.clearByFunction = function (functionName) {
|
||||
for (let index = 0; index < SERIAL_CONFIG.ports.length; index++) {
|
||||
let config = SERIAL_CONFIG.ports[index];
|
||||
if (config.functions.indexOf(functionName) != -1) {
|
||||
config.functions = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
publicScope.set = function(port, functionName, baudrate) {
|
||||
|
||||
publicScope.clearByFunction(functionName);
|
||||
|
||||
let config = publicScope.getPortByIdentifier(port);
|
||||
if (config) {
|
||||
|
||||
config.functions = [functionName];
|
||||
|
||||
//set baudrate
|
||||
//TODO add next entries as we progress
|
||||
if (functionName == 'MSP') {
|
||||
config.msp_baudrate = baudrate;
|
||||
} else if (functionName == 'GPS') {
|
||||
config.sensors_baudrate = baudrate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return publicScope;
|
||||
})();
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue