Skip to content

Commit

Permalink
Changes to use the MSP Displayport setting. Integrated changes from g…
Browse files Browse the repository at this point in the history
…eoffsim PR iNavFlight#1589
  • Loading branch information
Jeff Hendrix authored and Jeff Hendrix committed Oct 3, 2022
1 parent ffee3d3 commit 3d2d80b
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 49 deletions.
6 changes: 6 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3597,6 +3597,12 @@
"osdSettingCRSF_LQ_FORMAT_HELP": {
"message": "TYPE1 shows LQ% as used by TBS hardware. TYPE2 shows RF Profile Modes (2=150Hz, 1=50Hz, 0=4Hz update rates) and LQ % [0..100%]. Tracer shows RFMode 1 (1=250Hz) and LQ % [0..100%]."
},
"osd_video_show_guides": {
"message": "Show preview guides"
},
"osd_video_HELP": {
"message": "For HD keep within the red lines for 4:3, HDZero keep within the blue box for a higher refresh rate, AUTO/PAL the green line is NTSC limit ."
},
"osd_dji_HD_FPV": {
"message" : "DJI HD FPV"
},
Expand Down
60 changes: 50 additions & 10 deletions src/css/tabs/osd.css
Original file line number Diff line number Diff line change
Expand Up @@ -430,26 +430,26 @@ button {
left: calc(50% - 197px);
}

.tab-osd .preview_hd {
.tab-osd .preview_hdzero {
width: 600px !important;
left: calc(50% - 317px) !important;
}

.tab-osd .hd_43_left {
border-left: 1px solid red;
.tab-osd .hdzero_43_left {
border-left: 2px solid red;
position: absolute;
left: 60px;
height: calc(100% - 27px);
}

.tab-osd .hd_43_right {
border-right: 1px solid red;
.tab-osd .hdzero_43_right {
border-right: 2px solid red;
position: absolute;
right: 60px;
height: calc(100% - 27px);
}

.tab-osd .preview_hd_side {
.tab-osd .preview_hdzero_side {
width: calc(50% - 317px) !important;
}

Expand All @@ -459,23 +459,63 @@ button {
}

.tab-osd .dji_hd_43_left {
border-left: 1px solid red;
border-left: 2px solid red;
position: absolute;
left: 72px;
left: 84px;
height: calc(100% - 27px);
}

.tab-osd .dji_hd_43_right {
border-right: 1px solid red;
border-right: 2px solid red;
position: absolute;
right: 72px;
right: 84px;
height: calc(100% - 27px);
}

.tab-osd .preview_dji_hd_side {
width: calc(50% - 377px) !important;
}

.tab-osd .hd_3016_top {
border-top: 2px solid blue;
position: absolute;
top: 46px;
left: 120px;
width: 360px;
}

.tab-osd .hd_3016_bottom {
border-bottom: 2px solid blue;
position: absolute;
bottom: 18px;
left: 120px;
width: 360px;
}

.tab-osd .hd_3016_left {
border-left: 2px solid blue;
position: absolute;
top: 46px;
left: 120px;
height: 288px;
}

.tab-osd .hd_3016_right {
border-right: 2px solid blue;
position: absolute;
top: 46px;
right: 120px;
height: 288px;
}

.tab-osd .ntsc_bottom {
border-bottom: 2px solid green;
position: absolute;
bottom: 54px;
left: 0px;
width: 100%;
}

.tab-osd .preview {
/* please don't copy the generic background image from another project
* and replace the one that @nathantsoi took :)
Expand Down
28 changes: 19 additions & 9 deletions tabs/osd.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
</div>
<div class="display-layout">
<div class="col right">
<div class="left_43_margin"></div>
<div class="right_43_margin"></div>
<div class="preview">
</div>
<div class="hd_43_margin_left"></div>
<div class="hd_43_margin_right"></div>
<div class="hd_3016_box_top"></div>
<div class="hd_3016_box_bottom"></div>
<div class="hd_3016_box_left"></div>
<div class="hd_3016_box_right"></div>
<div class="pal_ntsc_box_bottom"></div>
<div class="preview"></div>
</div>
</div>
</div>
Expand All @@ -46,6 +50,12 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
<div class="spacer_box">
<div class="video-types"></div>
</div>
<div class="spacer_box settings">
<div for="osd_video_show_guides" class="helpicon cf_tip" data-i18n_title="osd_video_HELP"></div>
<label id="videoGuides">
<span data-i18n="osd_video_show_guides"></span>
</label>
</div>
</div>
<div class="gui_box grey settings-container">
<div class="gui_box_titlebar">
Expand Down Expand Up @@ -82,12 +92,12 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
<div for="plusCodeShort" class="helpicon cf_tip" data-i18n_title="osdSettingPLUS_CODE_SHORT_HELP"></div>
<label>
<select id="plusCodeShort" class="update_preview" data-setting="osd_plus_code_short" data-live="true"></select>
<span data-i18n="osd_plus_code_short"></span>
<span data-i18n="osd_plus_code_short"></span>
</label>
<div for="rpmPrecision" class="helpicon cf_tip" data-i18n_title="osd_esc_rpm_precision_help"></div>
<label>
<select id="rpmPrecision" class="update_preview" data-setting="osd_esc_rpm_precision" data-live="true"></select>
<span data-i18n="osd_esc_rpm_precision"></span>
<span data-i18n="osd_esc_rpm_precision"></span>
</label>
<label>
<select class="update_preview" data-setting="osd_crosshairs_style" data-live="true"></select>
Expand Down Expand Up @@ -210,7 +220,7 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
</label>
</div>
</div>
<div class="gui_box grey dji-hd-container">
<div class="gui_box grey dji-hd-container" id="dji_settings">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="osd_dji_HD_FPV"></div>
</div>
Expand All @@ -231,7 +241,7 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
<span data-i18n="osd_dji_GPS_source"></span>
</label>
<label>
<select data-setting="dji_message_speed_source" data-live="true"></select>
<select data-setting="dji_message_speed_source" data-live="true"></select>
<span data-i18n="osd_dji_speed_source"></span>
</label>
<label class="djiCraftNameElements">
Expand Down Expand Up @@ -281,7 +291,7 @@ <h1 class="tab_title" data-i18n="tabOSD"></h1>
<span data-i18n="osdSwitchInd3"></span>
</label>
</div>
</div>
</div>
</div>
<div id="fontmanagercontent" style="display:none; width:712px;">
<div class="font-picker" style="margin-bottom: 10px;">
Expand Down
90 changes: 60 additions & 30 deletions tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ OSD.initData = function () {
items: [],
groups: {},
preview: [],
isDjiHdFpv: false
isDjiHdFpv: false,
isMspDisplay: false
};
};

Expand Down Expand Up @@ -1990,6 +1991,9 @@ OSD.reload = function(callback) {
if(port.functions.includes('DJI_FPV')) {
OSD.data.isDjiHdFpv = true;
}
if(port.functions.includes('MSP_DISPLAYPORT')) {
OSD.data.isMspDisplay = true;
}
});
});

Expand Down Expand Up @@ -2045,7 +2049,6 @@ OSD.updateDisplaySize = function () {

// set the new video type and cols per line
FONT.constants.SIZES.LINE = OSD.constants.VIDEO_COLS[video_type];
OSD.constants.VIDEO_TYPES[OSD.data.video_system] = video_type;

// set the new display size
OSD.data.display_size = {
Expand All @@ -2071,15 +2074,12 @@ OSD.updateDisplaySize = function () {
$('.third_left').toggleClass('preview_dji_hd_side', video_type == 'DJIWTF')
$('.preview').toggleClass('preview_dji_hd cut43_left', video_type == 'DJIWTF')
$('.third_right').toggleClass('preview_dji_hd_side', video_type == 'DJIWTF')
$('.left_43_margin').toggleClass('dji_hd_43_left', video_type == 'DJIWTF')
$('.right_43_margin').toggleClass('dji_hd_43_right', video_type == 'DJIWTF')

// set the preview size based on the video type
$('.third_left').toggleClass('preview_hd_side', (video_type == 'HDZERO'))
$('.preview').toggleClass('preview_hd cut43_left', (video_type == 'HDZERO'))
$('.third_right').toggleClass('preview_hd_side', (video_type == 'HDZERO'))
$('.left_43_margin').toggleClass('hd_43_left', (video_type == 'HDZERO'))
$('.right_43_margin').toggleClass('hd_43_right', (video_type == 'HDZERO'))
$('.third_left').toggleClass('preview_hdzero_side', (video_type == 'HDZERO'))
$('.preview').toggleClass('preview_hdzero cut43_left', (video_type == 'HDZERO'))
$('.third_right').toggleClass('preview_hdzero_side', (video_type == 'HDZERO'))
OSD.GUI.updateGuidesView($('#videoGuides').find('input').is(':checked'));
};

OSD.saveAlarms = function(callback) {
Expand Down Expand Up @@ -2365,29 +2365,28 @@ OSD.GUI.checkAndProcessSymbolPosition = function(pos, charCode) {
OSD.GUI.updateVideoMode = function() {
// video mode
var $videoTypes = $('.video-types').empty();
for (var i = 0; i < OSD.constants.VIDEO_TYPES.length - 2; i++) {

$videoTypes.append(
$('<label/>')
.append($('<input name="video_system" type="radio"/>' + OSD.constants.VIDEO_TYPES[i] + '</label>')
.prop('checked', i === OSD.data.preferences.video_system)
.data('type', i)
)
);
}

// Add HD modes if MSP Displayport is selected
var isHdOsd = false;
if (!OSD.data.isDjiHdFpv) {
$('#dji_settings').hide();
}

$.each(SERIAL_CONFIG.ports, function(index, port){
if(port.functions.includes('MSP_DISPLAYPORT')) {
isHdOsd = true;
if (OSD.data.isMspDisplay) {
if (OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] != 'HDZERO') {
OSD.data.preferences.video_system = OSD.constants.VIDEO_TYPES.indexOf('HDZERO');
OSD.updateDisplaySize();
OSD.GUI.saveConfig();
}
});

if (isHdOsd) {
for (var i = OSD.constants.VIDEO_TYPES.length - 2; i < OSD.constants.VIDEO_TYPES.length; i++) {
} else {
if (OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'HDZERO' || OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'DJIWTF') {
OSD.data.preferences.video_system = OSD.constants.VIDEO_TYPES.indexOf('AUTO')
OSD.updateDisplaySize();
OSD.GUI.saveConfig();
}
}

for (var i = 0; i < OSD.constants.VIDEO_TYPES.length; i++) {
if ((OSD.constants.VIDEO_TYPES[i] != 'HDZERO' && OSD.constants.VIDEO_TYPES[i] != 'DJIWTF') || OSD.data.isMspDisplay)
{
$videoTypes.append(
$('<label/>')
.append($('<input name="video_system" type="radio"/>' + OSD.constants.VIDEO_TYPES[i] + '</label>')
Expand Down Expand Up @@ -2535,6 +2534,7 @@ OSD.GUI.updateFields = function() {
// Ensure the element is inside the viewport, at least partially.
// In that case move it to the very first row/col, otherwise there's
// no way to reposition items that are outside the viewport.
OSD.msp.helpers.calculate.coords(itemData);
if (itemData.x > OSD.data.display_size.x || itemData.y > OSD.data.display_size.y) {
itemData.x = itemData.y = itemData.position = 0;
}
Expand Down Expand Up @@ -2569,10 +2569,21 @@ OSD.GUI.updateFields = function() {
}
}

if ($('#videoGuidesToggle').length == false) {
$('#videoGuides').prepend(
$('<input id="videoGuidesToggle" type="checkbox" class="toggle" />')
.attr('checked', false)
.on('change', function () {
OSD.GUI.updateGuidesView(this.checked);
OSD.GUI.updatePreviews();
})
);
}

if ($('#djiUnsupportedElementsToggle').length == false) {
$('#djiUnsupportedElements').prepend(
$('<input id="djiUnsupportedElementsToggle" type="checkbox" class="toggle" />')
.attr('checked', OSD.data.isDjiHdFpv)
.attr('checked', OSD.data.isDjiHdFpv && !OSD.data.isMspDisplay)
.on('change', function () {
OSD.GUI.updateDjiView(this.checked);
OSD.GUI.updatePreviews();
Expand Down Expand Up @@ -2627,6 +2638,23 @@ OSD.GUI.updateDjiMessageElements = function(on) {
OSD.GUI.removeBottomLines();
};

OSD.GUI.updateGuidesView = function(on) {
isHdZero = OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'HDZERO';
$('.hd_43_margin_left').toggleClass('hdzero_43_left', (isHdZero && on))
$('.hd_43_margin_right').toggleClass('hdzero_43_right', (isHdZero && on))
$('.hd_3016_box_top').toggleClass('hd_3016_top', (isHdZero && on))
$('.hd_3016_box_bottom').toggleClass('hd_3016_bottom', (isHdZero && on))
$('.hd_3016_box_left').toggleClass('hd_3016_left', (isHdZero && on))
$('.hd_3016_box_right').toggleClass('hd_3016_right', (isHdZero && on))

isDJIWTF = OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'DJIWTF';
$('.hd_43_margin_left').toggleClass('dji_hd_43_left', (isDJIWTF && on))
$('.hd_43_margin_right').toggleClass('dji_hd_43_right', (isDJIWTF && on))

isPAL = OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'PAL' || OSD.constants.VIDEO_TYPES[OSD.data.preferences.video_system] == 'AUTO';
$('.pal_ntsc_box_bottom').toggleClass('ntsc_bottom', (isPAL && on))
};

OSD.GUI.updateDjiView = function(on) {
if (on) {
$(OSD.DjiElements.emptyGroups).each(function(index, groupName) {
Expand Down Expand Up @@ -2878,6 +2906,7 @@ OSD.GUI.updateAll = function() {
layouts.on('change', function() {
OSD.updateSelectedLayout(parseInt(layouts.val()));
OSD.GUI.updateFields();
OSD.GUI.updateGuidesView($('#videoGuides').find('input').is(':checked'));
OSD.GUI.updateDjiView($('#djiUnsupportedElements').find('input').is(':checked'));
OSD.GUI.updatePreviews();
});
Expand All @@ -2893,7 +2922,8 @@ OSD.GUI.updateAll = function() {
OSD.GUI.updateUnits();
OSD.GUI.updateFields();
OSD.GUI.updatePreviews();
OSD.GUI.updateDjiView(OSD.data.isDjiHdFpv);
OSD.GUI.updateGuidesView(false);
OSD.GUI.updateDjiView(OSD.data.isDjiHdFpv && !OSD.data.isMspDisplay);
};

OSD.GUI.update = function() {
Expand Down

0 comments on commit 3d2d80b

Please sign in to comment.