mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Added configuration for Dshot beacon activation conditions.
This commit is contained in:
parent
7be361ae20
commit
26361bebad
7 changed files with 91 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
'use strict;'
|
||||
|
||||
var Beepers = function (config) {
|
||||
var Beepers = function (config, supportedConditions) {
|
||||
var self = this;
|
||||
|
||||
var beepers = [
|
||||
|
@ -12,7 +12,7 @@ var Beepers = function (config) {
|
|||
{bit: 5, name: 'ARMING_GPS_FIX', visible: true},
|
||||
{bit: 6, name: 'BAT_CRIT_LOW', visible: true},
|
||||
{bit: 7, name: 'BAT_LOW', visible: true},
|
||||
{bit: 8, name: 'GPS_STATUS', visible: false}, // do not show
|
||||
{bit: 8, name: 'GPS_STATUS', visible: true},
|
||||
{bit: 9, name: 'RX_SET', visible: true},
|
||||
{bit: 10, name: 'ACC_CALIBRATION', visible: true},
|
||||
{bit: 11, name: 'ACC_CALIBRATION_FAIL', visible: true},
|
||||
|
@ -25,7 +25,27 @@ var Beepers = function (config) {
|
|||
{bit: 18, name: 'BLACKBOX_ERASE', visible: true},
|
||||
];
|
||||
|
||||
self._beepers = beepers;
|
||||
if (semver.gte(config.apiVersion, "1.37.0")) {
|
||||
beepers.push(
|
||||
{bit: 19, name: 'CRASH_FLIP', visible: true},
|
||||
{bit: 20, name: 'CAM_CONNECTION_OPEN', visible: true},
|
||||
{bit: 21, name: 'CAM_CONNECTION_CLOSE', visible: true},
|
||||
);
|
||||
}
|
||||
|
||||
if (supportedConditions) {
|
||||
self._beepers = [];
|
||||
beepers.forEach(function (beeper) {
|
||||
if (supportedConditions.some(function (supportedCondition) {
|
||||
return supportedCondition === beeper.name;
|
||||
})) {
|
||||
self._beepers.push(beeper);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self._beepers = beepers.slice();
|
||||
}
|
||||
|
||||
self._beeperMask = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ var FC = {
|
|||
BEEPER_CONFIG = {
|
||||
beepers: 0,
|
||||
dshotBeaconTone: 0,
|
||||
dshotBeaconConditions: 0,
|
||||
};
|
||||
|
||||
MIXER_CONFIG = {
|
||||
|
|
|
@ -605,6 +605,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||
BEEPER_CONFIG.dshotBeaconTone = data.readU8();
|
||||
}
|
||||
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
|
||||
BEEPER_CONFIG.dshotBeaconConditions.setMask(data.readU32());
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG:
|
||||
|
@ -1217,7 +1220,10 @@ MspHelper.prototype.crunch = function(code) {
|
|||
var beeperMask = BEEPER_CONFIG.beepers.getMask();
|
||||
buffer.push32(beeperMask);
|
||||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||
buffer.push8(BEEPER_CONFIG.dshotBeaconTone );
|
||||
buffer.push8(BEEPER_CONFIG.dshotBeaconTone);
|
||||
}
|
||||
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
|
||||
buffer.push32(BEEPER_CONFIG.dshotBeaconConditions.getMask());
|
||||
}
|
||||
break;
|
||||
case MSPCodes.MSP_SET_MIXER_CONFIG:
|
||||
|
|
|
@ -332,6 +332,7 @@ function onConnect() {
|
|||
if (CONFIG.flightControllerVersion !== '') {
|
||||
FEATURE_CONFIG.features = new Features(CONFIG);
|
||||
BEEPER_CONFIG.beepers = new Beepers(CONFIG);
|
||||
BEEPER_CONFIG.dshotBeaconConditions = new Beepers(CONFIG, [ "RX_LOST", "RX_SET" ]);
|
||||
|
||||
$('#tabs ul.mode-connected').show();
|
||||
|
||||
|
|
|
@ -240,6 +240,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
var dshotBeacon_e = $('.tab-configuration .dshotbeacon');
|
||||
var dshotBeeperSwitch = $('#dshotBeeperSwitch');
|
||||
var dshotBeeperBeaconTone = $('select.dshotBeeperBeaconTone');
|
||||
var dshotBeaconCondition_e = $('tbody.dshotBeaconConditions');
|
||||
var dshotBeaconSwitch_e = $('tr.dshotBeaconSwitch');
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||
for (var i = 1; i <= 5; i++) {
|
||||
|
@ -250,27 +252,40 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
dshotBeeper_e.hide();
|
||||
}
|
||||
|
||||
dshotBeeperSwitch.change(function() {
|
||||
if ($(this).is(':checked')) {
|
||||
dshotBeacon_e.show();
|
||||
if (dshotBeeperBeaconTone.val() == 0) {
|
||||
dshotBeeperBeaconTone.val(1).change();
|
||||
}
|
||||
} else {
|
||||
dshotBeeperBeaconTone.val(0).change();
|
||||
dshotBeacon_e.hide();
|
||||
}
|
||||
});
|
||||
|
||||
dshotBeeperBeaconTone.change(function() {
|
||||
BEEPER_CONFIG.dshotBeaconTone = dshotBeeperBeaconTone.val();
|
||||
});
|
||||
|
||||
dshotBeeperBeaconTone.val(BEEPER_CONFIG.dshotBeaconTone);
|
||||
dshotBeeperSwitch.prop('checked', BEEPER_CONFIG.dshotBeaconTone !== 0).change();
|
||||
|
||||
var template = $('.beepers .beeper-template');
|
||||
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
|
||||
dshotBeaconSwitch_e.hide();
|
||||
BEEPER_CONFIG.dshotBeaconConditions.generateElements(template, dshotBeaconCondition_e);
|
||||
|
||||
$('input.condition', dshotBeaconCondition_e).change(function () {
|
||||
var element = $(this);
|
||||
BEEPER_CONFIG.dshotBeaconConditions.updateData(element);
|
||||
});
|
||||
} else {
|
||||
dshotBeaconCondition_e.hide();
|
||||
|
||||
dshotBeeperSwitch.change(function() {
|
||||
if ($(this).is(':checked')) {
|
||||
dshotBeacon_e.show();
|
||||
if (dshotBeeperBeaconTone.val() == 0) {
|
||||
dshotBeeperBeaconTone.val(1).change();
|
||||
}
|
||||
} else {
|
||||
dshotBeeperBeaconTone.val(0).change();
|
||||
dshotBeacon_e.hide();
|
||||
}
|
||||
});
|
||||
|
||||
dshotBeeperSwitch.prop('checked', BEEPER_CONFIG.dshotBeaconTone !== 0).change();
|
||||
}
|
||||
|
||||
// Analog Beeper
|
||||
var template = $('.beepers .beeper-template');
|
||||
var destination = $('.beepers .beeper-configuration');
|
||||
var beeper_e = $('.tab-configuration .beepers');
|
||||
|
||||
|
@ -890,7 +905,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
});
|
||||
|
||||
$('input.beeper', beeper_e).change(function () {
|
||||
$('input.condition', beeper_e).change(function () {
|
||||
var element = $(this);
|
||||
BEEPER_CONFIG.beepers.updateData(element);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue