Newer
Older
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_PITCH")) {
rcScaling[1] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_YAW")) {
rcScaling[2] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_THROTTLE")) {
rcScaling[3] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_MODE_SW")) {
rcScaling[4] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_AUX1")) {
rcScaling[5] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_AUX2")) {
rcScaling[6] = value.toFloat();
Lorenz Meier
committed
}
if (parameterName.contains("RC_SCALE_AUX3")) {
rcScaling[7] = value.toFloat();
Lorenz Meier
committed
}
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
}
void QGCVehicleConfig::updateStatus(const QString& str)
{
ui->statusLabel->setText(str);
ui->statusLabel->setStyleSheet("");
}
void QGCVehicleConfig::updateError(const QString& str)
{
ui->statusLabel->setText(str);
ui->statusLabel->setStyleSheet(QString("QLabel { margin: 0px 2px; font: 14px; color: %1; background-color: %2; }").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name()));
}
void QGCVehicleConfig::setRCType(int type)
{
if (!mav) return;
// XXX TODO Add handling of RC_TYPE vs non-RC_TYPE here
mav->setParameter(0, "RC_TYPE", type);
rcTypeUpdateRequested = QGC::groundTimeMilliseconds();
QTimer::singleShot(rcTypeTimeout+100, this, SLOT(checktimeOuts()));
}
void QGCVehicleConfig::checktimeOuts()
{
if (rcTypeUpdateRequested > 0)
{
if (QGC::groundTimeMilliseconds() - rcTypeUpdateRequested > rcTypeTimeout)
{
updateError(tr("Setting remote control timed out - is the system connected?"));
}
}
}
void QGCVehicleConfig::updateView()
{
if (changed)
{
Lorenz Meier
committed
if (rc_mode == RC_MODE_1)
{
ui->rollSlider->setValue(rcRoll * 50 + 50);
ui->pitchSlider->setValue(rcThrottle * 100);
ui->yawSlider->setValue(rcYaw * 50 + 50);
ui->throttleSlider->setValue(rcPitch * 50 + 50);
Lorenz Meier
committed
}
else if (rc_mode == RC_MODE_2)
{
ui->rollSlider->setValue(rcRoll * 50 + 50);
ui->pitchSlider->setValue(rcPitch * 50 + 50);
ui->yawSlider->setValue(rcYaw * 50 + 50);
ui->throttleSlider->setValue(rcThrottle * 100);
Lorenz Meier
committed
}
else if (rc_mode == RC_MODE_3)
{
ui->rollSlider->setValue(rcYaw * 50 + 50);
ui->pitchSlider->setValue(rcThrottle * 100);
ui->yawSlider->setValue(rcRoll * 50 + 50);
ui->throttleSlider->setValue(rcPitch * 50 + 50);
Lorenz Meier
committed
}
else if (rc_mode == RC_MODE_4)
{
ui->rollSlider->setValue(rcYaw * 50 + 50);
ui->pitchSlider->setValue(rcPitch * 50 + 50);
ui->yawSlider->setValue(rcRoll * 50 + 50);
ui->throttleSlider->setValue(rcThrottle * 100);
}
ui->chanLabel->setText(QString("%1/%2").arg(rcValue[rcMapping[0]]).arg(rcRoll, 5, 'f', 2, QChar(' ')));
ui->chanLabel_2->setText(QString("%1/%2").arg(rcValue[rcMapping[1]]).arg(rcPitch, 5, 'f', 2, QChar(' ')));
ui->chanLabel_3->setText(QString("%1/%2").arg(rcValue[rcMapping[2]]).arg(rcYaw, 5, 'f', 2, QChar(' ')));
ui->chanLabel_4->setText(QString("%1/%2").arg(rcValue[rcMapping[3]]).arg(rcThrottle, 5, 'f', 2, QChar(' ')));
ui->modeSwitchSlider->setValue(rcMode * 50 + 50);
ui->chanLabel_5->setText(QString("%1/%2").arg(rcValue[rcMapping[4]]).arg(rcMode, 5, 'f', 2, QChar(' ')));
if (rcValue[rcMapping[5]] != UINT16_MAX) {
ui->aux1Slider->setValue(rcAux1 * 50 + 50);
ui->chanLabel_6->setText(QString("%1/%2").arg(rcValue[rcMapping[5]]).arg(rcAux1, 5, 'f', 2, QChar(' ')));
} else {
ui->chanLabel_6->setText(tr("---"));
}
if (rcValue[rcMapping[6]] != UINT16_MAX) {
ui->aux2Slider->setValue(rcAux2 * 50 + 50);
ui->chanLabel_7->setText(QString("%1/%2").arg(rcValue[rcMapping[6]]).arg(rcAux2, 5, 'f', 2, QChar(' ')));
} else {
ui->chanLabel_7->setText(tr("---"));
}
if (rcValue[rcMapping[7]] != UINT16_MAX) {
ui->aux3Slider->setValue(rcAux3 * 50 + 50);
ui->chanLabel_8->setText(QString("%1/%2").arg(rcValue[rcMapping[7]]).arg(rcAux3, 5, 'f', 2, QChar(' ')));
} else {
ui->chanLabel_8->setText(tr("---"));
Lorenz Meier
committed
}
changed = false;
}
}