From aac777eb07ad54654507aee5892c6a0397f70a6a Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sat, 10 Apr 2021 22:48:32 -0700 Subject: [PATCH] Preamp and attenuator are now queried on startup. Additionally, the preamp is checked when the attenuator is changed, and the attenuator is checked with the preamp is changed. This helps the user understand if the rig allows only one or the other to be active (such as the IC-9700). --- rigcommander.cpp | 21 +++++++++++++++++---- rigcommander.h | 5 ++++- wfmain.cpp | 18 ++++++++++++++++++ wfmain.h | 3 +++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index 286bf73..0cb373b 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -1056,6 +1056,9 @@ void rigCommander::parseCommand() case '\x0F': emit haveDuplexMode((duplexMode)(unsigned char)payloadIn[1]); break; + case '\x11': + emit haveAttenuator((unsigned char)payloadIn.at(1)); + break; case '\x14': // read levels parseLevels(); @@ -1065,7 +1068,7 @@ void rigCommander::parseCommand() parseLevels(); break; case '\x16': - parseRptrAccessMode(); + parseRegister16(); break; case '\x19': // qDebug(logRig()) << "Have rig ID: " << (unsigned int)payloadIn[2]; @@ -1957,13 +1960,23 @@ void rigCommander::parseRegister1B() } } -void rigCommander::parseRptrAccessMode() +void rigCommander::parseRegister16() { //"INDEX: 00 01 02 03 " //"DATA: 16 5d 00 fd " // ^-- mode info here - - emit haveRptAccessMode((rptAccessTxRx)payloadIn.at(2)); + switch(payloadIn.at(1)) + { + case '\x5d': + emit haveRptAccessMode((rptAccessTxRx)payloadIn.at(2)); + break; + case '\x02': + // Preamp + emit havePreamp((unsigned char)payloadIn.at(2)); + break; + default: + break; + } } void rigCommander::parseBandStackReg() diff --git a/rigcommander.h b/rigcommander.h index afe70ce..ecc6646 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -272,6 +272,9 @@ signals: // PTT and ATU: void havePTTStatus(bool pttOn); void haveATUStatus(unsigned char status); + void haveAttenuator(unsigned char att); + void havePreamp(unsigned char pre); + void haveAntenna(unsigned char ant); // Housekeeping: void getMoreDebug(); @@ -303,7 +306,7 @@ private: void parseRegisters1A(); void parseRegister1B(); void parseRegisters1C(); - void parseRptrAccessMode(); + void parseRegister16(); void parseBandStackReg(); void parsePTT(); void parseATU(); diff --git a/wfmain.cpp b/wfmain.cpp index bc70266..3f99016 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -455,8 +455,12 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent connect(this, SIGNAL(setPreamp(unsigned char)), rig, SLOT(setPreamp(unsigned char))); connect(this, SIGNAL(setAntenna(unsigned char)), rig, SLOT(setAntenna(unsigned char))); connect(this, SIGNAL(getPreamp()), rig, SLOT(getPreamp())); + connect(rig, SIGNAL(havePreamp(unsigned char)), this, SLOT(receivePreamp(unsigned char))); connect(this, SIGNAL(getAttenuator()), rig, SLOT(getAttenuator())); + connect(rig, SIGNAL(haveAttenuator(unsigned char)), this, SLOT(receiveAttenuator(unsigned char))); connect(this, SIGNAL(getAntenna()), rig, SLOT(getAntenna)); + //connect(rig, SIGNAL(haveAntenna(unsigned char)), this, SLOT(receiveAntennaSel(unsigned char))); + // Speech (emitted from rig speaker) connect(this, SIGNAL(sayAll()), rig, SLOT(sayAll())); @@ -3657,12 +3661,14 @@ void wfmain::on_attSelCombo_activated(int index) { unsigned char att = (unsigned char)ui->attSelCombo->itemData(index).toInt(); emit setAttenuator(att); + issueDelayedCommand(cmdGetPreamp); } void wfmain::on_preampSelCombo_activated(int index) { unsigned char pre = (unsigned char)ui->preampSelCombo->itemData(index).toInt(); emit setPreamp(pre); + issueDelayedCommand(cmdGetAttenuator); } void wfmain::on_antennaSelCombo_activated(int index) @@ -3676,6 +3682,18 @@ void wfmain::on_wfthemeCombo_activated(int index) colorMap->setGradient(static_cast(ui->wfthemeCombo->itemData(index).toInt())); } +void wfmain::receivePreamp(unsigned char pre) +{ + int preindex = ui->preampSelCombo->findData(pre); + ui->preampSelCombo->setCurrentIndex(preindex); +} + +void wfmain::receiveAttenuator(unsigned char att) +{ + int attindex = ui->attSelCombo->findData(att); + ui->attSelCombo->setCurrentIndex(attindex); +} + // --- DEBUG FUNCTION --- void wfmain::on_debugBtn_clicked() { diff --git a/wfmain.h b/wfmain.h index 32b5eec..7d409c1 100644 --- a/wfmain.h +++ b/wfmain.h @@ -203,6 +203,9 @@ private slots: void receiveATUStatus(unsigned char atustatus); + void receivePreamp(unsigned char pre); + void receiveAttenuator(unsigned char att); + //void receiveAntennaSel(unsigned char ant); void receiveRigID(rigCapabilities rigCaps); void receiveFoundRigID(rigCapabilities rigCaps); void receiveSerialPortError(QString port, QString errorText);