diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 94a6dad0a..a76428257 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -876,9 +876,6 @@ "receiverRcInterpolationIntervalHelp": { "message": "Interpolation interval for manual RC interpolation mode in milliseconds" }, - "receiverRcInterpolation": { - "message": "RC Interpolation" - }, "receiverRcInterpolationOff": { "message": "Off" }, @@ -1219,24 +1216,48 @@ "transponderNotSupported": { "message": "Your flight controller's firmware does not support transponder functionality." }, - "transponderHelp": { - "message": "Configure your transponder code here. Note: Only valid codes will be recognised by race timing systems. Valid transponder codes can be obtained from Seriously Pro." - }, "transponderInformation": { "message": "Transponders systems allow race organizers to time your laps. The transponder is fitted to your aircraft and when your aircraft passes the timing gate the track-side receiver registers your code and records your laptime. When fitting an IR based transponder your should ensure that it points outward from your aircraft towards the track-side receivers and that the light beam is not obstructed by your airframe, battery-straps, cables, propellers, etc." }, - "transponderConfiguration": { - "message": "Configuration" + "transponderConfigurationType": { + "message": "Transponder type" + }, + "transponderType0": { + "message": "None" + }, + "transponderType1": { + "message": "iLap" + }, + "transponderType2": { + "message": "aRCiTimer" }, - "transponderData": { + "transponderConfiguration1": { + "message": "Configuration iLap" + }, + "transponderConfiguration2": { + "message": "Configuration aRCiTimer" + }, + "transponderData1": { "message": "Data" }, - "transponderDataHelp": { + "transponderData2": { + "message": "Transponder ID" + }, + "transponderDataHelp1": { "message": "Hexadecimal digits only, 0-9, A-F" }, + "transponderHelp1": { + "message": "Configure your transponder code here. Note: Only valid codes will be recognised by race timing systems. Valid transponder codes can be obtained from Seriously Pro." + }, + "transponderHelp2": { + "message": "For more information please visit aRCiTimer site" + }, "transponderButtonSave": { "message": "Save" }, + "transponderButtonSaveReboot": { + "message": "Save and Reboot" + }, "transponderDataInvalid": { "message": "Transponder data is invalid" }, diff --git a/tabs/transponder.css b/tabs/transponder.css index 7465848e0..f903c158c 100644 --- a/tabs/transponder.css +++ b/tabs/transponder.css @@ -1,3 +1,7 @@ +#tab-transponder-templates { + display: none; +} + .tab-transponder .spacer_box { padding-bottom: 10px; float: left; @@ -73,3 +77,11 @@ .tab-transponder.transponder-supported .require-transponder-supported { display: block; } + +.textspacer-small { + margin-bottom: 15px; +} + +.tab-transponder select { + min-width: 100px; +} diff --git a/tabs/transponder.html b/tabs/transponder.html index c345326f7..c615ac534 100644 --- a/tabs/transponder.html +++ b/tabs/transponder.html @@ -1,10 +1,12 @@
+
Transponder
+
- +

@@ -12,41 +14,67 @@
- -
-
-

-
-
-
-
+
+
-
-
- +
+
+
- -
+ +
+
+
+
+

+
+
+
+
-
+ +
+ +
+
- +

- +
+
-
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+
+
diff --git a/tabs/transponder.js b/tabs/transponder.js index 8135c4ab7..64ca0d756 100644 --- a/tabs/transponder.js +++ b/tabs/transponder.js @@ -1,20 +1,55 @@ 'use strict'; + TABS.transponder = { available: false }; -TABS.transponder.initialize = function (callback, scrollPosition) { - var self = this; +TABS.transponder.initialize = function(callback, scrollPosition) { + + let _persistentInputValues = {}; + + let dataTypes = { + NONE: 0, + TEXT: 1, + LIST: 2, + }; - if (GUI.active_tab != 'transponder') { + // CONFIGURATION HERE FOR ADD NEW TRANSPONDER + let transponderConfigurations = { + 0: { + dataType: dataTypes.NONE // empty + }, //NONE + 1: { + dataType: dataTypes.TEXT // + }, //ilap + 2: { + dataType: dataTypes.LIST, // + dataOptions: { + 'ID 1': 'E00370FC0FFE07E0FF', + 'ID 2': '007C003EF800FC0FFE', + 'ID 3': 'F8811FF8811FFFC7FF', + 'ID 4': '007C003EF81F800FFE', + 'ID 5': 'F00FFF00FFF00FF0FF', + 'ID 6': '007CF0C1071F7C00F0', + 'ID 7': 'E003F03F00FF03F0C1', + 'ID 8': '00FC0FFE071F3E00FE', + 'ID 9': 'E083BFF00F9E38C0FF', + } + }, //arcitimer + }; + ///////////////////////////////////////////// + + if ( GUI.active_tab != 'transponder' ) { GUI.active_tab = 'transponder'; + googleAnalytics.sendAppView('Transponder'); } - // transponder supported added in MSP API Version 1.16.0 - TABS.transponder.available = semver.gte(CONFIG.apiVersion, "1.16.0"); - - if (!TABS.transponder.available) { + if ( CONFIG ) { + TABS.transponder.available = semver.gte(CONFIG.apiVersion, "1.16.0"); + } + ////////////// + if ( !TABS.transponder.available ) { load_html(); return; } @@ -23,13 +58,14 @@ TABS.transponder.initialize = function (callback, scrollPosition) { $('#content').load("./tabs/transponder.html", process_html); } - // get the transponder data and a flag to see if transponder support is enabled on the FC - MSP.send_message(MSPCodes.MSP_TRANSPONDER_CONFIG, false, false, load_html); - + //HELPERS // Convert a hex string to a byte array function hexToBytes(hex) { - for (var bytes = [], c = 0; c < hex.length; c += 2) - bytes.push(~parseInt(hex.substr(c, 2), 16)); + var bytes = []; + for ( let c = 0; c < hex.length; c += 2 ) { + bytes.push(~parseInt(hex.substr(c, 2), 16)); + } + return bytes; } @@ -37,68 +73,202 @@ TABS.transponder.initialize = function (callback, scrollPosition) { n = n + ''; return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n; } - + // Convert a byte array to a hex string function bytesToHex(bytes) { - for (var hex = [], i = 0; i < bytes.length; i++) { - hex.push(pad(((~bytes[i]) & 0xFF).toString(16),2)); + var hex = []; + for ( let i = 0; i < bytes.length; i++ ) { + hex.push(pad(((~bytes[i]) & 0xFF).toString(16), 2)); } return hex.join("").toUpperCase(); } - function process_html() { - // translate to user-selected language - localize(); - - $(".tab-transponder") - .toggleClass("transponder-supported", TABS.transponder.available && TRANSPONDER.supported); - - if (TABS.transponder.available) { - - var data = bytesToHex(TRANSPONDER.data); - - $('input[name="data"]').val(data); - $('input[name="data"]').prop('maxLength', data.length); - - $('a.save').click(function () { - - - // gather data that doesn't have automatic change event bound - - var dataString = $('input[name="data"]').val(); - var expectedLength = TRANSPONDER.data.length; - var hexRegExp = new RegExp('[0-9a-fA-F]{' + (expectedLength * 2) + '}', 'gi'); - if (!dataString.match(hexRegExp)) { - GUI.log(chrome.i18n.getMessage('transponderDataInvalid')); - return; + + ///////////// + + function fillByTransponderProviders(transponderProviders, transponderProviderID, toggleTransponderType) { + let transponderTypeSelect = $('#transponder_type_select'); + transponderTypeSelect.attr('data-defaultValue', transponderProviderID); + transponderTypeSelect.off('change').change(toggleTransponderType); + transponderTypeSelect.html(''); + + //build radio buttons + transponderTypeSelect.append( + $('