mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-21 15:25:22 +03:00
Adding rc smoothing
This commit is contained in:
parent
25b49fb79f
commit
5a6b277778
6 changed files with 437 additions and 25 deletions
34
src/js/fc.js
34
src/js/fc.js
|
@ -378,20 +378,26 @@ var FC = {
|
|||
};
|
||||
|
||||
RX_CONFIG = {
|
||||
serialrx_provider: 0,
|
||||
stick_max: 0,
|
||||
stick_center: 0,
|
||||
stick_min: 0,
|
||||
spektrum_sat_bind: 0,
|
||||
rx_min_usec: 0,
|
||||
rx_max_usec: 0,
|
||||
rcInterpolation: 0,
|
||||
rcInterpolationInterval: 0,
|
||||
airModeActivateThreshold: 0,
|
||||
rxSpiProtocol: 0,
|
||||
rxSpiId: 0,
|
||||
rxSpiRfChannelCount: 0,
|
||||
fpvCamAngleDegrees: 0,
|
||||
serialrx_provider: 0,
|
||||
stick_max: 0,
|
||||
stick_center: 0,
|
||||
stick_min: 0,
|
||||
spektrum_sat_bind: 0,
|
||||
rx_min_usec: 0,
|
||||
rx_max_usec: 0,
|
||||
rcInterpolation: 0,
|
||||
rcInterpolationInterval: 0,
|
||||
rcInterpolationChannels: 0,
|
||||
airModeActivateThreshold: 0,
|
||||
rxSpiProtocol: 0,
|
||||
rxSpiId: 0,
|
||||
rxSpiRfChannelCount: 0,
|
||||
fpvCamAngleDegrees: 0,
|
||||
rcSmoothingType: 0,
|
||||
rcSmoothingInputCutoff: 0,
|
||||
rcSmoothingDerivativeCutoff: 0,
|
||||
rcSmoothingInputType: 0,
|
||||
rcSmoothingDerivativeType: 0,
|
||||
};
|
||||
|
||||
FAILSAFE_CONFIG = {
|
||||
|
|
|
@ -764,6 +764,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
RX_CONFIG.spektrum_sat_bind = data.readU8();
|
||||
RX_CONFIG.rx_min_usec = data.readU16();
|
||||
RX_CONFIG.rx_max_usec = data.readU16();
|
||||
RX_CONFIG.rcInterpolation = 0;
|
||||
RX_CONFIG.rcInterpolationInterval = 0;
|
||||
RX_CONFIG.airModeActivateThreshold = 0;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
|
||||
RX_CONFIG.rcInterpolation = data.readU8();
|
||||
RX_CONFIG.rcInterpolationInterval = data.readU8();
|
||||
|
@ -773,16 +776,15 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
RX_CONFIG.rxSpiId = data.readU32();
|
||||
RX_CONFIG.rxSpiRfChannelCount = data.readU8();
|
||||
RX_CONFIG.fpvCamAngleDegrees = data.readU8();
|
||||
} else {
|
||||
RX_CONFIG.rxSpiProtocol = 0;
|
||||
RX_CONFIG.rxSpiId = 0;
|
||||
RX_CONFIG.rxSpiRfChannelCount = 0;
|
||||
RX_CONFIG.fpvCamAngleDegrees = 0;
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
RX_CONFIG.rcInterpolationChannels = data.readU8();
|
||||
RX_CONFIG.rcSmoothingType = data.readU8();
|
||||
RX_CONFIG.rcSmoothingInputCutoff = data.readU8();
|
||||
RX_CONFIG.rcSmoothingDerivativeCutoff = data.readU8();
|
||||
RX_CONFIG.rcSmoothingInputType = data.readU8();
|
||||
RX_CONFIG.rcSmoothingDerivativeType = data.readU8();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RX_CONFIG.rcInterpolation = 0;
|
||||
RX_CONFIG.rcInterpolationInterval = 0;
|
||||
RX_CONFIG.airModeActivateThreshold = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1360,6 +1362,7 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push16(BF_CONFIG.batterycapacity)
|
||||
}
|
||||
break;
|
||||
|
||||
case MSPCodes.MSP_SET_RX_CONFIG:
|
||||
buffer.push8(RX_CONFIG.serialrx_provider)
|
||||
.push16(RX_CONFIG.stick_max)
|
||||
|
@ -1377,6 +1380,14 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push32(RX_CONFIG.rxSpiId)
|
||||
.push8(RX_CONFIG.rxSpiRfChannelCount)
|
||||
.push8(RX_CONFIG.fpvCamAngleDegrees);
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
buffer.push8(RX_CONFIG.rcInterpolationChannels)
|
||||
.push8(RX_CONFIG.rcSmoothingType)
|
||||
.push8(RX_CONFIG.rcSmoothingInputCutoff)
|
||||
.push8(RX_CONFIG.rcSmoothingDerivativeCutoff)
|
||||
.push8(RX_CONFIG.rcSmoothingInputType)
|
||||
.push8(RX_CONFIG.rcSmoothingDerivativeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -324,6 +324,83 @@ TABS.receiver.initialize = function (callback) {
|
|||
});
|
||||
});
|
||||
|
||||
// RC Smoothing
|
||||
$('.tab-receiver .rcSmoothing').hide();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
$('.tab-receiver .rcSmoothing').show();
|
||||
|
||||
var rc_smoothing_protocol_e = $('select[name="rcSmoothing-select"]');
|
||||
rc_smoothing_protocol_e.change(function () {
|
||||
RX_CONFIG.rcSmoothingType = $(this).val();
|
||||
updateInterpolationView();
|
||||
});
|
||||
rc_smoothing_protocol_e.val(RX_CONFIG.rcSmoothingType);
|
||||
|
||||
var rcSmoothingnNumberElement = $('input[name="rcSmoothingInputHz-number"]');
|
||||
var rcSmoothingnDerivativeNumberElement = $('input[name="rcSmoothingDerivativeCutoff-number"]');
|
||||
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').show();
|
||||
$('select[name="rcSmoothing-input-manual-select"]').val("1");
|
||||
if (RX_CONFIG.rcSmoothingInputCutoff == 0) {
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').hide();
|
||||
$('select[name="rcSmoothing-input-manual-select"]').val("0");
|
||||
}
|
||||
$('select[name="rcSmoothing-input-manual-select"]').change(function () {
|
||||
if ($(this).val() == 0) {
|
||||
RX_CONFIG.rcSmoothingInputCutoff = 0;
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').hide();
|
||||
}
|
||||
if ($(this).val() == 1) {
|
||||
rcSmoothingnNumberElement.val(RX_CONFIG.rcSmoothingInputCutoff);
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').show();
|
||||
$('select[name="rcSmoothing-input-derivative-select"]').val("1");
|
||||
if (RX_CONFIG.rcSmoothingDerivativeCutoff == 0) {
|
||||
$('select[name="rcSmoothing-input-derivative-select"]').val("0");
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').hide();
|
||||
}
|
||||
$('select[name="rcSmoothing-input-derivative-select"]').change(function () {
|
||||
if ($(this).val() == 0) {
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').hide();
|
||||
RX_CONFIG.rcSmoothingDerivativeCutoff = 0;
|
||||
}
|
||||
if ($(this).val() == 1) {
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').show();
|
||||
rcSmoothingnDerivativeNumberElement.val(RX_CONFIG.rcSmoothingDerivativeCutoff);
|
||||
}
|
||||
});
|
||||
|
||||
rcSmoothingnNumberElement.change(function () {
|
||||
RX_CONFIG.rcSmoothingInputCutoff = $(this).val();
|
||||
});
|
||||
rcSmoothingnNumberElement.val(RX_CONFIG.rcSmoothingInputCutoff);
|
||||
|
||||
rcSmoothingnDerivativeNumberElement.change(function () {
|
||||
RX_CONFIG.rcSmoothingDerivativeCutoff = $(this).val();
|
||||
});
|
||||
rcSmoothingnDerivativeNumberElement.val(RX_CONFIG.rcSmoothingDerivativeCutoff);
|
||||
var rc_smoothing_derivative_type = $('select[name="rcSmoothingDerivativeType-select"]');
|
||||
rc_smoothing_derivative_type.change(function () {
|
||||
RX_CONFIG.rcSmoothingDerivativeType = $(this).val();
|
||||
});
|
||||
rc_smoothing_derivative_type.val(RX_CONFIG.rcSmoothingDerivativeType);
|
||||
var rc_smoothing_channels = $('select[name="rcSmoothingChannels-select"]');
|
||||
rc_smoothing_channels.change(function () {
|
||||
RX_CONFIG.rcInterpolationChannels = $(this).val();
|
||||
});
|
||||
rc_smoothing_channels.val(RX_CONFIG.rcInterpolationChannels);
|
||||
var rc_smoothing_input_type = $('select[name="rcSmoothingInputType-select"]');
|
||||
rc_smoothing_input_type.change(function () {
|
||||
RX_CONFIG.rcSmoothingInputType = $(this).val();
|
||||
});
|
||||
rc_smoothing_input_type.val(RX_CONFIG.rcSmoothingInputType);
|
||||
|
||||
updateInterpolationView();
|
||||
}
|
||||
|
||||
// Only show the MSP control sticks if the MSP Rx feature is enabled
|
||||
$(".sticks_btn").toggle(FEATURE_CONFIG.features.isEnabled('RX_MSP'));
|
||||
|
||||
|
@ -510,3 +587,29 @@ TABS.receiver.updateRcInterpolationParameters = function () {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
function updateInterpolationView() {
|
||||
$('.tab-receiver .rcInterpolation').hide();
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').show();
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').show();
|
||||
$('.tab-receiver .rcSmoothing-derivative-type').show();
|
||||
$('.tab-receiver .rcSmoothing-input-type').show();
|
||||
$('.tab-receiver .rcSmoothing-derivative-manual').show();
|
||||
$('.tab-receiver .rcSmoothing-input-manual').show();
|
||||
|
||||
if (parseInt(RX_CONFIG.rcSmoothingType) === 0) {
|
||||
$('.tab-receiver .rcInterpolation').show();
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').hide();
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').hide();
|
||||
$('.tab-receiver .rcSmoothing-derivative-type').hide();
|
||||
$('.tab-receiver .rcSmoothing-input-type').hide();
|
||||
$('.tab-receiver .rcSmoothing-derivative-manual').hide();
|
||||
$('.tab-receiver .rcSmoothing-input-manual').hide();
|
||||
}
|
||||
if (parseInt(RX_CONFIG.rcSmoothingDerivativeCutoff) === 0) {
|
||||
$('.tab-receiver .rcSmoothing-derivative-cutoff').hide();
|
||||
}
|
||||
if (parseInt(RX_CONFIG.rcSmoothingInputCutoff) === 0) {
|
||||
$('.tab-receiver .rcSmoothing-input-cutoff').hide();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue