diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0298fdb4..3a45e5d0 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -973,7 +973,7 @@ "message": "Cycles/Sec (Hz)" }, "configurationGPS": { - "message": "GPS" + "message": "Configuration" }, "configurationGPSProtocol": { "message": "Protocol" @@ -1624,10 +1624,10 @@ "message":"
  1. Remove propellers
  2. Connect LiPo and use Outputs Tab to test all motors
  3. Note the position of each motor (motor #1 - Left Top and so on)
  4. Fill the table below
" }, "gpsHead": { - "message": "GPS" + "message": "Position" }, "gpsStatHead": { - "message": "GPS Statistics" + "message": "Statistics" }, "gpsMapHead": { "message": "Current GPS location" diff --git a/js/fc.js b/js/fc.js index 26a638d2..bfa2ec57 100644 --- a/js/fc.js +++ b/js/fc.js @@ -576,7 +576,7 @@ var FC = { {bit: 1, group: 'batteryVoltage', name: 'VBAT'}, {bit: 4, group: 'other', name: 'MOTOR_STOP'}, {bit: 6, group: 'other', name: 'SOFTSERIAL', haveTip: true, showNameInTip: true}, - {bit: 7, group: 'gps', name: 'GPS', haveTip: true}, + {bit: 7, group: 'other', name: 'GPS', haveTip: true}, {bit: 10, group: 'other', name: 'TELEMETRY', showNameInTip: true}, {bit: 11, group: 'batteryCurrent', name: 'CURRENT_METER'}, {bit: 12, group: 'other', name: 'REVERSIBLE_MOTORS', showNameInTip: true}, diff --git a/tabs/configuration.html b/tabs/configuration.html index 5aa01f00..e628ae36 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -76,64 +76,6 @@ -
-
-
-
-
-
-
-

-
-
- -
- - -
- - -
-
- - -
- -
- - -
-
- - -
-
-
- - -
-
-
-
diff --git a/tabs/configuration.js b/tabs/configuration.js index 28cf8eee..7d3b9cb7 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -146,32 +146,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag); - // generate GPS - var gpsProtocols = FC.getGpsProtocols(); - var gpsSbas = FC.getGpsSbasProviders(); - - var gps_protocol_e = $('#gps_protocol'); - for (i = 0; i < gpsProtocols.length; i++) { - gps_protocol_e.append(''); - } - - gps_protocol_e.change(function () { - MISC.gps_type = parseInt($(this).val()); - }); - - gps_protocol_e.val(MISC.gps_type); - - var gps_ubx_sbas_e = $('#gps_ubx_sbas'); - for (i = 0; i < gpsSbas.length; i++) { - gps_ubx_sbas_e.append(''); - } - - gps_ubx_sbas_e.change(function () { - MISC.gps_ubx_sbas = parseInt($(this).val()); - }); - - gps_ubx_sbas_e.val(MISC.gps_ubx_sbas); - // VTX var config_vtx = $('.config-vtx'); if (VTX_CONFIG.device_type != VTX.DEV_UNKNOWN) { diff --git a/tabs/gps.html b/tabs/gps.html index 03db5254..562dc785 100644 --- a/tabs/gps.html +++ b/tabs/gps.html @@ -1,8 +1,78 @@ -
+
GPS
-
+
+ +
+
+
+
+
+
+
+

+
+
+ +
+ + +
+
+ +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+
+ + +
+
+
+
+ +
@@ -80,18 +150,23 @@
-
+
- +
-
+
+
-
-
+
+
+ +
+
+
\ No newline at end of file diff --git a/tabs/gps.js b/tabs/gps.js index be8291d9..b987f975 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -1,3 +1,4 @@ +/*global $,MSPChainerClass,googleAnalytics,mspHelper,MSPCodes,GUI,chrome,MSP,TABS,Settings,helper,ol*/ 'use strict'; TABS.gps = {}; @@ -8,11 +9,49 @@ TABS.gps.initialize = function (callback) { googleAnalytics.sendAppView('GPS'); } - function load_html() { - GUI.load("./tabs/gps.html", process_html); + var loadChainer = new MSPChainerClass(); + + var loadChain = [ + mspHelper.loadBfConfig, + mspHelper.loadMiscV2 + ]; + + loadChainer.setChain(loadChain); + loadChainer.setExitPoint(load_html); + loadChainer.execute(); + + var saveChainer = new MSPChainerClass(); + + var saveChain = [ + mspHelper.saveBfConfig, + mspHelper.saveMiscV2, + saveSettings, + mspHelper.saveToEeprom + ]; + + function saveSettings(onComplete) { + Settings.saveInputs().then(onComplete); } - load_html(); + saveChainer.setChain(saveChain); + saveChainer.setExitPoint(reboot); + + function reboot() { + //noinspection JSUnresolvedVariable + GUI.log(chrome.i18n.getMessage('configurationEepromSaved')); + + GUI.tab_switch_cleanup(function () { + MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { + //noinspection JSUnresolvedVariable + GUI.log(chrome.i18n.getMessage('deviceRebooting')); + GUI.handleReconnect($('.tab_gps a')); + }); + }); + } + + function load_html() { + GUI.load("./tabs/gps.html", Settings.processHtml(process_html)); + } let cursorInitialized = false; let iconStyle; @@ -23,6 +62,36 @@ TABS.gps.initialize = function (callback) { function process_html() { localize(); + var features = FC.getFeatures(); + + helper.features.updateUI($('.tab-gps'), BF_CONFIG.features); + + // generate GPS + var gpsProtocols = FC.getGpsProtocols(); + var gpsSbas = FC.getGpsSbasProviders(); + + var gps_protocol_e = $('#gps_protocol'); + for (i = 0; i < gpsProtocols.length; i++) { + gps_protocol_e.append(''); + } + + gps_protocol_e.change(function () { + MISC.gps_type = parseInt($(this).val()); + }); + + gps_protocol_e.val(MISC.gps_type); + + var gps_ubx_sbas_e = $('#gps_ubx_sbas'); + for (i = 0; i < gpsSbas.length; i++) { + gps_ubx_sbas_e.append(''); + } + + gps_ubx_sbas_e.change(function () { + MISC.gps_ubx_sbas = parseInt($(this).val()); + }); + + gps_ubx_sbas_e.val(MISC.gps_ubx_sbas); + let mapView = new ol.View({ center: ol.proj.fromLonLat([0, 0]), zoom: 15 @@ -36,20 +105,20 @@ TABS.gps.initialize = function (callback) { imagerySet: 'AerialWithLabels', maxZoom: 19 }); - } else if ( globalSettings.mapProviderType == 'mapproxy' ) { - mapLayer = new ol.source.TileWMS({ - url: globalSettings.proxyURL, - params: {'LAYERS':globalSettings.proxyLayer} - }) + } else if (globalSettings.mapProviderType == 'mapproxy') { + mapLayer = new ol.source.TileWMS({ + url: globalSettings.proxyURL, + params: { 'LAYERS': globalSettings.proxyLayer } + }) } else { mapLayer = new ol.source.OSM(); } - $("#center_button").click(function(){ - let lat = GPS_DATA.lat / 10000000; - let lon = GPS_DATA.lon / 10000000; - let center = ol.proj.fromLonLat([lon, lat]); - mapView.setCenter(center); + $("#center_button").click(function () { + let lat = GPS_DATA.lat / 10000000; + let lon = GPS_DATA.lon / 10000000; + let center = ol.proj.fromLonLat([lon, lat]); + mapView.setCenter(center); }); mapHandler = new ol.Map({ @@ -144,7 +213,7 @@ TABS.gps.initialize = function (callback) { }); mapHandler.addLayer(currentPositionLayer); - + mapView.setCenter(center); mapView.setZoom(14); } @@ -172,6 +241,29 @@ TABS.gps.initialize = function (callback) { get_raw_gps_data(); }); + + $('a.save').on('click', function () { + if (FC.isFeatureEnabled('GPS', features)) { + googleAnalytics.sendEvent('Setting', 'GpsProtocol', gpsProtocols[MISC.gps_type]); + googleAnalytics.sendEvent('Setting', 'GpsSbas', gpsSbas[MISC.gps_ubx_sbas]); + } + + googleAnalytics.sendEvent('Setting', 'GPSEnabled', FC.isFeatureEnabled('GPS', features) ? "true" : "false"); + + for (var i = 0; i < features.length; i++) { + var featureName = features[i].name; + if (FC.isFeatureEnabled(featureName, features)) { + googleAnalytics.sendEvent('Setting', 'Feature', featureName); + } + } + + helper.features.reset(); + helper.features.fromUI($('.tab-gps')); + helper.features.execute(function () { + saveChainer.execute(); + }); + }); + GUI.content_ready(callback); }