Skip to content

Commit

Permalink
Adding UI in OSD tab to changes CLI values
Browse files Browse the repository at this point in the history
  • Loading branch information
MedlinDrone committed Nov 13, 2023
1 parent 6fe7b76 commit 72c2e99
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 2 deletions.
47 changes: 46 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 @@ -6178,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 @@ -6327,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
50 changes: 49 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 @@ -2208,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 @@ -2232,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 @@ -2324,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 @@ -2444,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 @@ -2704,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 @@ -2822,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

0 comments on commit 72c2e99

Please sign in to comment.