diff --git a/locales/en/messages.json b/locales/en/messages.json index ca60a8b9fb..6a6a35c780 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1410,7 +1410,7 @@ "message": "Note: Make sure your FC is able to operate at these speeds! Check CPU and cycletime stability. Changing this may require PID re-tuning. TIP: Disable Accelerometer and other sensors to gain more performance." }, "configurationGPS": { - "message": "GPS" + "message": "GPS Configuration" }, "configurationGPSProtocol": { "message": "Protocol" @@ -1443,9 +1443,6 @@ "message": "When enabled, only the first arm after the battery is connected will be used as home point. If not enabled, every time the quad is armed, the home point will be updated.", "description": "Help text for the option to set the Home Point with the first arm only, not with each arm in the GPS Configuration" }, - "configurationGPSHelp": { - "message": "Note: Remember to configure a Serial Port (via Ports tab) when using GPS feature." - }, "configurationSerialRX": { "message": "Serial Receiver Provider" }, diff --git a/src/css/tabs/configuration.less b/src/css/tabs/configuration.less index 34a8157e7b..1420f7a084 100644 --- a/src/css/tabs/configuration.less +++ b/src/css/tabs/configuration.less @@ -111,40 +111,6 @@ margin-bottom: 0; } } - .gps { - .line { - clear: left; - } - select { - float: left; - width: 100px; - height: 20px; - margin: 0 10px 5px 0; - border: 1px solid var(--subtleAccent); - } - .select { - >div { - &:first-child { - float: left; - height: 20px; - margin-right: 15px; - margin-left: 3px; - } - } - } - span { - line-height: 20px; - } - .gui_box { - float: left; - margin-bottom: 10px; - } - td { - &:nth-child(2) { - width: 38px; - } - } - } .freelabel { margin-left: 10px; position: relative; @@ -340,11 +306,6 @@ float: left; width: 100%; } - .gpsSettings { - .note { - margin-top: 10px; - } - } } @media only screen and (max-width: 1055px) { .tab-configuration { diff --git a/src/css/tabs/gps.less b/src/css/tabs/gps.less index 4ba6de6ad2..972a3a4d30 100644 --- a/src/css/tabs/gps.less +++ b/src/css/tabs/gps.less @@ -40,6 +40,80 @@ .gps_map { height: 460px; } + .gps_config { + font-size: 11px; + .line { + clear: left; + } + select { + float: left; + width: 100px; + height: 20px; + margin: 0 10px 5px 0; + border: 1px solid var(--subtleAccent); + } + .select { + >div { + &:first-child { + float: left; + height: 20px; + margin-right: 15px; + margin-left: 3px; + } + } + } + span { + line-height: 20px; + } + .gui_box { + float: left; + margin-bottom: 10px; + } + td { + &:nth-child(2) { + width: 38px; + } + } + } + dl.features { + dt { + float: left; + width: 10px; + height: 18px; + line-height: 18px; + input { + margin-top: 2px; + } + } + dd { + margin: 0 0 0 20px; + height: 18px; + line-height: 18px; + } + } + .freelabel { + margin-left: 10px; + position: relative; + } + .spacer_box { + padding-bottom: 10px; + float: left; + width: calc(100% - 20px); + } + .select { + margin-bottom: 5px; + clear: left; + padding-bottom: 5px; + border-bottom: 1px solid var(--subtleAccent); + width: 100%; + float: left; + &:last-child { + border-bottom: none; + padding-bottom: 0; + margin-bottom: 0; + } + } + #connect { display: none; text-align: center; diff --git a/src/js/Features.js b/src/js/Features.js index e57d25688f..2324a16c86 100644 --- a/src/js/Features.js +++ b/src/js/Features.js @@ -37,7 +37,7 @@ const Features = function (config) { ); } - self._features = features; + self._features = features.sort((a, b) => a.name.localeCompare(b.name, window.navigator.language, { ignorePunctuation: true })); self._featureMask = 0; self._analyticsChanges = {}; diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index ebd8020187..13318db078 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -33,7 +33,6 @@ configuration.initialize = function (callback) { .then(() => MSP.promise(MSPCodes.MSP_FEATURE_CONFIG)) .then(() => MSP.promise(MSPCodes.MSP_BEEPER_CONFIG)) .then(() => MSP.promise(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG)) - .then(() => MSP.promise(MSPCodes.MSP_GPS_CONFIG)) .then(() => MSP.promise(MSPCodes.MSP_ACC_TRIM)) .then(() => MSP.promise(MSPCodes.MSP_ARMING_CONFIG)) .then(() => MSP.promise(MSPCodes.MSP_RC_DEADBAND)) @@ -336,99 +335,6 @@ configuration.initialize = function (callback) { $('input[name="fpvCamAngleDegrees"]').val(FC.RX_CONFIG.fpvCamAngleDegrees); $('input[name="fpvCamAngleDegrees"]').attr("max", 90); - // generate GPS - const gpsProtocols = [ - 'NMEA', - 'UBLOX', - 'MSP', - ]; - - const gpsBaudRates = [ - '115200', - '57600', - '38400', - '19200', - '9600', - ]; - - const gpsSbas = [ - i18n.getMessage('gpsSbasAutoDetect'), - i18n.getMessage('gpsSbasEuropeanEGNOS'), - i18n.getMessage('gpsSbasNorthAmericanWAAS'), - i18n.getMessage('gpsSbasJapaneseMSAS'), - i18n.getMessage('gpsSbasIndianGAGAN'), - ]; - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) { - gpsSbas.push(i18n.getMessage('gpsSbasNone')); - } - - const gpsProtocolElement = $('select.gps_protocol'); - const gpsAutoBaudElement = $('input[name="gps_auto_baud"]'); - const gpsAutoBaudGroup = $('.gps_auto_baud'); - const gpsAutoConfigElement = $('input[name="gps_auto_config"]'); - const gpsAutoConfigGroup = $('.gps_auto_config'); - const gpsUbloxGalileoElement = $('input[name="gps_ublox_galileo"]'); - const gpsUbloxGalileoGroup = $('.gps_ublox_galileo'); - const gpsUbloxSbasElement = $('select.gps_ubx_sbas'); - const gpsUbloxSbasGroup = $('.gps_ubx_sbas'); - const gpsHomeOnceElement = $('input[name="gps_home_once"]'); - const gpsBaudrateElement = $('select.gps_baudrate'); - - - for (let protocolIndex = 0; protocolIndex < gpsProtocols.length; protocolIndex++) { - gpsProtocolElement.append(``); - } - - gpsProtocolElement.change(function () { - FC.GPS_CONFIG.provider = parseInt($(this).val()); - - // Call this to enable or disable auto config elements depending on the protocol - gpsAutoConfigElement.change(); - - }).val(FC.GPS_CONFIG.provider).change(); - - gpsAutoBaudElement.prop('checked', FC.GPS_CONFIG.auto_baud === 1); - - gpsAutoConfigElement.change(function () { - const checked = $(this).is(":checked"); - - const ubloxSelected = FC.GPS_CONFIG.provider === gpsProtocols.indexOf('UBLOX'); - - const enableGalileoVisible = checked && ubloxSelected && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43); - gpsUbloxGalileoGroup.toggle(enableGalileoVisible); - - const enableSbasVisible = checked && ubloxSelected; - gpsUbloxSbasGroup.toggle(enableSbasVisible); - - }).prop('checked', FC.GPS_CONFIG.auto_config === 1).change(); - - gpsAutoBaudGroup.show(); - gpsAutoConfigGroup.show(); - - gpsUbloxGalileoElement.change(function() { - FC.GPS_CONFIG.ublox_use_galileo = $(this).is(':checked') ? 1 : 0; - }).prop('checked', FC.GPS_CONFIG.ublox_use_galileo > 0).change(); - - for (let sbasIndex = 0; sbasIndex < gpsSbas.length; sbasIndex++) { - gpsUbloxSbasElement.append(``); - } - - gpsUbloxSbasElement.change(function () { - FC.GPS_CONFIG.ublox_sbas = parseInt($(this).val()); - }).val(FC.GPS_CONFIG.ublox_sbas); - - $('.gps_home_once').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)); - gpsHomeOnceElement.change(function() { - FC.GPS_CONFIG.home_point_once = $(this).is(':checked') ? 1 : 0; - }).prop('checked', FC.GPS_CONFIG.home_point_once > 0).change(); - - for (let baudRateIndex = 0; baudRateIndex < gpsBaudRates.length; baudRateIndex++) { - gpsBaudrateElement.append(``); - } - - gpsBaudrateElement.prop("disabled", true); - gpsBaudrateElement.parent().hide(); - // fill board alignment $('input[name="board_align_roll"]').val(FC.BOARD_ALIGNMENT_CONFIG.roll); $('input[name="board_align_pitch"]').val(FC.BOARD_ALIGNMENT_CONFIG.pitch); @@ -514,12 +420,10 @@ configuration.initialize = function (callback) { self.analyticsChanges = {}; // fill some data - FC.GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0; - FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0; - FC.SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1; FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1; FC.SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1; + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { FC.CONFIG.craftName = $('input[name="craftName"]').val().trim(); FC.CONFIG.pilotName = $('input[name="pilotName"]').val().trim(); @@ -537,7 +441,6 @@ configuration.initialize = function (callback) { .then(() => MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG))) .then(() => MSP.promise(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG))) .then(() => MSP.promise(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG))) - .then(() => MSP.promise(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG))) .then(() => MSP.promise(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND))) .then(() => MSP.promise(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT))) .then(() => MSP.promise(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG))) diff --git a/src/js/tabs/gps.js b/src/js/tabs/gps.js index a43ffe50b0..3d2807ef68 100644 --- a/src/js/tabs/gps.js +++ b/src/js/tabs/gps.js @@ -1,23 +1,32 @@ import { i18n } from "../localization"; +import semver from 'semver'; +import { API_VERSION_1_43 } from '../data_storage'; import GUI, { TABS } from '../gui'; -import { have_sensor } from "../sensor_helpers"; import FC from '../fc'; import MSP from "../msp"; import MSPCodes from "../msp/MSPCodes"; +import { gui_log } from '../gui_log'; +import { have_sensor } from "../sensor_helpers"; +import { mspHelper } from '../msp/MSPHelper'; +import { reinitializeConnection } from '../serial_backend'; +import { updateTabList } from '../utils/updateTabList'; const gps = {}; -gps.initialize = function (callback) { - if (GUI.active_tab !== 'gps') { - GUI.active_tab = 'gps'; - } +gps.initialize = async function (callback) { + + GUI.active_tab = 'gps'; + + await MSP.promise(MSPCodes.MSP_FEATURE_CONFIG); + await MSP.promise(MSPCodes.MSP_GPS_CONFIG); + await MSP.promise(MSPCodes.MSP_STATUS); + + load_html(); function load_html() { $('#content').load("./tabs/gps.html", process_html); } - MSP.send_message(MSPCodes.MSP_STATUS, false, false, load_html); - function set_online(){ $('#connect').hide(); $('#waiting').show(); @@ -49,6 +58,122 @@ gps.initialize = function (callback) { // To not flicker the divs while the fix is unstable let gpsWasFixed = false; + // GPS Configuration + const features_e = $('.tab-gps .features'); + + FC.FEATURE_CONFIG.features.generateElements(features_e); + + const checkUpdateGpsControls = () => $('.gpsSettings').toggle(FC.FEATURE_CONFIG.features.isEnabled('GPS')); + + $('input.feature', features_e).on('change', function () { + const element = $(this); + + FC.FEATURE_CONFIG.features.updateData(element); + updateTabList(FC.FEATURE_CONFIG.features); + + if (element.attr('name') === 'GPS') { + checkUpdateGpsControls(); + } + }); + + checkUpdateGpsControls(); + + // generate GPS + const gpsProtocols = [ + 'NMEA', + 'UBLOX', + 'MSP', + ]; + + const gpsBaudRates = [ + '115200', + '57600', + '38400', + '19200', + '9600', + ]; + + const gpsSbas = [ + i18n.getMessage('gpsSbasAutoDetect'), + i18n.getMessage('gpsSbasEuropeanEGNOS'), + i18n.getMessage('gpsSbasNorthAmericanWAAS'), + i18n.getMessage('gpsSbasJapaneseMSAS'), + i18n.getMessage('gpsSbasIndianGAGAN'), + ]; + + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) { + gpsSbas.push(i18n.getMessage('gpsSbasNone')); + } + + const gpsProtocolElement = $('select.gps_protocol'); + const gpsAutoBaudElement = $('input[name="gps_auto_baud"]'); + const gpsAutoBaudGroup = $('.gps_auto_baud'); + const gpsAutoConfigElement = $('input[name="gps_auto_config"]'); + const gpsAutoConfigGroup = $('.gps_auto_config'); + const gpsUbloxGalileoElement = $('input[name="gps_ublox_galileo"]'); + const gpsUbloxGalileoGroup = $('.gps_ublox_galileo'); + const gpsUbloxSbasElement = $('select.gps_ubx_sbas'); + const gpsUbloxSbasGroup = $('.gps_ubx_sbas'); + const gpsHomeOnceElement = $('input[name="gps_home_once"]'); + const gpsBaudrateElement = $('select.gps_baudrate'); + + for (let protocolIndex = 0; protocolIndex < gpsProtocols.length; protocolIndex++) { + gpsProtocolElement.append(``); + } + + gpsProtocolElement.change(function () { + FC.GPS_CONFIG.provider = parseInt($(this).val()); + + // Call this to enable or disable auto config elements depending on the protocol + gpsAutoConfigElement.change(); + + }).val(FC.GPS_CONFIG.provider).change(); + + gpsAutoBaudElement.prop('checked', FC.GPS_CONFIG.auto_baud === 1); + + gpsAutoConfigElement.on('change', function () { + const checked = $(this).is(":checked"); + + const ubloxSelected = FC.GPS_CONFIG.provider === gpsProtocols.indexOf('UBLOX'); + const mspSelected = FC.GPS_CONFIG.provider === gpsProtocols.indexOf('MSP'); + + const enableGalileoVisible = checked && ubloxSelected && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43); + gpsUbloxGalileoGroup.toggle(enableGalileoVisible); + + const enableSbasVisible = checked && ubloxSelected; + gpsUbloxSbasGroup.toggle(enableSbasVisible); + + gpsAutoBaudGroup.toggle(ubloxSelected || mspSelected); + gpsAutoConfigGroup.toggle(ubloxSelected || mspSelected); + + }).prop('checked', FC.GPS_CONFIG.auto_config === 1).trigger('change'); + + gpsUbloxGalileoElement.change(function() { + FC.GPS_CONFIG.ublox_use_galileo = $(this).is(':checked') ? 1 : 0; + }).prop('checked', FC.GPS_CONFIG.ublox_use_galileo > 0).change(); + + for (let sbasIndex = 0; sbasIndex < gpsSbas.length; sbasIndex++) { + gpsUbloxSbasElement.append(``); + } + + gpsUbloxSbasElement.change(function () { + FC.GPS_CONFIG.ublox_sbas = parseInt($(this).val()); + }).val(FC.GPS_CONFIG.ublox_sbas); + + $('.gps_home_once').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)); + gpsHomeOnceElement.change(function() { + FC.GPS_CONFIG.home_point_once = $(this).is(':checked') ? 1 : 0; + }).prop('checked', FC.GPS_CONFIG.home_point_once > 0).change(); + + for (const baudRate of gpsBaudRates) { + gpsBaudrateElement.append(``); + } + + gpsBaudrateElement.prop("disabled", true); + gpsBaudrateElement.parent().hide(); + + // End GPS Configuration + function update_ui() { const lat = FC.GPS_DATA.lat / 10000000; const lon = FC.GPS_DATA.lon / 10000000; @@ -80,6 +205,7 @@ gps.initialize = function (callback) { ${i18n.getMessage('gpsSignalStatusQly')} `); + if (FC.GPS_DATA.chn.length <= 16) { // Legacy code path: old BF firmware or old ublox module for (let i = 0; i < FC.GPS_DATA.chn.length; i++) { @@ -155,11 +281,9 @@ gps.initialize = function (callback) { message.action = 'nofix'; frame.contentWindow.postMessage(message, '*'); } - }else{ + } else { gpsWasFixed = false; - $('#connect').show(); - $('#waiting').hide(); - $('#loadmap').hide(); + set_offline(); } } @@ -216,9 +340,31 @@ gps.initialize = function (callback) { frame.contentWindow.postMessage(message, '*'); }); + $('a.save').on('click', function() { + // fill some data + FC.GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0; + FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0; + + async function saveConfiguration() { + await MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG)); + await MSP.promise(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG)); + await MSP.promise(MSPCodes.MSP_EEPROM_WRITE); + reboot(); + } + + function reboot() { + gui_log(i18n.getMessage('configurationEepromSaved')); + + GUI.tab_switch_cleanup(function() { + MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection); + }); + } + + saveConfiguration(); + }); + GUI.content_ready(callback); } - }; gps.cleanup = function (callback) { diff --git a/src/tabs/configuration.html b/src/tabs/configuration.html index 68c5376e37..94b700ba2c 100644 --- a/src/tabs/configuration.html +++ b/src/tabs/configuration.html @@ -135,7 +135,7 @@ - + @@ -143,82 +143,6 @@ - - -
-
-
-
-
-
- - - - - - - - - - - -
-
-
-
-

-
- -
- - -
-
- - -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
- -
-
-
- - -
-
-
-
-
-
-
@@ -416,10 +340,12 @@
+
+ diff --git a/src/tabs/gps.html b/src/tabs/gps.html index 5ff192c8cc..f9e5d33e48 100644 --- a/src/tabs/gps.html +++ b/src/tabs/gps.html @@ -1,13 +1,83 @@ -
+
GPS
-
+ +
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ +
+
@@ -46,18 +116,6 @@
-
-
-
-
-
- - -
-
-
-
-
@@ -65,9 +123,8 @@ -
-
-
+
+
@@ -76,9 +133,14 @@
+
+
+
+ +
+
-