Skip to content

Commit

Permalink
Move GPS configuration to GPS tab (#3326)
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis authored Feb 8, 2023
1 parent 1906b3a commit 309bd43
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 249 deletions.
5 changes: 1 addition & 4 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@
"message": "<strong>Note:</strong> 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"
Expand Down Expand Up @@ -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": "<strong>Note:</strong> Remember to configure a Serial Port (via Ports tab) when using GPS feature."
},
"configurationSerialRX": {
"message": "Serial Receiver Provider"
},
Expand Down
39 changes: 0 additions & 39 deletions src/css/tabs/configuration.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -340,11 +306,6 @@
float: left;
width: 100%;
}
.gpsSettings {
.note {
margin-top: 10px;
}
}
}
@media only screen and (max-width: 1055px) {
.tab-configuration {
Expand Down
74 changes: 74 additions & 0 deletions src/css/tabs/gps.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/js/Features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
99 changes: 1 addition & 98 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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(`<option value="${protocolIndex}">${gpsProtocols[protocolIndex]}</option>`);
}

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(`<option value="${sbasIndex}">${gpsSbas[sbasIndex]}</option>`);
}

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(`<option value="${gpsBaudRates[baudRateIndex]}">${gpsBaudRates[baudRateIndex]}</option>`);
}

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);
Expand Down Expand Up @@ -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();
Expand All @@ -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)))
Expand Down
Loading

0 comments on commit 309bd43

Please sign in to comment.