From 5b7d9bfa522762785fb839a1636b7643f0febd80 Mon Sep 17 00:00:00 2001 From: IvoFPV Date: Tue, 3 Sep 2019 19:11:05 +0200 Subject: [PATCH] Add warning if SA port assigned and no Vtx Table --- locales/en/messages.json | 3 +++ src/js/tabs/ports.js | 32 +++++++++++++++++++++++++++++++- src/tabs/ports.html | 5 +++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 7ed013d8..60578902 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1373,6 +1373,9 @@ "portsHelp": { "message": "Note: not all combinations are valid. When the flight controller firmware detects this the serial port configuration will be reset." }, + "portsVtxTableNotSet": { + "message": "WARNING: The VTX table has not been set up correctly and without it VTX control will not be possible. Please set up the VTX table in $t(tabVtx.message) tab." + }, "portsMSPHelp": { "message": "Note: Do NOT disable MSP on the first serial port unless you know what you are doing. You may have to reflash and erase your configuration if you do." }, diff --git a/src/js/tabs/ports.js b/src/js/tabs/ports.js index c367696d..e9c3ff7b 100644 --- a/src/js/tabs/ports.js +++ b/src/js/tabs/ports.js @@ -111,7 +111,13 @@ TABS.ports.initialize = function (callback, scrollPosition) { load_configuration_from_fc(); function load_configuration_from_fc() { - MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, on_configuration_loaded_handler); + if(semver.gte(CONFIG.apiVersion, "1.42.0")) { + MSP.promise(MSPCodes.MSP_VTX_CONFIG).then(function() { + return MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, on_configuration_loaded_handler); + }); + } else { + MSP.send_message(MSPCodes.MSP_CF_SERIAL_CONFIG, false, false, on_configuration_loaded_handler); + } function on_configuration_loaded_handler() { $('#content').load("./tabs/ports.html", on_tab_loaded_handler); @@ -273,6 +279,30 @@ TABS.ports.initialize = function (callback, scrollPosition) { ports_e.find('tbody').append(port_configuration_e); } + if (semver.gte(CONFIG.apiVersion, "1.42.0")) { + var vtxTableNotConfigured = VTX_CONFIG.vtx_table_available && + (VTX_CONFIG.vtx_table_bands == 0 || + VTX_CONFIG.vtx_table_channels == 0 || + VTX_CONFIG.vtx_table_powerlevels == 0); + const pheripheralsSelectElement = $('select[name="function-peripherals"]'); + pheripheralsSelectElement.change(function() { + let vtxControlSelected = false; + pheripheralsSelectElement.each(function() { + const el = $(this); + if (el.val() == "TBS_SMARTAUDIO" || el.val() == "IRC_TRAMP") { + vtxControlSelected = true; + } + }); + if (vtxControlSelected && vtxTableNotConfigured) { + $('.vtxTableNotSet').show(); + } else { + $('.vtxTableNotSet').hide(); + } + }); + pheripheralsSelectElement.change(); + } else { + $('.vtxTableNotSet').hide(); + } } function on_tab_loaded_handler() { diff --git a/src/tabs/ports.html b/src/tabs/ports.html index 14a96aa4..8a71c7a3 100644 --- a/src/tabs/ports.html +++ b/src/tabs/ports.html @@ -11,6 +11,11 @@

+
+
+

+
+