|
31 | 31 | #include <QDebug> |
32 | 32 |
|
33 | 33 | OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) : |
34 | | - ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false) |
| 34 | + ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false), m_isCalibratingInput(false) |
35 | 35 | { |
36 | 36 | ui->setupUi(this); |
37 | 37 |
|
@@ -120,6 +120,17 @@ void OutputChannelForm::enableChannelTest(bool state) |
120 | 120 | } |
121 | 121 | } |
122 | 122 |
|
| 123 | +/** |
| 124 | + * Update the input calibration status |
| 125 | + */ |
| 126 | +void OutputChannelForm::inputCalibrationStatus(bool state) |
| 127 | +{ |
| 128 | + if (m_isCalibratingInput == state) { |
| 129 | + return; |
| 130 | + } |
| 131 | + m_isCalibratingInput = state; |
| 132 | +} |
| 133 | + |
123 | 134 | /** |
124 | 135 | * Toggles the channel linked state for use in testing mode |
125 | 136 | */ |
@@ -242,21 +253,18 @@ void OutputChannelForm::setChannelRange() |
242 | 253 | setLimits(1000, 1000, 1000, 1000); |
243 | 254 | ui->actuatorMin->setValue(1000); |
244 | 255 | ui->actuatorMax->setValue(1000); |
245 | | - ui->actuatorMin->setEnabled(false); |
246 | | - ui->actuatorMax->setEnabled(false); |
247 | | - ui->actuatorRev->setEnabled(false); |
248 | | - ui->actuatorLink->setEnabled(false); |
249 | | - ui->actuatorValue->setEnabled(false); |
250 | 256 | ui->actuatorRev->setChecked(false); |
251 | 257 | ui->actuatorLink->setChecked(false); |
| 258 | + enableControls(false); |
252 | 259 | return; |
253 | 260 | } |
254 | 261 |
|
255 | | - ui->actuatorMin->setEnabled(true); |
256 | | - ui->actuatorMax->setEnabled(true); |
257 | | - ui->actuatorNeutral->setEnabled(true); |
258 | | - ui->actuatorValue->setEnabled(true); |
259 | | - ui->actuatorLink->setEnabled(true); |
| 262 | + if (m_isCalibratingInput) { |
| 263 | + // Nothing to do here |
| 264 | + return; |
| 265 | + } |
| 266 | + |
| 267 | + enableControls(true); |
260 | 268 |
|
261 | 269 | int minValue = ui->actuatorMin->value(); |
262 | 270 | int maxValue = ui->actuatorMax->value(); |
@@ -323,6 +331,25 @@ void OutputChannelForm::reverseChannel(bool state) |
323 | 331 | } |
324 | 332 | } |
325 | 333 |
|
| 334 | +/** |
| 335 | + * Enable/Disable all UI controls |
| 336 | + */ |
| 337 | +void OutputChannelForm::enableControls(bool state) |
| 338 | +{ |
| 339 | + ui->actuatorMin->setEnabled(state); |
| 340 | + ui->actuatorMax->setEnabled(state); |
| 341 | + ui->actuatorValue->setEnabled(state); |
| 342 | + ui->actuatorLink->setEnabled(state); |
| 343 | + // Reverse checkbox will be never checked |
| 344 | + // or enabled for normal motor |
| 345 | + if (isNormalMotor()) { |
| 346 | + ui->actuatorRev->setChecked(false); |
| 347 | + ui->actuatorRev->setEnabled(false); |
| 348 | + } else { |
| 349 | + ui->actuatorRev->setEnabled(state); |
| 350 | + } |
| 351 | +} |
| 352 | + |
326 | 353 | /** |
327 | 354 | * Emits the channel value which will be send to the UAV to move the servo. |
328 | 355 | * Returns immediately if we are not in testing mode. |
|
0 commit comments