Skip to content

Commit

Permalink
Hide telemetry protocols for CRSF, FPORT and GHST (betaflight#3726)
Browse files Browse the repository at this point in the history
* Hide telemetry protocols for CRSF, FPORT and GHST

* Add placeholder

* Update message

* Fix sonar
  • Loading branch information
haslinghuis authored and chmelevskij committed Apr 27, 2024
1 parent fa5aff4 commit f4a15eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7338,6 +7338,9 @@
"firmwareFlasherTelemetryProtocolDescription": {
"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."
},
"firmwareFlasherOptionLabelTelemetryProtocolIncluded": {
"message": "Automatically Included"
},
"firmwareFlasherOptionsDescription": {
"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."
},
Expand Down
29 changes: 29 additions & 0 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,31 @@ firmware_flasher.initialize = function (callback) {
});
}

function toggleTelemetryProtocolInfo() {
const radioProtocol = $('select[name="radioProtocols"] option:selected').val();
const hasTelemetryEnabledByDefault = [
'USE_SERIALRX_CRSF',
'USE_SERIALRX_FPORT',
'USE_SERIALRX_GHST',
].includes(radioProtocol);

$('select[name="telemetryProtocols"]').attr('disabled', hasTelemetryEnabledByDefault);

if (hasTelemetryEnabledByDefault) {
if ($('select[name="telemetryProtocols"] option[value="-1"]').length === 0) {
$('select[name="telemetryProtocols"]').prepend($('<option>', {
value: '-1',
selected: 'selected',
text: i18n.getMessage('firmwareFlasherOptionLabelTelemetryProtocolIncluded'),
}));
} else {
$('select[name="telemetryProtocols"] option:first').attr('selected', 'selected').text(i18n.getMessage('firmwareFlasherOptionLabelTelemetryProtocolIncluded'));
}
} else if ($('select[name="telemetryProtocols"] option[value="-1"]').length) {
$('select[name="telemetryProtocols"] option:first').remove();
}
}

function buildOptions(data) {
if (!navigator.onLine) {
return;
Expand All @@ -208,6 +233,8 @@ firmware_flasher.initialize = function (callback) {
if (!self.validateBuildKey()) {
preselectRadioProtocolFromStorage();
}

toggleTelemetryProtocolInfo();
}

function preselectRadioProtocolFromStorage() {
Expand Down Expand Up @@ -435,6 +462,8 @@ firmware_flasher.initialize = function (callback) {
if (selectedProtocol) {
setConfig({"ffRadioProtocol" : selectedProtocol});
}

toggleTelemetryProtocolInfo();
});

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

0 comments on commit f4a15eb

Please sign in to comment.