CF/BF - Update for API v0.35.0 - OSD SLAVE.
parent
158b36cd9c
commit
0520f0d473
3
js/fc.js
3
js/fc.js
|
@ -74,7 +74,8 @@ var FC = {
|
|||
accelerometerTrims: [0, 0],
|
||||
name: '',
|
||||
numProfiles: 3,
|
||||
rateProfile: 0
|
||||
rateProfile: 0,
|
||||
boardType: 0,
|
||||
};
|
||||
|
||||
FEATURE_CONFIG = {
|
||||
|
|
14
js/gui.js
14
js/gui.js
|
@ -1,3 +1,4 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var TABS = {}; // filled by individual tab js file
|
||||
|
@ -12,12 +13,14 @@ var GUI_control = function () {
|
|||
this.operating_system;
|
||||
this.interval_array = [];
|
||||
this.timeout_array = [];
|
||||
|
||||
this.defaultAllowedTabsWhenDisconnected = [
|
||||
'landing',
|
||||
'firmware_flasher',
|
||||
'help'
|
||||
];
|
||||
this.defaultAllowedTabsWhenConnected = [
|
||||
this.defaultAllowedFCTabsWhenConnected = [
|
||||
'setup',
|
||||
'failsafe',
|
||||
'transponder',
|
||||
'osd',
|
||||
|
@ -37,7 +40,14 @@ var GUI_control = function () {
|
|||
'receiver',
|
||||
'sensors',
|
||||
'servos',
|
||||
'setup'
|
||||
];
|
||||
this.defaultAllowedOSDTabsWhenConnected = [
|
||||
'setup',
|
||||
'osd',
|
||||
'power',
|
||||
'sensors',
|
||||
'transponder',
|
||||
'cli',
|
||||
];
|
||||
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;
|
||||
|
||||
|
|
|
@ -611,6 +611,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
}
|
||||
CONFIG.boardIdentifier = identifier;
|
||||
CONFIG.boardVersion = data.readU16();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.35.0")) {
|
||||
CONFIG.boardType = data.readU8();
|
||||
} else {
|
||||
CONFIG.boardType = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_NAME:
|
||||
|
|
|
@ -263,9 +263,32 @@ function onConnect() {
|
|||
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||
$('div#connectbutton a.connect_state').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||
$('div#connectbutton a.connect').addClass('active');
|
||||
|
||||
$('#tabs ul.mode-disconnected').hide();
|
||||
$('#tabs ul.mode-connected-cli').show();
|
||||
|
||||
|
||||
// show only appropriate tabs
|
||||
$('#tabs ul.mode-connected li').hide();
|
||||
$('#tabs ul.mode-connected li').filter(function (index) {
|
||||
var classes = $(this).attr("class").split(/\s+/);
|
||||
var found = false;
|
||||
$.each(GUI.allowedTabs, function (index, value) {
|
||||
var tabName = "tab_" + value;
|
||||
if ($.inArray(tabName, classes) >= 0) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (CONFIG.boardType == 0) {
|
||||
if (classes.indexOf("osd-required") >= 0) {
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}).show();
|
||||
|
||||
if (CONFIG.flightControllerVersion !== '') {
|
||||
FEATURE_CONFIG.features = new Features(CONFIG);
|
||||
|
||||
|
@ -277,7 +300,9 @@ function onConnect() {
|
|||
MSP.send_message(MSPCodes.MSP_STATUS_EX, false, false);
|
||||
MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false);
|
||||
|
||||
startLiveDataRefreshTimer();
|
||||
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) {
|
||||
startLiveDataRefreshTimer();
|
||||
}
|
||||
}
|
||||
|
||||
var sensor_state = $('#sensor-status');
|
||||
|
@ -349,7 +374,7 @@ function sensor_status(sensors_detected) {
|
|||
$('.accicon', e_sensor_status).removeClass('active');
|
||||
}
|
||||
|
||||
if (true) { // Gyro status is not reported by FC
|
||||
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) { // Gyro status is not reported by FC
|
||||
$('.gyro', e_sensor_status).addClass('on');
|
||||
$('.gyroicon', e_sensor_status).addClass('active');
|
||||
} else {
|
||||
|
|
3
main.js
3
main.js
|
@ -466,12 +466,13 @@ function updateTabList(features) {
|
|||
} else {
|
||||
$('#tabs ul.mode-connected li.tab_transponder').hide();
|
||||
}
|
||||
|
||||
/* FIXME this approach doesn't work for OSD SLAVE boards as they don't have an 'OSD' feature.
|
||||
if (features.isEnabled('OSD')) {
|
||||
$('#tabs ul.mode-connected li.tab_osd').show();
|
||||
} else {
|
||||
$('#tabs ul.mode-connected li.tab_osd').hide();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function zeroPad(value, width) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<p class="note">Note that some flight controllers have an onboard <a href="https://www.youtube.com/watch?v=ikKH_6SQ-Tk" target="_blank">MinimOSD</a> that can be flashed and configured with <a href="https://github.com/ShikOfTheRa/scarab-osd/releases/latest" target="_blank">scarab-osd</a>, however the MinimOSD cannot be configured through this interface.</p>
|
||||
</div>
|
||||
<div class="supported hide">
|
||||
<div class="cf_column third_left elements">
|
||||
<div class="cf_column third_left elements requires-osd-feature">
|
||||
<div class="spacer_right">
|
||||
<div class="gui_box grey">
|
||||
<div
|
||||
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="cf_column twothird">
|
||||
<div class="gui_box grey preview" style="float: left;">
|
||||
<div class="gui_box grey preview requires-osd-feature" style="float: left;">
|
||||
<div class="gui_box_titlebar image">
|
||||
<div class="spacer_box_title">
|
||||
Preview <span>(drag to change position)</span><span class="preview-logo cf_tip" title="Show or hide the logo in the preview window. This will not change any settings on the flight controller."></span>
|
||||
|
@ -42,7 +42,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="cf_column third_right" style="width: calc(100% - 377px);">
|
||||
<div class="gui_box grey">
|
||||
<div class="gui_box grey requires-max7456">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title">Video
|
||||
Format
|
||||
|
@ -52,7 +52,7 @@
|
|||
<div class="video-types"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey units-container" style="display:none;">
|
||||
<div class="gui_box grey units-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title">Units
|
||||
</div>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<div class="units"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gui_box grey alarms-container" style="display:none;">
|
||||
<div class="gui_box grey alarms-container requires-osd-feature" style="display:none;">
|
||||
<div class="gui_box_titlebar">
|
||||
<div class="spacer_box_title">
|
||||
Alarms
|
||||
|
@ -117,10 +117,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="content_toolbar supported hide" style="left:0;">
|
||||
<div class="btn">
|
||||
<div class="btn save">
|
||||
<a class="active save" href="#" >Save</a>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<div class="btn requires-max7456">
|
||||
<a class="fonts" id="fontmanager" href="#" >Font Manager</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
52
tabs/osd.js
52
tabs/osd.js
|
@ -556,7 +556,7 @@ OSD.msp = {
|
|||
},
|
||||
encodeOther: function() {
|
||||
var result = [-1, OSD.data.video_system];
|
||||
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
|
||||
if (OSD.data.state.haveOsdFeature && semver.gte(CONFIG.apiVersion, "1.21.0")) {
|
||||
result.push8(OSD.data.unit_mode);
|
||||
// watch out, order matters! match the firmware
|
||||
result.push8(OSD.data.alarms.rssi.value);
|
||||
|
@ -576,18 +576,30 @@ OSD.msp = {
|
|||
decode: function(payload) {
|
||||
var view = payload.data;
|
||||
var d = OSD.data;
|
||||
d.compiled_in = view.readU8();
|
||||
d.video_system = view.readU8();
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.21.0")) {
|
||||
d.unit_mode = view.readU8();
|
||||
d.alarms = {};
|
||||
d.alarms['rssi'] = { display_name: 'Rssi', value: view.readU8() };
|
||||
d.alarms['cap']= { display_name: 'Capacity', value: view.readU16() };
|
||||
d.alarms['time'] = { display_name: 'Minutes', value: view.readU16() };
|
||||
d.alarms['alt'] = { display_name: 'Altitude', value: view.readU16() };
|
||||
d.flags = view.readU8();
|
||||
|
||||
if (d.flags > 0) {
|
||||
if (payload.length > 1) {
|
||||
d.video_system = view.readU8();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.21.0") && bit_check(d.flags, 0)) {
|
||||
d.unit_mode = view.readU8();
|
||||
d.alarms = {};
|
||||
d.alarms['rssi'] = { display_name: 'Rssi', value: view.readU8() };
|
||||
d.alarms['cap']= { display_name: 'Capacity', value: view.readU16() };
|
||||
d.alarms['time'] = { display_name: 'Minutes', value: view.readU16() };
|
||||
d.alarms['alt'] = { display_name: 'Altitude', value: view.readU16() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d.state = {};
|
||||
d.state.haveSomeOsd = (d.flags != 0)
|
||||
d.state.haveMax7456Video = bit_check(d.flags, 4) || (d.flags == 1 && semver.lt(CONFIG.apiVersion, "1.34.0"));
|
||||
d.state.haveOsdFeature = bit_check(d.flags, 0) || (d.flags == 1 && semver.lt(CONFIG.apiVersion, "1.34.0"));
|
||||
d.state.isOsdSlave = bit_check(d.flags, 1) && semver.gte(CONFIG.apiVersion, "1.34.0");
|
||||
|
||||
d.display_items = [];
|
||||
|
||||
// start at the offset from the other fields
|
||||
while (view.offset < view.byteLength && d.display_items.length < OSD.constants.DISPLAY_FIELDS.length) {
|
||||
var v = null;
|
||||
|
@ -685,15 +697,17 @@ TABS.osd.initialize = function (callback) {
|
|||
// ask for the OSD config data
|
||||
MSP.promise(MSPCodes.MSP_OSD_CONFIG)
|
||||
.then(function(info) {
|
||||
|
||||
OSD.chooseFields();
|
||||
// fc responsed with short message: osd unsupported
|
||||
if (info.length < 4) {
|
||||
|
||||
OSD.msp.decode(info);
|
||||
|
||||
if (OSD.data.state.haveSomeOsd == 0) {
|
||||
$('.unsupported').fadeIn();
|
||||
return;
|
||||
}
|
||||
$('.supported').fadeIn();
|
||||
OSD.msp.decode(info);
|
||||
|
||||
|
||||
// show Betaflight logo in preview
|
||||
var $previewLogo = $('.preview-logo').empty();
|
||||
$previewLogo.append(
|
||||
|
@ -762,6 +776,14 @@ TABS.osd.initialize = function (callback) {
|
|||
$alarms.append($input);
|
||||
}
|
||||
}
|
||||
|
||||
if (!OSD.data.state.haveMax7456Video) {
|
||||
$('.requires-max7456').hide();
|
||||
}
|
||||
|
||||
if (!OSD.data.state.haveOsdFeature) {
|
||||
$('.requires-osd-feature').hide();
|
||||
}
|
||||
|
||||
// display fields on/off and position
|
||||
var $displayFields = $('.display-fields').empty();
|
||||
|
|
|
@ -185,17 +185,26 @@ TABS.sensors.initialize = function (callback) {
|
|||
|
||||
// disable graphs for sensors that are missing
|
||||
var checkboxes = $('.tab-sensors .info .checkboxes input');
|
||||
if (!have_sensor(CONFIG.activeSensors, 'acc')) {
|
||||
checkboxes.eq(1).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'mag')) {
|
||||
checkboxes.eq(2).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'baro')) {
|
||||
checkboxes.eq(3).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'sonar')) {
|
||||
checkboxes.eq(4).prop('disabled', true);
|
||||
checkboxes.parent().show();
|
||||
|
||||
if (CONFIG.boardType == 0 || CONFIG.boardType == 2) {
|
||||
if (!have_sensor(CONFIG.activeSensors, 'acc')) {
|
||||
checkboxes.eq(1).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'mag')) {
|
||||
checkboxes.eq(2).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'baro')) {
|
||||
checkboxes.eq(3).prop('disabled', true);
|
||||
}
|
||||
if (!have_sensor(CONFIG.activeSensors, 'sonar')) {
|
||||
checkboxes.eq(4).prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i <= 4; i++) {
|
||||
checkboxes.eq(i).prop('disabled', true);
|
||||
checkboxes.eq(i).parent().hide();
|
||||
}
|
||||
}
|
||||
|
||||
$('.tab-sensors .info .checkboxes input').change(function () {
|
||||
|
|
Loading…
Reference in New Issue