Skip to content

Commit e17965d

Browse files
authored
Merge pull request #2112 from iNavFlight/wizard-gps-step
Wizard GPS step
2 parents 80cf875 + f6df2c0 commit e17965d

5 files changed

+119
-11
lines changed

js/defaults_dialog.js

+23
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ var defaultsDialog = (function () {
7272
name: "receiverProtocol",
7373
value: $container.find('#wizard-receiver-protocol option:selected').text()
7474
});
75+
} else if (stepName == "gps") {
76+
let port = $container.find('#wizard-gps-port').val();
77+
let baud = $container.find('#wizard-gps-baud').val();
78+
let protocol = $container.find('#wizard-gps-protocol option:selected').text();
79+
80+
privateScope.wizardSettings.push({
81+
name: "gpsPort",
82+
value: {
83+
port: port,
84+
baud: baud
85+
}
86+
});
87+
88+
privateScope.wizardSettings.push({
89+
name: "gpsProtocol",
90+
value: protocol
91+
});
7592
}
7693

7794
privateScope.wizard(selectedDefaultPreset, wizardStep + 1);
@@ -121,6 +138,12 @@ var defaultsDialog = (function () {
121138
* Bindings executed when the receiver wizard tab is loaded
122139
*/
123140
wizardUiBindings.receiver($content);
141+
} else if (stepName == "gps") {
142+
/**
143+
* Bindings executed when the GPS wizard tab is loaded
144+
*
145+
*/
146+
wizardUiBindings.gps($content);
124147
}
125148

126149
Settings.configureInputs().then(

js/defaults_dialog_entries.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var defaultsDialogData = [
77
"notRecommended": false,
88
"reboot": true,
99
"mixerToApply": 3,
10-
"wizardPages": ['receiver'],
10+
"wizardPages": ['receiver', 'gps'],
1111
"settings": [
1212
{
1313
key: "model_preview_type",
@@ -129,7 +129,7 @@ var defaultsDialogData = [
129129
"notRecommended": false,
130130
"reboot": true,
131131
"mixerToApply": 3,
132-
"wizardPages": ['receiver'],
132+
"wizardPages": ['receiver', 'gps'],
133133
"settings": [
134134
{
135135
key: "model_preview_type",
@@ -270,7 +270,7 @@ var defaultsDialogData = [
270270
"notRecommended": false,
271271
"reboot": true,
272272
"mixerToApply": 3,
273-
"wizardPages": ['receiver'],
273+
"wizardPages": ['receiver', 'gps'],
274274
"settings": [
275275
{
276276
key: "model_preview_type",
@@ -392,7 +392,7 @@ var defaultsDialogData = [
392392
"id": 3,
393393
"reboot": true,
394394
"mixerToApply": 14,
395-
"wizardPages": ['receiver'],
395+
"wizardPages": ['receiver', 'gps'],
396396
"settings": [
397397
{
398398
key: "model_preview_type",
@@ -598,7 +598,7 @@ var defaultsDialogData = [
598598
"id": 4,
599599
"reboot": true,
600600
"mixerToApply": 8,
601-
"wizardPages": ['receiver'],
601+
"wizardPages": ['receiver', 'gps'],
602602
"settings": [
603603
{
604604
key: "model_preview_type",
@@ -804,7 +804,7 @@ var defaultsDialogData = [
804804
"notRecommended": false,
805805
"reboot": true,
806806
"mixerToApply": 31,
807-
"wizardPages": ['receiver'],
807+
"wizardPages": ['receiver', 'gps'],
808808
"settings": [
809809
{
810810
key: "model_preview_type",

js/wizard_save_framework.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
const mspHelper = require('./msp/MSPHelper');
44
const serialPortHelper = require('./serialPortHelper');
55
const FC = require('./fc');
6+
const features = require('./feature_framework');
67

78
var wizardSaveFramework = (function () {
89

910
let self = {};
1011

1112
self.saveSetting = function (config, callback) {
12-
/*
13-
serialrx_provider to 2
14-
serialrx_provider to 6
15-
*/
1613

1714
switch (config.name) {
1815
case 'receiverPort':
@@ -22,6 +19,24 @@ var wizardSaveFramework = (function () {
2219
case 'receiverProtocol':
2320
mspHelper.setSetting('serialrx_provider', config.value, callback);
2421
break;
22+
case 'gpsPort':
23+
24+
let gpsBit = FC.getFeatures().find( feature => feature.name === 'GPS' ).bit;
25+
26+
if (config.value.port == '-1') {
27+
features.unset(gpsBit);
28+
} else {
29+
features.set(gpsBit);
30+
}
31+
32+
serialPortHelper.set(config.value.port, 'GPS', config.value.baud);
33+
mspHelper.saveSerialPorts(function () {
34+
features.execute(callback);
35+
});
36+
break;
37+
case 'gpsProtocol':
38+
mspHelper.setSetting('gps_provider', config.value, callback);
39+
break;
2540
default:
2641
callback();
2742
break;

js/wizard_ui_bindings.js

+57
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,68 @@
22

33
const mspHelper = require('./msp/MSPHelper');
44
const serialPortHelper = require('./serialPortHelper');
5+
const FC = require('./fc');
56

67
const wizardUiBindings = (function () {
78

89
let self = {};
910

11+
self.gps = function ($context) {
12+
mspHelper.loadFeatures(mspHelper.loadSerialPorts(function () {
13+
14+
let $port = $('#wizard-gps-port');
15+
let $baud = $('#wizard-gps-baud');
16+
let $protocol = $('#wizard-gps-protocol');
17+
18+
let ports = serialPortHelper.getPortIdentifiersForFunction('GPS');
19+
20+
let currentPort = null;
21+
22+
if (ports.length == 1) {
23+
currentPort = ports[0];
24+
}
25+
26+
let availablePorts = serialPortHelper.getPortList();
27+
$port.append('<option value="-1">None</option>');
28+
for (let i = 0; i < availablePorts.length; i++) {
29+
let port = availablePorts[i];
30+
$port.append('<option value="' + port.identifier + '">' + port.displayName + '</option>');
31+
}
32+
33+
serialPortHelper.getBauds('SENSOR').forEach(function (baud) {
34+
$baud.append('<option value="' + baud + '">' + baud + '</option>');
35+
});
36+
37+
let gpsProtocols = FC.getGpsProtocols();
38+
for (let i = 0; i < gpsProtocols.length; i++) {
39+
$protocol.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>');
40+
}
41+
42+
if (currentPort !== null) {
43+
$port.val(currentPort);
44+
} else {
45+
$port.val(-1);
46+
}
47+
48+
$port.on('change', function () {
49+
let port = $(this).val();
50+
51+
let portConfig = serialPortHelper.getPortByIdentifier(currentPort);
52+
$baud.val(portConfig.sensors_baudrate);
53+
if (port == -1) {
54+
$('#wizard-gps-baud-container').hide();
55+
$('#wizard-gps-protocol-container').hide();
56+
$baud.val(serialPortHelper.getRuleByName('GPS').defaultBaud);
57+
} else {
58+
$('#wizard-gps-baud-container').show();
59+
$('#wizard-gps-protocol-container').show();
60+
}
61+
}).trigger('change');
62+
63+
}));
64+
65+
};
66+
1067
self.receiver = function ($content) {
1168

1269
mspHelper.loadSerialPorts(function () {

wizard/gps.html

+14-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
<h2>GPS wizard</h2>
1+
<h2>GPS wizard</h2>
2+
<p>
3+
Configure GPS and port. If you unsure about serial port or protocol, click `Skip` to go to the next page.
4+
You can change those settings later with the configurator UI. If no GPS installed, choose <b>None</b>.
5+
</p>
6+
<div>
7+
<label for="wizard-gps-port">GPS Serial Port</label><select id="wizard-gps-port"></select>
8+
</div>
9+
<div style="display: none;" id="wizard-gps-baud-container">
10+
<label for="wizard-gps-baud">GPS Baud Rate</label><select id="wizard-gps-baud"></select>
11+
</div>
12+
<div style="display: none;" id="wizard-gps-protocol-container">
13+
<label for="wizard-gps-protocol">GPS Protocol</label><select id="wizard-gps-protocol"></select>
14+
</div>

0 commit comments

Comments
 (0)