mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 16:55:24 +03:00
Merge pull request #631 from DanNixon/configurable_osd_warnings
Configurable OSD warnings
This commit is contained in:
commit
a29fda8122
3 changed files with 162 additions and 9 deletions
|
@ -2344,6 +2344,9 @@
|
|||
"osdSetupCraftNameTitle": {
|
||||
"message": "Craft Name"
|
||||
},
|
||||
"osdSetupWarningsTitle": {
|
||||
"message": "Warnings"
|
||||
},
|
||||
"osdSetupFontPresets": {
|
||||
"message": "Font presets:"
|
||||
},
|
||||
|
@ -2571,6 +2574,47 @@
|
|||
"message": "Select the timer alarm threshold in minutes, when the time exceeds this value the OSD element will blink, setting this to 0 disables the alarm"
|
||||
},
|
||||
|
||||
"osdWarningArmingDisabled": {
|
||||
"message": "Reports the most severe reason for not arming"
|
||||
},
|
||||
"osdWarningBatteryNotFull": {
|
||||
"message": "Alerts when a battery is connected that is not fully charged"
|
||||
},
|
||||
"osdWarningBatteryWarning": {
|
||||
"message": "Alerts when the battery voltage falls below warning threshold"
|
||||
},
|
||||
"osdWarningBatteryCritical": {
|
||||
"message": "Alters when the battery voltage falls below the minimum average cell voltage"
|
||||
},
|
||||
"osdWarningVisualBeeper": {
|
||||
"message": "Shows a visualisation of the beeper (shows as 4 asterisks)"
|
||||
},
|
||||
"osdWarningCrashFlipMode": {
|
||||
"message": "Warns when flip over after crash mode is activated"
|
||||
},
|
||||
|
||||
"osdSectionHelpElements": {
|
||||
"message": "Enable or disable OSD elements."
|
||||
},
|
||||
"osdSectionHelpVideoMode": {
|
||||
"message": "Set the expected video mode of the camera (typically this can be left on AUTO, if you have difficulties then set this to match the camera output)."
|
||||
},
|
||||
"osdSectionHelpUnits": {
|
||||
"message": "Sets the unit system used for numeric readouts."
|
||||
},
|
||||
"osdSectionHelpTimers": {
|
||||
"message": "Configure flight timers."
|
||||
},
|
||||
"osdSectionHelpAlarms": {
|
||||
"message": "Set the thresholds used for OSD elements with alarm states."
|
||||
},
|
||||
"osdSectionHelpStats": {
|
||||
"message": "Set the values dispalyed on the post flight statistics screen."
|
||||
},
|
||||
"osdSectionHelpWarnings": {
|
||||
"message": "Enable or disable warnings that are shown on the WARNINGS element."
|
||||
},
|
||||
|
||||
"mainHelpArmed": {
|
||||
"message": "Motor Arming"
|
||||
},
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="cf_column third_left elements requires-osd-feature">
|
||||
<div class="spacer_right">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box_titlebar" style="margin-bottom: 0px;">
|
||||
<div class="gui_box_titlebar cf_tip" style="margin-bottom: 0px;">
|
||||
<div class="spacer_box_title">
|
||||
<span i18n="osdSetupElementsTitle" />
|
||||
<span class="switch-all-elements">
|
||||
|
@ -48,8 +48,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="cf_column third_right" style="width: calc(100% - 377px);">
|
||||
<div class="gui_box grey requires-max7456">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="gui_box videomode-container grey requires-max7456">
|
||||
<div class="gui_box_titlebar cf_tip">
|
||||
<div class="spacer_box_title" i18n="osdSetupVideoFormatTitle" />
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey units-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="gui_box_titlebar cf_tip">
|
||||
<div class="spacer_box_title" i18n="osdSetupUnitsTitle" />
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
|
@ -65,8 +65,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey timers-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar"
|
||||
style="margin-bottom: 0px;">
|
||||
<div class="gui_box_titlebar cf_tip" style="margin-bottom: 0px;">
|
||||
<div class="spacer_box_title" i18n="osdSetupTimersTitle" />
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
|
@ -74,13 +73,23 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey alarms-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="gui_box_titlebar cf_tip">
|
||||
<div class="spacer_box_title" i18n="osdSetupAlarmsTitle" />
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<div class="alarms"></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">
|
||||
<div class="spacer_box_title" i18n="osdSetupWarningsTitle" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer_box">
|
||||
<div id="warnings-fields" class="switchable-fields"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey stats-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar"
|
||||
style="margin-bottom: 0px;">
|
||||
|
@ -137,4 +146,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
102
tabs/osd.js
102
tabs/osd.js
|
@ -223,6 +223,7 @@ OSD.initData = function() {
|
|||
unit_mode: null,
|
||||
alarms: [],
|
||||
stat_items: [],
|
||||
warnings: [],
|
||||
display_items: [],
|
||||
timers: [],
|
||||
last_positions: {},
|
||||
|
@ -682,6 +683,32 @@ OSD.constants = {
|
|||
desc: 'osdDescStatTimer2'
|
||||
}
|
||||
},
|
||||
ALL_WARNINGS: {
|
||||
ARMING_DISABLED: {
|
||||
name: 'ARMING_DISABLED',
|
||||
desc: 'osdWarningArmingDisabled'
|
||||
},
|
||||
BATTERY_NOT_FULL: {
|
||||
name: 'BATTERY_NOT_FULL',
|
||||
desc: 'osdWarningBatteryNotFull'
|
||||
},
|
||||
BATTERY_WARNING: {
|
||||
name: 'BATTERY_WARNING',
|
||||
desc: 'osdWarningBatteryWarning'
|
||||
},
|
||||
BATTERY_CRITICAL: {
|
||||
name: 'BATTERY_CRITICAL',
|
||||
desc: 'osdWarningBatteryCritical'
|
||||
},
|
||||
VISUAL_BEEPER: {
|
||||
name: 'VISUAL_BEEPER',
|
||||
desc: 'osdWarningVisualBeeper'
|
||||
},
|
||||
CRASH_FLIP_MODE: {
|
||||
name: 'CRASH_FLIP_MODE',
|
||||
desc: 'osdWarningCrashFlipMode'
|
||||
}
|
||||
},
|
||||
FONT_TYPES: [
|
||||
{ file: "default", name: "Default" },
|
||||
{ file: "bold", name: "Bold" },
|
||||
|
@ -809,6 +836,18 @@ OSD.chooseFields = function () {
|
|||
F.MAX_DISTANCE,
|
||||
F.BLACKBOX_LOG_NUMBER
|
||||
];
|
||||
|
||||
// Choose warnings
|
||||
// Nothing much to do here, I'm preempting there being new warnings
|
||||
F = OSD.constants.ALL_WARNINGS;
|
||||
OSD.constants.WARNINGS = [
|
||||
F.ARMING_DISABLED,
|
||||
F.BATTERY_NOT_FULL,
|
||||
F.BATTERY_WARNING,
|
||||
F.BATTERY_CRITICAL,
|
||||
F.VISUAL_BEEPER,
|
||||
F.CRASH_FLIP_MODE
|
||||
];
|
||||
};
|
||||
|
||||
OSD.updateDisplaySize = function() {
|
||||
|
@ -887,6 +926,16 @@ OSD.msp = {
|
|||
result.push16(0);
|
||||
}
|
||||
result.push16(OSD.data.alarms.alt.value);
|
||||
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
|
||||
var warningFlags = 0;
|
||||
for (var i = 0; i < OSD.constants.WARNINGS.length; i++) {
|
||||
if (OSD.data.warnings[i].enabled) {
|
||||
warningFlags |= (1 << i);
|
||||
}
|
||||
}
|
||||
console.log(warningFlags);
|
||||
result.push16(warningFlags);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
@ -941,6 +990,7 @@ OSD.msp = {
|
|||
|
||||
d.display_items = [];
|
||||
d.stat_items = [];
|
||||
d.warnings = [];
|
||||
d.timers = [];
|
||||
|
||||
// Parse display element positions
|
||||
|
@ -988,7 +1038,7 @@ OSD.msp = {
|
|||
|
||||
// Parse configurable timers
|
||||
var expectedTimersCount = view.readU8();
|
||||
while (view.offset < view.byteLength) {
|
||||
while (view.offset < view.byteLength && expectedTimersCount > 0) {
|
||||
var v = view.readU16();
|
||||
var j = d.timers.length;
|
||||
d.timers.push($.extend({
|
||||
|
@ -1001,6 +1051,14 @@ OSD.msp = {
|
|||
view.readU16();
|
||||
expectedTimersCount--;
|
||||
}
|
||||
|
||||
// Parse enabled warnings
|
||||
if (view.offset + 2 <= view.byteLength) {
|
||||
var warningFlags = view.readU16();
|
||||
for (var i = 0; i < OSD.constants.WARNINGS.length; i++) {
|
||||
d.warnings.push($.extend(OSD.constants.WARNINGS[i], { enabled: (warningFlags & (1 << i)) != 0 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate OSD element previews that are defined by a function
|
||||
|
@ -1098,6 +1156,14 @@ TABS.osd.initialize = function (callback) {
|
|||
content: $('#fontmanagercontent')
|
||||
});
|
||||
|
||||
$('.elements-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpElements'));
|
||||
$('.videomode-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpVideoMode'));
|
||||
$('.units-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpUnits'));
|
||||
$('.timers-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpTimers'));
|
||||
$('.alarms-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpAlarms'));
|
||||
$('.stats-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpStats'));
|
||||
$('.warnings-container div.cf_tip').attr('title', chrome.i18n.getMessage('osdSectionHelpWarnings'));
|
||||
|
||||
// 2 way binding... sorta
|
||||
function updateOsdView() {
|
||||
// ask for the OSD config data
|
||||
|
@ -1295,6 +1361,40 @@ TABS.osd.initialize = function (callback) {
|
|||
|
||||
$statsFields.append($field);
|
||||
}
|
||||
|
||||
// Warnings
|
||||
$('.warnings-container').show();
|
||||
var $warningFields = $('#warnings-fields').empty();
|
||||
|
||||
for (let field of OSD.data.warnings) {
|
||||
if (!field.name) { continue; }
|
||||
|
||||
var $field = $('<div class="switchable-field field-'+field.index+'"/>');
|
||||
var desc = null;
|
||||
if (field.desc && field.desc.length) {
|
||||
desc = chrome.i18n.getMessage(field.desc);
|
||||
}
|
||||
if (desc && desc.length) {
|
||||
$field[0].classList.add('osd_tip');
|
||||
$field.attr('title', desc);
|
||||
}
|
||||
$field.append(
|
||||
$('<input type="checkbox" name="'+field.name+'" class="togglesmall"></input>')
|
||||
.data('field', field)
|
||||
.attr('checked', field.enabled)
|
||||
.change(function(e) {
|
||||
var field = $(this).data('field');
|
||||
field.enabled = !field.enabled;
|
||||
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
|
||||
.then(function() {
|
||||
updateOsdView();
|
||||
});
|
||||
})
|
||||
);
|
||||
$field.append('<label for="'+field.name+'" class="char-label">'+inflection.titleize(field.name)+'</label>');
|
||||
|
||||
$warningFields.append($field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue