Skip to content

Commit 03b0233

Browse files
authored
Hide telemetry protocols for CRSF, FPORT and GHST (#3726)
* Hide telemetry protocols for CRSF, FPORT and GHST * Add placeholder * Update message * Fix sonar
1 parent 56ceb48 commit 03b0233

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7338,6 +7338,9 @@
73387338
"firmwareFlasherTelemetryProtocolDescription": {
73397339
"message": "Select the telemetry protocol you would like included in this build. Note this is a drop down, but only one item maybe selected. There are also some telemetry protocols that will be enabled, regardless of your selection here based on the radio protocol selected, e.g. CRSF."
73407340
},
7341+
"firmwareFlasherOptionLabelTelemetryProtocolIncluded": {
7342+
"message": "Automatically Included"
7343+
},
73417344
"firmwareFlasherOptionsDescription": {
73427345
"message": "Select the generic options you would like included in this build. Note this is a drop down, and multiple items maybe selected. Such items as fixes, e.g. AKK VTX, are included here."
73437346
},

src/js/tabs/firmware_flasher.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,31 @@ firmware_flasher.initialize = function (callback) {
195195
});
196196
}
197197

198+
function toggleTelemetryProtocolInfo() {
199+
const radioProtocol = $('select[name="radioProtocols"] option:selected').val();
200+
const hasTelemetryEnabledByDefault = [
201+
'USE_SERIALRX_CRSF',
202+
'USE_SERIALRX_FPORT',
203+
'USE_SERIALRX_GHST',
204+
].includes(radioProtocol);
205+
206+
$('select[name="telemetryProtocols"]').attr('disabled', hasTelemetryEnabledByDefault);
207+
208+
if (hasTelemetryEnabledByDefault) {
209+
if ($('select[name="telemetryProtocols"] option[value="-1"]').length === 0) {
210+
$('select[name="telemetryProtocols"]').prepend($('<option>', {
211+
value: '-1',
212+
selected: 'selected',
213+
text: i18n.getMessage('firmwareFlasherOptionLabelTelemetryProtocolIncluded'),
214+
}));
215+
} else {
216+
$('select[name="telemetryProtocols"] option:first').attr('selected', 'selected').text(i18n.getMessage('firmwareFlasherOptionLabelTelemetryProtocolIncluded'));
217+
}
218+
} else if ($('select[name="telemetryProtocols"] option[value="-1"]').length) {
219+
$('select[name="telemetryProtocols"] option:first').remove();
220+
}
221+
}
222+
198223
function buildOptions(data) {
199224
if (!navigator.onLine) {
200225
return;
@@ -208,6 +233,8 @@ firmware_flasher.initialize = function (callback) {
208233
if (!self.validateBuildKey()) {
209234
preselectRadioProtocolFromStorage();
210235
}
236+
237+
toggleTelemetryProtocolInfo();
211238
}
212239

213240
function preselectRadioProtocolFromStorage() {
@@ -435,6 +462,8 @@ firmware_flasher.initialize = function (callback) {
435462
if (selectedProtocol) {
436463
setConfig({"ffRadioProtocol" : selectedProtocol});
437464
}
465+
466+
toggleTelemetryProtocolInfo();
438467
});
439468

440469
$('select[name="board"]').on('change', function() {

0 commit comments

Comments
 (0)