1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 01:35:28 +03:00

Merge pull request #1142 from smoriarty21/rc_smoothing

WIP: Adding rc smoothing to configurator
This commit is contained in:
Michael Keller 2018-08-12 18:25:34 +12:00 committed by GitHub
commit 84e2cada68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 465 additions and 49 deletions

View file

@ -390,20 +390,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 = {

View file

@ -790,6 +790,14 @@ MspHelper.prototype.process_data = function(dataHandler) {
RX_CONFIG.rxSpiId = data.readU32();
RX_CONFIG.rxSpiRfChannelCount = data.readU8();
RX_CONFIG.fpvCamAngleDegrees = data.readU8();
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.rxSpiProtocol = 0;
RX_CONFIG.rxSpiId = 0;
@ -801,6 +809,8 @@ MspHelper.prototype.process_data = function(dataHandler) {
RX_CONFIG.rcInterpolationInterval = 0;
RX_CONFIG.airModeActivateThreshold = 0;
}
break;
case MSPCodes.MSP_FAILSAFE_CONFIG:
@ -1403,6 +1413,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)
@ -1420,6 +1431,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);
}
}
}

View file

@ -328,6 +328,95 @@ TABS.receiver.initialize = function (callback) {
});
});
// RC Smoothing
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");
$('.tab-receiver .rc-smoothing-input-blank').hide();
if (RX_CONFIG.rcSmoothingInputCutoff == 0) {
$('.tab-receiver .rcSmoothing-input-cutoff').hide();
$('select[name="rcSmoothing-input-manual-select"]').val("0");
$('.tab-receiver .rc-smoothing-input-blank').show();
}
$('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");
$('.tab-receiver .rc-smoothing-derivative-blank').hide();
if (RX_CONFIG.rcSmoothingDerivativeCutoff == 0) {
$('select[name="rcSmoothing-input-derivative-select"]').val("0");
$('.tab-receiver .rcSmoothing-derivative-cutoff').hide();
$('.tab-receiver .rc-smoothing-derivative-blank').show();
}
$('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();
} else {
$('.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();
$('.tab-receiver .rc-smoothing-type').hide();
}
// Only show the MSP control sticks if the MSP Rx feature is enabled
$(".sticks_btn").toggle(FEATURE_CONFIG.features.isEnabled('RX_MSP'));
@ -508,9 +597,35 @@ TABS.receiver.cleanup = function (callback) {
TABS.receiver.updateRcInterpolationParameters = function () {
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
if ($('select[name="rcInterpolation-select"]').val() === '3') {
$('.tab-receiver .rcInterpolationInterval').show();
$('.tab-receiver .rc-interpolation-manual').show();
} else {
$('.tab-receiver .rcInterpolationInterval').hide();
$('.tab-receiver .rc-interpolation-manual').hide();
}
}
};
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();
}
}