Skip to content

Commit

Permalink
Hide telemetry protocols for CRSF, FPORT and GHST
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Jan 5, 2024
1 parent adf380c commit 16f28ef
Show file tree
Hide file tree
Showing 3 changed files with 33 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 @@ -7344,6 +7344,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": "This Radio Protocol has Telemetry 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 @@ -188,6 +188,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) {
$('select[name="telemetryProtocols"] option:selected').val('-1');
}

$('select[name="telemetryProtocols"]').select2({
templateSelection: function (data) {
if (data.id === '-1') {
return hasTelemetryEnabledByDefault ? i18n.getMessage('firmwareFlasherOptionLabelTelemetryProtocolIncluded') : '[None]';
}

return data.text;
},
});
}

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

toggleTelemetryProtocolInfo();
}

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

toggleTelemetryProtocolInfo();
});

$('select[name="board"]').on('change', function() {
Expand Down
1 change: 1 addition & 0 deletions src/tabs/firmware_flasher.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
<strong i18n="firmwareFlasherBuildTelemetryProtocols"></strong>
<div id="telemetryProtocolInfo" class="build-options-wrapper">
<select id="telemetryProtocols" name="telemetryProtocols" class="select2">
<option value="-1">placeholder</option>
</select>
<div class="helpicon cf_tip_wide" i18n_title="firmwareFlasherTelemetryProtocolDescription"></div>
</div>
Expand Down

0 comments on commit 16f28ef

Please sign in to comment.