diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 3dc10bc1..6ad07bfd 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -783,6 +783,9 @@ "portsFunction_BLACKBOX": { "message": "Blackbox" }, + "portsFunction_RUNCAM_SPLIT_CONTROL": { + "message": "RunCam Split" + }, "pidTuningName": { "message": "Name" }, diff --git a/build/script.js b/build/script.js old mode 100755 new mode 100644 index 48b33f5f..3e2a2521 --- a/build/script.js +++ b/build/script.js @@ -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,7 +14595,15 @@ TABS.auxiliary.initialize = function (callback) { } function get_rc_data() { - MSP.send_message(MSPCodes.MSP_RC, false, false, load_html); + 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() { @@ -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] += "" + AUX_CONFIG[modeIndex] + ""; + var modeName = AUX_CONFIG[modeIndex]; + modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName); + auxAssignment[modeRange.auxChannelIndex] += "" + modeName + ""; } } @@ -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(''); @@ -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(''); @@ -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; + +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index a3883f19..2147837f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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 = [ diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index c1512e3f..94a0cd59 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -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, }; /** diff --git a/js/peripherals.js b/js/peripherals.js new file mode 100644 index 00000000..70ea7ab8 --- /dev/null +++ b/js/peripherals.js @@ -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; + +} \ No newline at end of file diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index f0a9895d..02f01ee8 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -16,7 +16,15 @@ TABS.auxiliary.initialize = function (callback) { } function get_rc_data() { - MSP.send_message(MSPCodes.MSP_RC, false, false, load_html); + 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() { @@ -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); diff --git a/tabs/failsafe.js b/tabs/failsafe.js index f00ccb70..3ceccb1c 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -101,7 +101,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { continue; // invalid! } - auxAssignment[modeRange.auxChannelIndex] += "" + AUX_CONFIG[modeIndex] + ""; + var modeName = AUX_CONFIG[modeIndex]; + modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName); + auxAssignment[modeRange.auxChannelIndex] += "" + modeName + ""; } } diff --git a/tabs/ports.html b/tabs/ports.html index f74a81e3..338735d0 100644 --- a/tabs/ports.html +++ b/tabs/ports.html @@ -21,6 +21,7 @@ Telemetry RX GPS + Peripherals @@ -62,6 +63,9 @@ + diff --git a/tabs/ports.js b/tabs/ports.js index c34c81e5..22d41a8f 100644 --- a/tabs/ports.js +++ b/tabs/ports.js @@ -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(''); @@ -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(''); @@ -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); }