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

add runcam split suport

add peripherals column on ports page

fixed ports page will show the rcsplit with apiversion less 1.27.0

move the modeName adjust function to peripherals.js, and add failsafe modename not update when rcsplit available

cleanup

clean up
This commit is contained in:
azol 2017-08-04 18:36:40 +08:00 committed by azolyoung
parent e394d4fd86
commit 73f324e4c1
9 changed files with 152 additions and 13 deletions

View file

@ -783,6 +783,9 @@
"portsFunction_BLACKBOX": {
"message": "Blackbox"
},
"portsFunction_RUNCAM_SPLIT_CONTROL": {
"message": "RunCam Split"
},
"pidTuningName": {
"message": "Name"
},

76
build/script.js Executable file → Normal file
View file

@ -7594,7 +7594,8 @@ var mspHelper = (function (gui) {
'RX_SERIAL': 6,
'BLACKBOX': 7,
'TELEMETRY_MAVLINK': 8,
'TELEMETRY_IBUS': 9
'TELEMETRY_IBUS': 9,
'RUNCAM_SPLIT_CONTROL' : 10,
};
/**
@ -14594,8 +14595,16 @@ TABS.auxiliary.initialize = function (callback) {
}
function get_rc_data() {
if (SERIAL_CONFIG.ports.length == 0) {
MSP.send_message(MSPCodes.MSP_RC, false, false, get_serial_config);
} else {
MSP.send_message(MSPCodes.MSP_RC, false, false, load_html);
}
}
function get_serial_config() {
MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/auxiliary.html", process_html);
@ -14606,8 +14615,10 @@ TABS.auxiliary.initialize = function (callback) {
function createMode(modeIndex, modeId) {
var modeTemplate = $('#tab-auxiliary-templates .mode');
var newMode = modeTemplate.clone();
var modeName = AUX_CONFIG[modeIndex];
// if user choose the runcam split at peripheral column, then adjust the boxname(BOXCAMERA1, BOXCAMERA2, BOXCAMERA3)
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
$(newMode).attr('id', 'mode-' + modeIndex);
$(newMode).find('.name').text(modeName);
@ -15858,7 +15869,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
continue; // invalid!
}
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + AUX_CONFIG[modeIndex] + "</span>";
var modeName = AUX_CONFIG[modeIndex];
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + modeName + "</span>";
}
}
@ -20722,6 +20735,7 @@ TABS.ports = {};
TABS.ports.initialize = function (callback, scrollPosition) {
var board_definition = {};
var isSupportPeripherals = semver.gte(CONFIG.apiVersion, "1.27.0");
var functionRules = [
{name: 'MSP', groups: ['data', 'msp'], maxPorts: 2},
@ -20752,6 +20766,12 @@ TABS.ports.initialize = function (callback, scrollPosition) {
});
}
// support configure RunCam Split
GUI.log('API version is ' + CONFIG.apiVersion);
if (isSupportPeripherals) {
functionRules.push({ name: 'RUNCAM_SPLIT_CONTROL', groups: ['peripherals'], maxPorts: 1 });
}
for (var i = 0; i < functionRules.length; i++) {
functionRules[i].displayName = chrome.i18n.getMessage('portsFunction_' + functionRules[i].name);
}
@ -20802,7 +20822,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
'250000'
];
var columns = ['data', 'logging', 'gps', 'telemetry', 'rx'];
var columns = ['data', 'logging', 'gps', 'telemetry', 'rx', 'peripherals'];
if (GUI.active_tab != 'ports') {
GUI.active_tab = 'ports';
@ -20839,6 +20859,12 @@ TABS.ports.initialize = function (callback, scrollPosition) {
31: 'SOFTSERIAL2'
};
// if apiVersion < 1.27.0, than remove the peripherals column
if (!isSupportPeripherals) {
$('.peripherls-column').remove();
$('.functionsCell-peripherals').remove();
}
var gps_baudrate_e = $('select.gps_baudrate');
for (var i = 0; i < gpsBaudRates.length; i++) {
gps_baudrate_e.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
@ -20901,7 +20927,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
}
var select_e;
if (column != 'telemetry') {
if (column !== 'telemetry' && column !== 'peripherals') {
var checkboxId = 'functionCheckbox-' + portIndex + '-' + columnIndex + '-' + i;
functions_e.prepend('<span class="function"><input type="checkbox" class="togglemedium" id="' + checkboxId + '" value="' + functionName + '" /><label for="' + checkboxId + '"> ' + functionRule.displayName + '</label></span>');
@ -20966,6 +20992,13 @@ TABS.ports.initialize = function (callback, scrollPosition) {
functions.push(telemetryFunction);
}
if (isSupportPeripherals) {
var peripheralFunction = $(portConfiguration_e).find('select[name=function-peripherals]').val();
if (peripheralFunction) {
functions.push(peripheralFunction);
}
}
if (telemetryFunction.length > 0) {
googleAnalytics.sendEvent('Setting', 'Telemetry Protocol', telemetryFunction);
}
@ -23932,3 +23965,36 @@ helper.mspBalancedInterval = (function (mspQueue, intervalHandler) {
return publicScope;
})(helper.mspQueue, helper.interval);
'use strict';
// return true if user has choose a special peripheral
function isPeripheralSelected(peripheralName) {
for (var portIndex = 0; portIndex < SERIAL_CONFIG.ports.length; portIndex++) {
var serialPort = SERIAL_CONFIG.ports[portIndex];
if (serialPort.functions.indexOf(peripheralName) >= 0) {
return true;
}
}
return false;
}
// Adjust the real name for a modeId. Useful if it belongs to a peripheral
function adjustBoxNameIfPeripheralWithModeID(modeId, defaultName) {
if (isPeripheralSelected("RUNCAM_SPLIT_CONTROL")) {
switch (modeId) {
case 39: // BOXCAMERA1
return "CAMERA WI-FI";
case 40: // BOXCAMERA2
return "CAMERA POWER";
case 41: // BOXCAMERA3
return "CAMERA CHANGE MODE";
default:
return defaultName;
}
}
return defaultName;
}

View file

@ -77,7 +77,8 @@ sources.js = [
'./js/periodicStatusUpdater.js',
'./js/serial_queue.js',
'./js/msp_balanced_interval.js',
'./tabs/advanced_tuning.js'
'./tabs/advanced_tuning.js',
'./js/peripherals.js'
];
sources.mapJs = [

View file

@ -41,7 +41,8 @@ var mspHelper = (function (gui) {
'RX_SERIAL': 6,
'BLACKBOX': 7,
'TELEMETRY_MAVLINK': 8,
'TELEMETRY_IBUS': 9
'TELEMETRY_IBUS': 9,
'RUNCAM_SPLIT_CONTROL' : 10,
};
/**

32
js/peripherals.js Normal file
View file

@ -0,0 +1,32 @@
'use strict';
// return true if user has choose a special peripheral
function isPeripheralSelected(peripheralName) {
for (var portIndex = 0; portIndex < SERIAL_CONFIG.ports.length; portIndex++) {
var serialPort = SERIAL_CONFIG.ports[portIndex];
if (serialPort.functions.indexOf(peripheralName) >= 0) {
return true;
}
}
return false;
}
// Adjust the real name for a modeId. Useful if it belongs to a peripheral
function adjustBoxNameIfPeripheralWithModeID(modeId, defaultName) {
if (isPeripheralSelected("RUNCAM_SPLIT_CONTROL")) {
switch (modeId) {
case 39: // BOXCAMERA1
return "CAMERA WI-FI";
case 40: // BOXCAMERA2
return "CAMERA POWER";
case 41: // BOXCAMERA3
return "CAMERA CHANGE MODE";
default:
return defaultName;
}
}
return defaultName;
}

View file

@ -16,8 +16,16 @@ TABS.auxiliary.initialize = function (callback) {
}
function get_rc_data() {
if (SERIAL_CONFIG.ports.length == 0) {
MSP.send_message(MSPCodes.MSP_RC, false, false, get_serial_config);
} else {
MSP.send_message(MSPCodes.MSP_RC, false, false, load_html);
}
}
function get_serial_config() {
MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/auxiliary.html", process_html);
@ -28,8 +36,10 @@ TABS.auxiliary.initialize = function (callback) {
function createMode(modeIndex, modeId) {
var modeTemplate = $('#tab-auxiliary-templates .mode');
var newMode = modeTemplate.clone();
var modeName = AUX_CONFIG[modeIndex];
// if user choose the runcam split at peripheral column, then adjust the boxname(BOXCAMERA1, BOXCAMERA2, BOXCAMERA3)
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
$(newMode).attr('id', 'mode-' + modeIndex);
$(newMode).find('.name').text(modeName);

View file

@ -101,7 +101,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
continue; // invalid!
}
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + AUX_CONFIG[modeIndex] + "</span>";
var modeName = AUX_CONFIG[modeIndex];
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
auxAssignment[modeRange.auxChannelIndex] += "<span class=\"modename\">" + modeName + "</span>";
}
}

View file

@ -21,6 +21,7 @@
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
<td class='peripherls-column'>Peripherals</td>
</tr>
</thead>
<tbody>
@ -62,6 +63,9 @@
<td class="functionsCell-gps"><select class="gps_baudrate">
<!-- list generated here -->
</select></td>
<td class="functionsCell-peripherals"><select class="blackbox_baudrate">
<!-- list generated here -->
</select></td>
</tr>
</tbody>
</table>

View file

@ -4,6 +4,7 @@ TABS.ports = {};
TABS.ports.initialize = function (callback, scrollPosition) {
var board_definition = {};
var isSupportPeripherals = semver.gte(CONFIG.apiVersion, "1.27.0");
var functionRules = [
{name: 'MSP', groups: ['data', 'msp'], maxPorts: 2},
@ -34,6 +35,12 @@ TABS.ports.initialize = function (callback, scrollPosition) {
});
}
// support configure RunCam Split
GUI.log('API version is ' + CONFIG.apiVersion);
if (isSupportPeripherals) {
functionRules.push({ name: 'RUNCAM_SPLIT_CONTROL', groups: ['peripherals'], maxPorts: 1 });
}
for (var i = 0; i < functionRules.length; i++) {
functionRules[i].displayName = chrome.i18n.getMessage('portsFunction_' + functionRules[i].name);
}
@ -84,7 +91,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
'250000'
];
var columns = ['data', 'logging', 'gps', 'telemetry', 'rx'];
var columns = ['data', 'logging', 'gps', 'telemetry', 'rx', 'peripherals'];
if (GUI.active_tab != 'ports') {
GUI.active_tab = 'ports';
@ -121,6 +128,12 @@ TABS.ports.initialize = function (callback, scrollPosition) {
31: 'SOFTSERIAL2'
};
// if apiVersion < 1.27.0, than remove the peripherals column
if (!isSupportPeripherals) {
$('.peripherls-column').remove();
$('.functionsCell-peripherals').remove();
}
var gps_baudrate_e = $('select.gps_baudrate');
for (var i = 0; i < gpsBaudRates.length; i++) {
gps_baudrate_e.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
@ -183,7 +196,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
}
var select_e;
if (column != 'telemetry') {
if (column !== 'telemetry' && column !== 'peripherals') {
var checkboxId = 'functionCheckbox-' + portIndex + '-' + columnIndex + '-' + i;
functions_e.prepend('<span class="function"><input type="checkbox" class="togglemedium" id="' + checkboxId + '" value="' + functionName + '" /><label for="' + checkboxId + '"> ' + functionRule.displayName + '</label></span>');
@ -248,6 +261,13 @@ TABS.ports.initialize = function (callback, scrollPosition) {
functions.push(telemetryFunction);
}
if (isSupportPeripherals) {
var peripheralFunction = $(portConfiguration_e).find('select[name=function-peripherals]').val();
if (peripheralFunction) {
functions.push(peripheralFunction);
}
}
if (telemetryFunction.length > 0) {
googleAnalytics.sendEvent('Setting', 'Telemetry Protocol', telemetryFunction);
}