From 6938ed8a60b1dfbd28ae42481bf0584e08e72eaa Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 15 Feb 2021 20:32:14 -0800 Subject: [PATCH] Full support for set and read mic gain and tx power. Code also exists to set and read microphone compressor level, vox gain, anti vox, and self audio monitor. --- rigcommander.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ rigcommander.h | 6 ++++++ wfmain.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++--- wfmain.h | 25 ++++++++++++++++++++++--- wfmain.ui | 9 +++++++++ 5 files changed, 124 insertions(+), 6 deletions(-) diff --git a/rigcommander.cpp b/rigcommander.cpp index d900810..c4bc4b3 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -907,6 +907,49 @@ void rigCommander::parseLevels() } +void rigCommander::setTxPower(unsigned char power) +{ + QByteArray payload("\x14\x0A"); + payload.append(bcdEncodeInt(power)); + prepDataAndSend(payload); +} + +void rigCommander::setMicGain(unsigned char gain) +{ + QByteArray payload("\x14\x0B"); + payload.append(bcdEncodeInt(gain)); + prepDataAndSend(payload); +} + +void rigCommander::setCompLevel(unsigned char compLevel) +{ + QByteArray payload("\x14\x0E"); + payload.append(bcdEncodeInt(compLevel)); + prepDataAndSend(payload); +} + +void rigCommander::setMonitorLevel(unsigned char monitorLevel) +{ + QByteArray payload("\x14\x0E"); + payload.append(bcdEncodeInt(monitorLevel)); + prepDataAndSend(payload); +} + +void rigCommander::setVoxGain(unsigned char gain) +{ + QByteArray payload("\x14\x16"); + payload.append(bcdEncodeInt(gain)); + prepDataAndSend(payload); +} + +void rigCommander::setAntiVoxGain(unsigned char gain) +{ + QByteArray payload("\x14\x17"); + payload.append(bcdEncodeInt(gain)); + prepDataAndSend(payload); +} + + void rigCommander::getRfGain() { QByteArray payload("\x14\x02"); diff --git a/rigcommander.h b/rigcommander.h index 1485108..4dc536c 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -78,6 +78,12 @@ public slots: void setSquelch(unsigned char level); void setRfGain(unsigned char level); void setAfGain(unsigned char level); + void setTxPower(unsigned char power); + void setMicGain(unsigned char gain); + void setCompLevel(unsigned char compLevel); + void setMonitorLevel(unsigned char monitorLevel); + void setVoxGain(unsigned char gain); + void setAntiVoxGain(unsigned char gain); void startATU(); void setATU(bool enabled); diff --git a/wfmain.cpp b/wfmain.cpp index 7de4920..24e5b4e 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -288,16 +288,30 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent connect(this, SIGNAL(setMode(unsigned char, unsigned char)), rig, SLOT(setMode(unsigned char, unsigned char))); // Levels (read and write) + // Levels: Query: connect(this, SIGNAL(getLevels()), rig, SLOT(getLevels())); connect(this, SIGNAL(getRfGain()), rig, SLOT(getRfGain())); connect(this, SIGNAL(getAfGain()), rig, SLOT(getAfGain())); + connect(this, SIGNAL(getSql()), rig, SLOT(getSql())); + connect(this, SIGNAL(getTxPower()), rig, SLOT(getTxLevel())); + connect(this, SIGNAL(getMicGain()), rig, SLOT(getMicGain())); + + // Levels: Set: connect(this, SIGNAL(setRfGain(unsigned char)), rig, SLOT(setRfGain(unsigned char))); connect(this, SIGNAL(setAfGain(unsigned char)), rig, SLOT(setAfGain(unsigned char))); + connect(this, SIGNAL(setSql(unsigned char)), rig, SLOT(setSquelch(unsigned char))); + connect(this, SIGNAL(setTxPower(unsigned char)), rig, SLOT(setTxPower(unsigned char))); + connect(this, SIGNAL(setMicGain(unsigned char)), rig, SLOT(setMicGain(unsigned char))); + connect(this, SIGNAL(setMonitorLevel(unsigned char)), rig, SLOT(setMonitorLevel(unsigned char))); + connect(this, SIGNAL(setVoxGain(unsigned char)), rig, SLOT(setVoxGain(unsigned char))); + connect(this, SIGNAL(setAntiVoxGain(unsigned char)), rig, SLOT(setAntiVoxGain(unsigned char))); + + + + // Levels: handle return on query: connect(rig, SIGNAL(haveRfGain(unsigned char)), this, SLOT(receiveRfGain(unsigned char))); connect(rig, SIGNAL(haveAfGain(unsigned char)), this, SLOT(receiveAfGain(unsigned char))); - connect(this, SIGNAL(getSql()), rig, SLOT(getSql())); connect(rig, SIGNAL(haveSql(unsigned char)), this, SLOT(receiveSql(unsigned char))); - connect(this, SIGNAL(setSql(unsigned char)), rig, SLOT(setSquelch(unsigned char))); connect(rig, SIGNAL(haveTxPower(unsigned char)), this, SLOT(receiveTxPower(unsigned char))); connect(rig, SIGNAL(haveMicGain(unsigned char)), this, SLOT(receiveMicGain(unsigned char))); @@ -1154,7 +1168,11 @@ void wfmain:: getInitialRigState() cmdOutQue.append(cmdGetRxGain); cmdOutQue.append(cmdGetAfGain); - cmdOutQue.append(cmdGetSql); // implimented but not used + cmdOutQue.append(cmdGetSql); + + cmdOutQue.append(cmdGetTxPower); + cmdOutQue.append(cmdGetMicGain); + // TODO: // get TX level // get Scope reference Level @@ -1350,6 +1368,12 @@ void wfmain::runDelayedCommand() case cmdGetSql: emit getSql(); break; + case cmdGetTxPower: + emit getTxPower(); + break; + case cmdGetMicGain: + emit getMicGain(); + break; case cmdGetATUStatus: emit getATUStatus(); break; @@ -2566,6 +2590,23 @@ void wfmain::receiveAntiVoxGain(unsigned char antiVoxGain) (void)antiVoxGain; } +void wfmain::on_txPowerSlider_valueChanged(int value) +{ + emit setTxPower(value); +} + +void wfmain::on_micGainSlider_valueChanged(int value) +{ + emit setMicGain(value); +} + +void wfmain::on_scopeRefLevelSlider_valueChanged(int value) +{ + //emit setScopeRefLevel(value); + (void)value; +} + + // --- DEBUG FUNCTION --- diff --git a/wfmain.h b/wfmain.h index 57c3064..8dede19 100644 --- a/wfmain.h +++ b/wfmain.h @@ -47,15 +47,27 @@ signals: void getPTT(); void setPTT(bool pttOn); void getBandStackReg(char band, char regCode); + void getDebug(); + + // Level get: + void getLevels(); // get all levels void getRfGain(); void getAfGain(); void getSql(); - void getDebug(); + void getTxPower(); + void getMicGain(); + + // Level set: void setRfGain(unsigned char level); void setAfGain(unsigned char level); void setSql(unsigned char level); + void setMicGain(unsigned char); + void setCompLevel(unsigned char); + void setTxPower(unsigned char); + void setMonitorLevel(unsigned char); + void setVoxGain(unsigned char); + void setAntiVoxGain(unsigned char); - void getLevels(); void getMeters(bool isTransmitting); @@ -312,6 +324,12 @@ private slots: void on_satOpsBtn_clicked(); + void on_txPowerSlider_valueChanged(int value); + + void on_micGainSlider_valueChanged(int value); + + void on_scopeRefLevelSlider_valueChanged(int value); + private: Ui::wfmain *ui; QSettings settings; @@ -402,7 +420,8 @@ private: double knobFreqMhz; enum cmds {cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetMode, cmdGetDataMode, cmdSetDataModeOn, cmdSetDataModeOff, cmdSpecOn, cmdSpecOff, cmdDispEnable, cmdDispDisable, cmdGetRxGain, cmdGetAfGain, - cmdGetSql, cmdGetATUStatus, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT}; + cmdGetSql, cmdGetATUStatus, cmdScopeCenterMode, cmdScopeFixedMode, cmdGetPTT, + cmdGetTxPower, cmdGetMicGain}; cmds cmdOut; QVector cmdOutQue; freqMemory mem; diff --git a/wfmain.ui b/wfmain.ui index edfd76a..e29752f 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -543,6 +543,15 @@ Spectrum Reference Level Adjust + + -200 + + + 200 + + + 5 + Qt::Vertical