Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Configurator support for new OSD feature Camera Angle Reference #3570

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5110,6 +5110,9 @@
"osdSetupAlarmsTitle": {
"message": "Alarms"
},
"osdSetupCarTitle": {
"message": "Camera Angle Reference"
},
"osdSetupStatsTitle": {
"message": "Post Flight Statistics"
},
Expand Down Expand Up @@ -5290,6 +5293,20 @@
"osdDescElementHorizonSidebars": {
"message": "Sidebars around artificial horizon indicator"
},
"osdTextElementCameraAngleReference": {
"message": "Camera Angle Reference",
"description": "One of the elements of the OSD"
},
"osdDescElementCameraAngleReference": {
"message": "Camera angle reference for flying with FPV tilt gimbal"
},
"osdTextElementCameraAngleReferenceSidebar": {
"message": "Camera Angle Reference Sidebar",
"description": "One of the elements of the OSD"
},
"osdDescElementCameraAngleReferenceSidebar": {
"message": "Sidebar for Camera angle reference"
},
"osdTextElementCurrentDraw": {
"message": "Battery current draw",
"description": "One of the elements of the OSD"
Expand Down Expand Up @@ -6164,7 +6181,46 @@
"message": "Altitude",
"description": "Text of the altitude alarm"
},

"osdCarOptionScale": {
"message": "Scale",
"description": "Scale"
},
"osdCarOptionWidth": {
"message": "Width",
"description": "Width"
},
"osdCarOptionChannel": {
"message": "Channel",
"description": "Channel"
},
"osdCarOptionDots": {
"message": "Dots",
"description": "Dots"
},
"osdCarOptionSbarScale": {
"message": "Sidebar Scale",
"description": "Sidebar Scale"
},
"osdCarOptionSbarLow": {
"message": "Sidebar Angle 1/5",
"description": "Sidebar Scale"
},
"osdCarOptionSbarMidLow": {
"message": "Sidebar Angle 2/5",
"description": "Sidebar Scale"
},
"osdCarOptionSbarMid": {
"message": "Sidebar Angle 3/5",
"description": "Sidebar Scale"
},
"osdCarOptionSbarMidHigh": {
"message": "Sidebar Angle 4/5",
"description": "Sidebar Scale"
},
"osdCarOptionSbarHigh": {
"message": "Sidebar Angle 5/5",
"description": "Sidebar Scale"
},
"osdWarningTextArmingDisabled": {
"message": "Arming disabled",
"description": "One of the warnings that can be selected to be shown in the OSD"
Expand Down Expand Up @@ -6313,6 +6369,9 @@
"osdSectionHelpAlarms": {
"message": "Set the thresholds used for OSD elements with alarm states."
},
"osdSectionHelpCar": {
"message": "Set the Camera Angle Reference parameter values"
},
"osdSectionHelpStats": {
"message": "Set the values dispalyed on the post flight statistics screen."
},
Expand Down
24 changes: 24 additions & 0 deletions src/css/tabs/osd.less
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,30 @@
font-weight: normal;
}
}
.car {
label {
display: block;
width: 100%;
border-bottom: 1px solid var(--subtleAccent);
margin-top: 5px;
padding-bottom: 5px;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
}
input {
width: 55px;
padding-left: 3px;
height: 18px;
line-height: 20px;
text-align: left;
border-radius: 3px;
margin-right: 11px;
font-size: 11px;
font-weight: normal;
}
}
.grid-row {
justify-content: flex-start;
gap: 7px;
Expand Down
12 changes: 12 additions & 0 deletions src/js/VirtualFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ const VirtualFC = {
alt: { display_name: i18n.getMessage('osdTimerAlarmOptionAltitude'), value: 0 },
time: { display_name: 'Minutes', value: 0 },
};
virtualOSD.data.car = {
scale: { display_name: i18n.getMessage('osdCarOptionScale'), value: 0 },
width: { display_name: i18n.getMessage('osdCarOptionWidth'), value: 0 },
channel: { display_name: i18n.getMessage('osdCarOptionChannel'), value: 0 },
dots: { display_name: i18n.getMessage('osdCarOptionDots'), value: 0 },
sbar_scale: { display_name: i18n.getMessage('osdCarOptionSbarScale'), value: 0 },
sbar_low: { display_name: i18n.getMessage('osdCarOptionSbarLow'), value: 0 },
sbar_mid_low: { display_name: i18n.getMessage('osdCarOptionSbarMidLow'), value: 0 },
sbar_mid: { display_name: i18n.getMessage('osdCarOptionSbarMid'), value: 0 },
sbar_mid_high: { display_name: i18n.getMessage('osdCarOptionSbarMidHigh'), value: 0 },
sbar_high: { display_name: i18n.getMessage('osdCarOptionSbarHigh'), value: 0 },
};
},
};

Expand Down
70 changes: 69 additions & 1 deletion src/js/tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ OSD.initData = function() {
video_system: null,
unit_mode: null,
alarms: [],
car: [],
statItems: [],
warnings: [],
displayItems: [],
Expand Down Expand Up @@ -1536,6 +1537,24 @@ OSD.loadDisplayFields = function() {
positionable: true,
preview: '1:23.456',
},
CAM_ANGLE_REFERENCE: {
name: 'CAM_ANGLE_REFERENCE',
text: 'osdTextElementCameraAngleReference',
desc: 'osdDescElementCameraAngleReference',
defaultPosition: -1,
draw_order: 555,
positionable: true,
preview: '***CAR***',
},
CAM_ANGLE_REFERENCE_SBAR: {
name: 'CAM_ANGLE_REFERENCE_SBAR',
text: 'osdTextElementCameraAngleReferenceSidebar',
desc: 'osdDescElementCameraAngleReferenceSidebar',
defaultPosition: -1,
draw_order: 560,
positionable: true,
preview: '***SBR***||',
},
};
};

Expand Down Expand Up @@ -1970,6 +1989,8 @@ OSD.chooseFields = function() {
F.GPS_LAP_TIME_CURRENT,
F.GPS_LAP_TIME_PREVIOUS,
F.GPS_LAP_TIME_BEST3,
F.CAM_ANGLE_REFERENCE,
F.CAM_ANGLE_REFERENCE_SBAR,
]);
}

Expand Down Expand Up @@ -2188,6 +2209,7 @@ OSD.msp = {
result.push16(OSD.data.alarms.cap.value);
result.push16(0); // This value is unused by the firmware with configurable timers
result.push16(OSD.data.alarms.alt.value);


let warningFlags = 0;
for (let i = 0; i < OSD.data.warnings.length; i++) {
Expand All @@ -2212,6 +2234,19 @@ OSD.msp = {
result.push8(OSD.data.parameters.cameraFrameWidth);
result.push8(OSD.data.parameters.cameraFrameHeight);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
result.push8(OSD.data.car.scale.value);
result.push8(OSD.data.car.width.value);
result.push8(OSD.data.car.channel.value);
result.push8(OSD.data.car.dots.value);

result.push8(OSD.data.car.sbar_scale.value);
result.push8(OSD.data.car.sbar_low.value);
result.push8(OSD.data.car.sbar_mid_low.value);
result.push8(OSD.data.car.sbar_mid.value);
result.push8(OSD.data.car.sbar_mid_high.value);
result.push8(OSD.data.car.sbar_high.value);
}
}
return result;
},
Expand Down Expand Up @@ -2304,7 +2339,7 @@ OSD.msp = {
d.alarms['alt'] = { display_name: i18n.getMessage('osdTimerAlarmOptionAltitude'), value: view.readU16() };
}
}

d.state = {};
d.state.haveSomeOsd = (d.flags !== 0);
d.state.haveMax7456Configured = bit_check(d.flags, 4);
Expand Down Expand Up @@ -2424,6 +2459,22 @@ OSD.msp = {
d.parameters.cameraFrameHeight = view.readU8();
}

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
d.car = {};
d.car['scale'] = { display_name: i18n.getMessage('osdCarOptionScale'), value: view.readU8() };
d.car['width'] = { display_name: i18n.getMessage('osdCarOptionWidth'), value: view.readU8() };
d.car['channel'] = { display_name: i18n.getMessage('osdCarOptionChannel'), value: view.readU8() };
d.car['dots'] = { display_name: i18n.getMessage('osdCarOptionDots'), value: view.readU8() };

d.car['sbar_scale'] = { display_name: i18n.getMessage('osdCarOptionSbarScale'), value: view.readU8() };
d.car['sbar_low'] = { display_name: i18n.getMessage('osdCarOptionSbarLow'), value: view.readU8() };
d.car['sbar_mid_low'] = { display_name: i18n.getMessage('osdCarOptionSbarMidLow'), value: view.readU8() };
d.car['sbar_mid'] = { display_name: i18n.getMessage('osdCarOptionSbarMid'), value: view.readU8() };
d.car['sbar_mid_high'] = { display_name: i18n.getMessage('osdCarOptionSbarMidHigh'), value: view.readU8() };
d.car['sbar_high'] = { display_name: i18n.getMessage('osdCarOptionSbarHigh'), value: view.readU8() };

}

this.processOsdElements(d, itemsPositionsRead);

OSD.updateDisplaySize();
Expand Down Expand Up @@ -2684,6 +2735,7 @@ osd.initialize = function(callback) {
$('.units-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpUnits'));
$('.timers-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpTimers'));
$('.alarms-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpAlarms'));
$('.car-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpCar'));
$('.stats-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpStats'));
$('.warnings-container div.cf_tip').attr('title', i18n.getMessage('osdSectionHelpWarnings'));

Expand Down Expand Up @@ -2802,6 +2854,22 @@ osd.initialize = function(callback) {
$alarms.append($input);
}

// Camera Angle Reference
$('.car-container').show();
const $car = $('.car').empty();
for (const k in OSD.data.car) {
const car = OSD.data.car[k];
const carInput = $(`<input name="car" type="number" id="${k}"/>${car.display_name}</label>`);
carInput.val(car.value);
carInput.focusout(function() {
OSD.data.car[$(this)[0].id].value = $(this)[0].value;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
.then(updateOsdView);
});
const $input = $('<label/>').append(carInput);
$car.append($input);
}

// Timers
$('.timers-container').show();
const $timers = $('#timer-fields').empty();
Expand Down
8 changes: 8 additions & 0 deletions src/tabs/osd.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ <h1 class="tab_title">
<div class="alarms"></div>
</div>
</div>
<div class="gui_box grey car-container requires-osd-feature" style="display:none;">
<div class="gui_box_titlebar cf_tip">
<div class="spacer_box_title" i18n="osdSetupCarTitle"></div>
</div>
<div class="spacer_box">
<div class="car"></div>
</div>
</div>
<div class="gui_box grey warnings-container requires-osd-feature" style="display:none;">
<div class="gui_box_titlebar cf_tip" style="margin-bottom: 0px;">
<div class="spacer_box_title">
Expand Down