From 00709a4e1fbabffae57747cda8730e9cdb84b296 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 8 Oct 2014 20:57:59 -0700 Subject: [PATCH] Fix channel index bug causing incorrect reversal Also fixed bug where channel detection number had off by 1. Also changed UI to show channel reversal. --- src/ui/px4_configuration/PX4RCCalibration.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ui/px4_configuration/PX4RCCalibration.cc b/src/ui/px4_configuration/PX4RCCalibration.cc index 538d9460b..e4fa21640 100644 --- a/src/ui/px4_configuration/PX4RCCalibration.cc +++ b/src/ui/px4_configuration/PX4RCCalibration.cc @@ -360,6 +360,7 @@ void PX4RCCalibration::_remoteControlChannelRawChanged(int chan, float fval) // We always update raw values _rcRawValue[chan] = fval; + //qDebug() << "Raw value" << chan << fval; // Update state machine switch (_rcCalState) { @@ -392,7 +393,7 @@ void PX4RCCalibration::_remoteControlChannelRawChanged(int chan, float fval) _updateView(); // Confirm found channel - QString msg = tr("Found %1 [Channel %2]").arg(_rgFunctionInfo[_rcCalStateCurrentChannel].functionName).arg(chan); + QString msg = tr("Found %1 [Channel %2]").arg(_rgFunctionInfo[_rcCalStateCurrentChannel].functionName).arg(chan + 1); _ui->rcCalFound->setText(msg); //qDebug() << msg; _ui->rcCalTryAgain->setEnabled(true); @@ -429,11 +430,12 @@ void PX4RCCalibration::_remoteControlChannelRawChanged(int chan, float fval) Q_ASSERT(_rcCalStateCurrentChannel >= 0 && _rcCalStateCurrentChannel < rcCalFunctionMax); if (chan == _rgFunctionChannelMapping[_rcCalStateCurrentChannel]) { // If the channel moved considerably use it to determine inversion + //qDebug() << "Detect inversion" << chan << _rcValueSave[chan] << fval << _rcCalMoveDelta; if (fabsf(_rcValueSave[chan] - fval) > _rcCalMoveDelta) { // Request was made to move channel to a lower value. If value goes up the channel is reversed. bool reversed = fval > _rcValueSave[chan]; - _rgChannelInfo[_rcCalStateCurrentChannel].reversed = reversed; + _rgChannelInfo[chan].reversed = reversed; _updateView(); // Confirm inversion detection @@ -510,7 +512,13 @@ void PX4RCCalibration::_updateView() if (info->function == rcCalFunctionMax) { name = tr("Channel %1").arg(oneBasedChannel); } else { - name = tr("%1 [Channel %2]").arg(_rgFunctionInfo[info->function].functionName).arg(oneBasedChannel); + QString label; + if (info->reversed) { + label = tr("%1 [Channel %2,Rev]"); + } else { + label = tr("%1 [Channel %2]"); + } + name = label.arg(_rgFunctionInfo[info->function].functionName).arg(oneBasedChannel); } _rgRadioWidget[chan]->setTitle(name); } @@ -650,6 +658,7 @@ void PX4RCCalibration::_rcCalBegin(void) /// @brief Saves the current channel values, so that we can detect when the use moves an input. void PX4RCCalibration::_rcCalSaveCurrentValues(void) { + //qDebug() << "_rcCalSaveCurrentValues"; for (unsigned i = 0; i < _chanMax; i++) { _rcValueSave[i] = _rcRawValue[i]; } -- 2.22.0