From a1d3f93dad7141a54a4ffd5585eaad0ee7774591 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 24 Jan 2023 20:12:23 +0000 Subject: [PATCH 01/11] PBT should now display correctly in ALL modes! --- wfmain.cpp | 42 +++++++++++++++++++++++++++++++++--------- wfmain.h | 1 + 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 83a1ff2..3757535 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4718,7 +4718,16 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e passbandIndicator->topLeft->setCoords(pbStart, 0); passbandIndicator->bottomRight->setCoords(pbEnd, rigCaps.spectAmpMax); - if (TPBFInner || TPBFOuter) { + double pbtDefault = 0.0; // This will be the default PBT for the selected mode. + + if ((currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) && passbandWidth > 0.0006) + { + pbtDefault = passbandWidth - (passbandCenterFrequency * 2); + } + + if ((int(TPBFInner*1000000) - int(pbtDefault*1000000) || int(TPBFOuter*1000000) - int(pbtDefault*1000000)) + && passbandAction != passbandResizing && currentModeInfo.mk != modeFM) + { pbtIndicator->setVisible(true); } else @@ -4729,10 +4738,10 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e /* pbtIndicator displays the intersection between TPBFInner and TPBFOuter */ - pbtIndicator->topLeft->setCoords(qMax(pbStart + (TPBFInner / 2), pbStart + (TPBFOuter / 2)), 0); + pbtIndicator->topLeft->setCoords(qMax(pbStart + (TPBFInner / 2) - (pbtDefault /2), pbStart + (TPBFOuter / 2) - (pbtDefault /2)), 0); - pbtIndicator->bottomRight->setCoords(qMin(pbStart + (TPBFInner / 2) + passbandWidth, - pbStart + (TPBFOuter / 2) + passbandWidth), rigCaps.spectAmpMax); + pbtIndicator->bottomRight->setCoords(qMin(pbStart + (TPBFInner / 2) - (pbtDefault /2) + passbandWidth, + pbStart + (TPBFOuter / 2) - (pbtDefault/2) + passbandWidth), rigCaps.spectAmpMax); } if (underlayMode == underlayPeakHold) @@ -6547,22 +6556,37 @@ void wfmain::receivePassband(quint16 pass) void wfmain::receiveCwPitch(unsigned char pitch) { if (currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) { - passbandCenterFrequency = (double)((((600 / 256) * pitch) + 300) / 1000000.0)/2.0; + cwPitch = ((600.0 / 256.0) * pitch) + 300; + passbandCenterFrequency = cwPitch / 2000000.0; } } void wfmain::receiveTPBFInner(unsigned char level) { + /* + * This is written like this as although PBT is supposed to be sent in 50Hz steps, + * sometimes it sends the 'nearest' value. This results in math errors. + * By multiplying the MHz value by 20000 with rounding, then dividing this value + * by 20000, we are guaranteed to get a frequency value that matches the step size. + */ qint16 shift = (qint16)(level - 128); - TPBFInner = (double)(shift / 127.0) * (passbandWidth); - //qDebug() << "Inner" << level; + //TPBFInner = (double)(shift / 127.0) * (passbandWidth); + TPBFInner = ceil((shift / 127.0) * (passbandWidth) * 20000.0) / 20000.0; + qDebug() << "Inner" << level << "TPBFInner" << TPBFInner; } void wfmain::receiveTPBFOuter(unsigned char level) { + /* + * This is written like this as although PBT is supposed to be sent in 50Hz steps, + * sometimes it sends the 'nearest' value. This results in math errors. + * By multiplying the MHz value by 20000 with rounding, then dividing this value + * by 20000, we are guaranteed to get a frequency value that matches the step size. + */ qint16 shift = (qint16)(level - 128); - TPBFOuter = (double)(shift / 127.0) * (passbandWidth); - /// qDebug() << "Outer" << level; + TPBFOuter = ceil((shift / 127.0) * (passbandWidth) * 20000.0) / 20000.0; + //TPBFOuter = (double)(shift / 127.0) * (passbandWidth); + qDebug() << "Outer" << level << "TPBFOuter" << TPBFOuter; } diff --git a/wfmain.h b/wfmain.h index 45048c6..c90ad0e 100644 --- a/wfmain.h +++ b/wfmain.h @@ -1111,6 +1111,7 @@ private: double TPBFInner = 0.0; double TPBFOuter = 0.0; double passbandCenterFrequency = 0.0; + quint16 cwPitch = 600; SERVERCONFIG serverConfig; void serverAddUserLine(const QString& user, const QString& pass, const int& type); From 8b8668a6deacb528cf9e0bf7311465966abc1614 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 25 Jan 2023 11:41:50 +0000 Subject: [PATCH 02/11] Finally PBT works in all modes/filter widths/cw pitch settings. --- wfmain.cpp | 58 +++++++++++++++++++++++++++++++++--------------------- wfmain.h | 2 ++ 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 3757535..9e93996 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4718,15 +4718,16 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e passbandIndicator->topLeft->setCoords(pbStart, 0); passbandIndicator->bottomRight->setCoords(pbEnd, rigCaps.spectAmpMax); - double pbtDefault = 0.0; // This will be the default PBT for the selected mode. - if ((currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) && passbandWidth > 0.0006) { - pbtDefault = passbandWidth - (passbandCenterFrequency * 2); + pbtDefault = round((passbandWidth - (cwPitch / 1000000.0)) * 200000.0) / 200000.0; + } + else + { + pbtDefault = 0.0; } - if ((int(TPBFInner*1000000) - int(pbtDefault*1000000) || int(TPBFOuter*1000000) - int(pbtDefault*1000000)) - && passbandAction != passbandResizing && currentModeInfo.mk != modeFM) + if ((TPBFInner - pbtDefault || TPBFOuter - pbtDefault) && passbandAction != passbandResizing && currentModeInfo.mk != modeFM) { pbtIndicator->setVisible(true); } @@ -4742,6 +4743,8 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e pbtIndicator->bottomRight->setCoords(qMin(pbStart + (TPBFInner / 2) - (pbtDefault /2) + passbandWidth, pbStart + (TPBFOuter / 2) - (pbtDefault/2) + passbandWidth), rigCaps.spectAmpMax); + + //qDebug() << "Default" << pbtDefault << "Inner" << TPBFInner << "Outer" << TPBFOuter << "Pass" << passbandWidth << "Center" << passbandCenterFrequency << "CW" << cwPitch; } if (underlayMode == underlayPeakHold) @@ -4891,8 +4894,10 @@ void wfmain::handlePlotDoubleClick(QMouseEvent *me) QCPAbstractItem* item = plot->itemAt(me->pos(), true); QCPItemRect* rectItem = dynamic_cast (item); if (rectItem != nullptr) { - issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)128); - issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)128); + double pbFreq = (pbtDefault / passbandWidth) * 127.0; + qint16 newFreq = pbFreq + 128; + issueCmdUniquePriority(cmdSetTPBFInner, (unsigned char)newFreq); + issueCmdUniquePriority(cmdSetTPBFOuter, (unsigned char)newFreq); } } } @@ -6556,37 +6561,46 @@ void wfmain::receivePassband(quint16 pass) void wfmain::receiveCwPitch(unsigned char pitch) { if (currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) { - cwPitch = ((600.0 / 256.0) * pitch) + 300; + cwPitch = round((((600.0 / 255.0) * pitch) + 300)/5.0)*5.0; passbandCenterFrequency = cwPitch / 2000000.0; } + qDebug() << "CW" << pitch << "Pitch" << cwPitch; } void wfmain::receiveTPBFInner(unsigned char level) { - /* - * This is written like this as although PBT is supposed to be sent in 50Hz steps, + * This is written like this as although PBT is supposed to be sent in 25Hz steps, * sometimes it sends the 'nearest' value. This results in math errors. - * By multiplying the MHz value by 20000 with rounding, then dividing this value - * by 20000, we are guaranteed to get a frequency value that matches the step size. + * In CW mode, the value is also dependant on the CW Pitch setting */ qint16 shift = (qint16)(level - 128); - //TPBFInner = (double)(shift / 127.0) * (passbandWidth); - TPBFInner = ceil((shift / 127.0) * (passbandWidth) * 20000.0) / 20000.0; - qDebug() << "Inner" << level << "TPBFInner" << TPBFInner; + double tempVar = ceil((shift / 127.0) * passbandWidth * 20000.0) / 20000.0; + // tempVar now contains value to the nearest 50Hz If CW mode, add/remove the cwPitch. + double pitch = 0.0; + if ((currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) && passbandWidth > 0.0006) + { + pitch = (600.0 - cwPitch) / 1000000.0; + } + TPBFInner = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz. + //qDebug() << "Inner" << level << "TPBFInner" << TPBFInner; } void wfmain::receiveTPBFOuter(unsigned char level) { - /* - * This is written like this as although PBT is supposed to be sent in 50Hz steps, + * This is written like this as although PBT is supposed to be sent in 25Hz steps, * sometimes it sends the 'nearest' value. This results in math errors. - * By multiplying the MHz value by 20000 with rounding, then dividing this value - * by 20000, we are guaranteed to get a frequency value that matches the step size. + * In CW mode, the value is also dependant on the CW Pitch setting */ qint16 shift = (qint16)(level - 128); - TPBFOuter = ceil((shift / 127.0) * (passbandWidth) * 20000.0) / 20000.0; - //TPBFOuter = (double)(shift / 127.0) * (passbandWidth); - qDebug() << "Outer" << level << "TPBFOuter" << TPBFOuter; + double tempVar = ceil((shift / 127.0) * passbandWidth * 20000.0) / 20000.0; + // tempVar now contains value to the nearest 50Hz If CW mode, add/remove the cwPitch. + double pitch = 0.0; + if ((currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) && passbandWidth > 0.0006) + { + pitch = (600.0 - cwPitch) / 1000000.0; + } + TPBFOuter = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz. + //qDebug() << "Outer" << level << "TPBFOuter" << TPBFOuter; } diff --git a/wfmain.h b/wfmain.h index c90ad0e..1506d01 100644 --- a/wfmain.h +++ b/wfmain.h @@ -1111,7 +1111,9 @@ private: double TPBFInner = 0.0; double TPBFOuter = 0.0; double passbandCenterFrequency = 0.0; + double pbtDefault = 0.0; quint16 cwPitch = 600; + SERVERCONFIG serverConfig; void serverAddUserLine(const QString& user, const QString& pass, const int& type); From 4b40e20d9825e66c7b7cd77371d3f1e8801f06ae Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 25 Jan 2023 15:39:01 +0000 Subject: [PATCH 03/11] Remove some debugging --- wfmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index e224e66..cb6f5d9 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6597,7 +6597,7 @@ void wfmain::receiveCwPitch(unsigned char pitch) { cwPitch = round((((600.0 / 255.0) * pitch) + 300)/5.0)*5.0; passbandCenterFrequency = cwPitch / 2000000.0; } - qDebug() << "CW" << pitch << "Pitch" << cwPitch; + //qDebug() << "CW" << pitch << "Pitch" << cwPitch; } void wfmain::receiveTPBFInner(unsigned char level) { From ded6bd1adeba5790b1457fa1afcae651f322f045 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 25 Jan 2023 18:01:24 +0000 Subject: [PATCH 04/11] Add CW Speed spinbox to CW sender --- cwsender.cpp | 16 ++++ cwsender.h | 4 + cwsender.ui | 220 ++++++++++++++++++++++++++++++----------------- rigcommander.cpp | 24 ++++++ rigcommander.h | 3 + wfmain.cpp | 17 +++- wfmain.h | 1 + 7 files changed, 202 insertions(+), 83 deletions(-) diff --git a/cwsender.cpp b/cwsender.cpp index 7d64554..60fd89b 100644 --- a/cwsender.cpp +++ b/cwsender.cpp @@ -41,6 +41,13 @@ void cwSender::handleKeySpeed(unsigned char wpm) } } +void cwSender::handlePitch(unsigned char pitch) { + quint16 cwPitch = round((((600.0 / 255.0) * pitch) + 300) / 5.0) * 5.0; + ui->pitchSpin->blockSignals(true); + ui->pitchSpin->setValue(cwPitch); + ui->pitchSpin->blockSignals(false); +} + void cwSender::handleBreakInMode(unsigned char b) { if(b < 3) @@ -107,6 +114,15 @@ void cwSender::on_wpmSpin_valueChanged(int wpm) emit setKeySpeed((unsigned char)wpm); } +void cwSender::on_pitchSpin_valueChanged(int arg1) +{ + // quint16 cwPitch = round((((600.0 / 255.0) * pitch) + 300) / 5.0) * 5.0; + unsigned char pitch = 0; + pitch = ceil((arg1 - 300) * (255.0 / 600.0)); + qDebug() << "Setting pitch" << pitch; + emit setPitch(pitch); +} + void cwSender::on_macro1btn_clicked() { processMacroButton(1, ui->macro1btn); diff --git a/cwsender.h b/cwsender.h index 2f77f9d..237b4f9 100644 --- a/cwsender.h +++ b/cwsender.h @@ -27,11 +27,13 @@ signals: void sendCW(QString cwMessage); void stopCW(); void setKeySpeed(unsigned char wpm); + void setPitch(unsigned char pitch); void setBreakInMode(unsigned char b); void getCWSettings(); public slots: void handleKeySpeed(unsigned char wpm); + void handlePitch(unsigned char pitch); void handleBreakInMode(unsigned char b); void handleCurrentModeUpdate(mode_kind mode); @@ -47,6 +49,8 @@ private slots: void on_wpmSpin_valueChanged(int arg1); + void on_pitchSpin_valueChanged(int arg1); + void on_macro1btn_clicked(); void on_macro2btn_clicked(); diff --git a/cwsender.ui b/cwsender.ui index 29093bc..900684f 100644 --- a/cwsender.ui +++ b/cwsender.ui @@ -6,7 +6,7 @@ 0 0 - 681 + 636 451 @@ -18,23 +18,7 @@ - - - - Qt::NoFocus - - - CW Transmission Transcript - - - false - - - true - - - - + Macros @@ -177,45 +161,6 @@ - - - - Break In - - - - - - - Stop sending CW - - - Stop - - - - - - - <html><head/><body><p>Set the desired break-in mode:</p><p>1. None: You must manually key and unkey the radio.</p><p>2. Semi: Transmit is automatic and switches to receive at the end of the text.</p><p>3. Full: Same as semi, but with breaks between characters when possible.</p></body></html> - - - - Off - - - - - Semi - - - - - Full - - - - @@ -238,29 +183,6 @@ - - - - WPM: - - - - - - - Set the Words Per Minute - - - 6 - - - 48 - - - 20 - - - @@ -274,6 +196,144 @@ + + + + Qt::NoFocus + + + CW Transmission Transcript + + + false + + + true + + + + + + + Stop sending CW + + + Stop + + + + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + <html><head/><body><p>Set the desired break-in mode:</p><p>1. None: You must manually key and unkey the radio.</p><p>2. Semi: Transmit is automatic and switches to receive at the end of the text.</p><p>3. Full: Same as semi, but with breaks between characters when possible.</p></body></html> + + + + Off + + + + + Semi + + + + + Full + + + + + + + + WPM: + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Set the Words Per Minute + + + 6 + + + 48 + + + 20 + + + + + + + Break In + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + 300 + + + 900 + + + 5 + + + QAbstractSpinBox::DefaultStepType + + + 600 + + + + + + + PITCH (Hz): + + + Qt::AlignCenter + + + + + diff --git a/rigcommander.cpp b/rigcommander.cpp index 0f441e0..5d3a8ef 100644 --- a/rigcommander.cpp +++ b/rigcommander.cpp @@ -936,6 +936,14 @@ void rigCommander::getCwPitch() prepDataAndSend(payload); } +void rigCommander::setCwPitch(unsigned char pitch) +{ + QByteArray payload; + payload.setRawData("\x14\x09", 2); + payload.append(bcdEncodeInt(pitch)); + prepDataAndSend(payload); +} + void rigCommander::getPskTone() { QByteArray payload; @@ -943,6 +951,14 @@ void rigCommander::getPskTone() prepDataAndSend(payload); } +void rigCommander::setPskTone(unsigned char tone) +{ + QByteArray payload; + payload.setRawData("\x1a\x05\x00\x44", 4); + payload.append(bcdEncodeInt(tone)); + prepDataAndSend(payload); +} + void rigCommander::getRttyMark() { QByteArray payload; @@ -950,6 +966,14 @@ void rigCommander::getRttyMark() prepDataAndSend(payload); } +void rigCommander::setRttyMark(unsigned char mark) +{ + QByteArray payload; + payload.setRawData("\x1a\x05\x00\x41", 4); + payload.append(bcdEncodeInt(mark)); + prepDataAndSend(payload); +} + void rigCommander::getTransmitFrequency() { QByteArray payload; diff --git a/rigcommander.h b/rigcommander.h index 47d563a..7ca3ff2 100644 --- a/rigcommander.h +++ b/rigcommander.h @@ -122,8 +122,11 @@ public slots: void getPassband(); void getCwPitch(); + void setCwPitch(unsigned char pitch); void getPskTone(); + void setPskTone(unsigned char tone); void getRttyMark(); + void setRttyMark(unsigned char mark); // Repeater: void setDuplexMode(duplexMode dm); diff --git a/wfmain.cpp b/wfmain.cpp index cb6f5d9..fe04ed2 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -347,10 +347,13 @@ void wfmain::rigConnections() connect(this, SIGNAL(stopCW()), rig, SLOT(sendStopCW())); connect(this, SIGNAL(setKeySpeed(unsigned char)), rig, SLOT(setKeySpeed(unsigned char))); connect(this, SIGNAL(getKeySpeed()), rig, SLOT(getKeySpeed())); + connect(this, SIGNAL(setCwPitch(unsigned char)), rig, SLOT(setCwPitch(unsigned char))); connect(this, SIGNAL(setCWBreakMode(unsigned char)), rig, SLOT(setBreakIn(unsigned char))); connect(this, SIGNAL(getCWBreakMode()), rig, SLOT(getBreakIn())); connect(this->rig, &rigCommander::haveKeySpeed, - [=](const unsigned char &wpm) { cw->handleKeySpeed(wpm);}); + [=](const unsigned char& wpm) { cw->handleKeySpeed(wpm); }); + connect(this->rig, &rigCommander::haveCwPitch, + [=](const unsigned char& speed) { cw->handlePitch(speed); }); connect(this->rig, &rigCommander::haveCWBreakMode, [=](const unsigned char &bm) { cw->handleBreakInMode(bm);}); @@ -1079,7 +1082,9 @@ void wfmain::setupMainUI() connect(this->cw, &cwSender::setBreakInMode, [=](const unsigned char &bmode) { issueCmd(cmdSetBreakMode, bmode);}); connect(this->cw, &cwSender::setKeySpeed, - [=](const unsigned char &wpm) { issueCmd(cmdSetKeySpeed, wpm);}); + [=](const unsigned char& wpm) { issueCmd(cmdSetKeySpeed, wpm); }); + connect(this->cw, &cwSender::setPitch, + [=](const unsigned char& pitch) { issueCmd(cmdSetCwPitch, pitch); }); connect(this->cw, &cwSender::getCWSettings, [=]() { issueDelayedCommand(cmdGetKeySpeed); issueDelayedCommand(cmdGetBreakMode);}); @@ -3708,6 +3713,12 @@ void wfmain::doCmd(commandtype cmddata) emit setKeySpeed(wpm); break; } + case cmdSetCwPitch: + { + unsigned char pitch = (*std::static_pointer_cast(data)); + emit setCwPitch(pitch); + break; + } case cmdSetATU: { bool atuOn = (*std::static_pointer_cast(data)); @@ -6594,7 +6605,7 @@ void wfmain::receivePassband(quint16 pass) void wfmain::receiveCwPitch(unsigned char pitch) { if (currentModeInfo.mk == modeCW || currentModeInfo.mk == modeCW_R) { - cwPitch = round((((600.0 / 255.0) * pitch) + 300)/5.0)*5.0; + cwPitch = round((((600.0 / 255.0) * pitch) + 300) / 5.0) * 5.0; passbandCenterFrequency = cwPitch / 2000000.0; } //qDebug() << "CW" << pitch << "Pitch" << cwPitch; diff --git a/wfmain.h b/wfmain.h index 264fbbb..00c1063 100644 --- a/wfmain.h +++ b/wfmain.h @@ -175,6 +175,7 @@ signals: void stopCW(); void getKeySpeed(); void setKeySpeed(unsigned char wpm); + void setCwPitch(unsigned char pitch); void setCWBreakMode(unsigned char breakMode); void getCWBreakMode(); From ea46d6c625e02c4869bd5fcd42c191f111a590f7 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 25 Jan 2023 21:22:06 +0000 Subject: [PATCH 05/11] Add math.h for cwsender --- cwsender.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cwsender.h b/cwsender.h index 237b4f9..e35875f 100644 --- a/cwsender.h +++ b/cwsender.h @@ -6,10 +6,12 @@ #include #include #include +#include #include "wfviewtypes.h" #include "logcategories.h" + namespace Ui { class cwSender; } From 49501273d02e02df7b2b1ca58be7a576daa1a19f Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 25 Jan 2023 21:37:12 +0000 Subject: [PATCH 06/11] Fix for shuttle resource files --- controllersetup.cpp | 4 ++-- resources/resources.qrc | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/controllersetup.cpp b/controllersetup.cpp index fdb359c..5bef058 100644 --- a/controllersetup.cpp +++ b/controllersetup.cpp @@ -116,11 +116,11 @@ void controllerSetup::newDevice(unsigned char devType, QVector