Skip to content

Commit

Permalink
Hide unused OSD video mode
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Jan 18, 2024
1 parent d3e51c0 commit 203e5d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,10 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
buffer.push8(FC.BEEPER_CONFIG.dshotBeaconTone);
buffer.push32(FC.BEEPER_CONFIG.dshotBeaconConditions.getDisabledMask());
break;
case MSPCodes.MSP_SET_OSD_CANVAS:
buffer.push8(OSD.data.VIDEO_COLS['HD']);
buffer.push8(OSD.data.VIDEO_ROWS['HD']);
break;
case MSPCodes.MSP_SET_MIXER_CONFIG:
buffer.push8(FC.MIXER_CONFIG.mixer);
buffer.push8(FC.MIXER_CONFIG.reverseMotorDir);
Expand Down
16 changes: 15 additions & 1 deletion src/js/tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import inflection from "inflection";
import { checkChromeRuntimeError } from "../utils/common";
import debounce from "lodash.debounce";
import $ from 'jquery';
import { mspHelper } from "../msp/MSPHelper";

const FONT = {};
const SYM = {};
Expand Down Expand Up @@ -2780,6 +2781,15 @@ osd.initialize = function(callback) {
// video mode
const $videoTypes = $('.video-types').empty();
for (let i = 0; i < OSD.constants.VIDEO_TYPES.length; i++) {
// Remove SD or HD option depending on the build
if (FC.CONFIG.buildOptions) {
if ((OSD.constants.VIDEO_TYPES[i] === 'PAL' || OSD.constants.VIDEO_TYPES[i] === 'NTSC') && !FC.CONFIG.buildOptions.includes('USE_OSD_SD')) {
continue;
}
if (OSD.constants.VIDEO_TYPES[i] === 'HD' && !FC.CONFIG.buildOptions.includes('USE_OSD_HD')) {
continue;
}
}
const type = OSD.constants.VIDEO_TYPES[i];
const videoFormatOptionText = i18n.getMessage(`osdSetupVideoFormatOption${inflection.camelize(type.toLowerCase())}`);
const $checkbox = $('<label/>')
Expand Down Expand Up @@ -3354,7 +3364,11 @@ osd.initialize = function(callback) {
});

$('a.save').click(function() {
MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
if (OSD.data.video_system === 'HD' && FC.CONFIG.buildOptions.includes('USE_OSD_HD')) {
MSP.promise(MSPCodes.MSP_SET_OSD_CANVAS, mspHelper.crunch(MSPCodes.MSP_SET_OSD_CANVAS));
} else {
MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
}
gui_log(i18n.getMessage('osdSettingsSaved'));
const oldText = $(this).html();
$(this).html(i18n.getMessage('osdButtonSaved'));
Expand Down

0 comments on commit 203e5d0

Please sign in to comment.