From e9e042fad8adf43038d97016dbdce776732b27a1 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Wed, 18 Jan 2023 22:27:06 -0800 Subject: [PATCH] Change mode selection code to use the command queue (as it should have). Beginnings of automatic sideband options. --- freqmemory.h | 32 +------------------------------- sidebandchooser.cpp | 0 sidebandchooser.h | 39 +++++++++++++++++++++++++++++++++++++++ wfmain.cpp | 15 ++++++++++++--- wfmain.h | 1 + wfview.pro | 1 + wfviewtypes.h | 30 ++++++++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 sidebandchooser.cpp create mode 100644 sidebandchooser.h diff --git a/freqmemory.h b/freqmemory.h index 0067158..58f8c7e 100644 --- a/freqmemory.h +++ b/freqmemory.h @@ -2,37 +2,7 @@ #define FREQMEMORY_H #include #include - -// 0 1 2 3 4 -//modes << "LSB" << "USB" << "AM" << "CW" << "RTTY"; -// 5 6 7 8 9 -// modes << "FM" << "CW-R" << "RTTY-R" << "LSB-D" << "USB-D"; - -enum mode_kind { - modeLSB=0x00, - modeUSB=0x01, - modeAM=0x02, - modeCW=0x03, - modeRTTY=0x04, - modeFM=0x05, - modeCW_R=0x07, - modeRTTY_R=0x08, - modePSK = 0x12, - modePSK_R = 0x13, - modeLSB_D=0x80, - modeUSB_D=0x81, - modeDV=0x17, - modeDD=0x27, - modeWFM, - modeS_AMD, - modeS_AML, - modeS_AMU, - modeP25, - modedPMR, - modeNXDN_VN, - modeNXDN_N, - modeDCR -}; +#include "wfviewtypes.h" struct mode_info { mode_kind mk; diff --git a/sidebandchooser.cpp b/sidebandchooser.cpp new file mode 100644 index 0000000..e69de29 diff --git a/sidebandchooser.h b/sidebandchooser.h new file mode 100644 index 0000000..c3c2872 --- /dev/null +++ b/sidebandchooser.h @@ -0,0 +1,39 @@ +#ifndef SIDEBANDCHOOSER_H +#define SIDEBANDCHOOSER_H + +#include "wfviewtypes.h" + +class sidebandChooser +{ +public: + sidebandChooser(); + + static inline mode_kind getMode(freqt f, mode_kind currentMode = modeUSB) { + + if((currentMode == modeLSB) || (currentMode == modeUSB) ) + { + if(f.Hz < 5000000) + { + return modeLSB; + } + if( (f.Hz >= 5000000) || (f.Hz < 5600000) ) + { + return modeUSB; + } + if( (f.Hz >= 5600000) || (f.Hz < 10000000) ) + { + return modeLSB; + } + + return modeUSB; + } else { + return currentMode; + } + } + + +private: + +}; + +#endif // SIDEBANDCHOOSER_H diff --git a/wfmain.cpp b/wfmain.cpp index c2e1522..f7b9c01 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -4885,18 +4885,23 @@ void wfmain::on_goFreqBtn_clicked() if(ok) { f.Hz = freqDbl*1E6; - issueCmd(cmdSetFreq, f); } } else { KHz = ui->freqMhzLineEdit->text().toInt(&ok); if(ok) { f.Hz = KHz*1E3; - issueCmd(cmdSetFreq, f); } } if(ok) { + mode_info m; + issueCmd(cmdSetFreq, f); + m.mk = sidebandChooser::getMode(f, currentMode); + qDebug(logSystem()) << "current mode: " << currentMode << "new mode:" << m.mk; + if(m.mk != currentMode) + issueCmd(cmdSetMode, m); + f.MHzDouble = (float)f.Hz / 1E6; freq = f; setUIFreq(); @@ -5055,7 +5060,11 @@ void wfmain::changeMode(mode_kind mode) void wfmain::changeMode(mode_kind mode, bool dataOn) { int filter = ui->modeFilterCombo->currentData().toInt(); - emit setMode((unsigned char)mode, (unsigned char)filter); + mode_info m; + m.filter = (unsigned char) filter; + m.reg = (unsigned char) mode; + issueCmd(cmdSetMode, m); + //emit setMode((unsigned char)mode, (unsigned char)filter); currentMode = mode; diff --git a/wfmain.h b/wfmain.h index 3db01a1..3e7175b 100644 --- a/wfmain.h +++ b/wfmain.h @@ -44,6 +44,7 @@ #include "loggingwindow.h" #include "cluster.h" #include "audiodevices.h" +#include "sidebandchooser.h" #include #include diff --git a/wfview.pro b/wfview.pro index b041382..94b7d66 100644 --- a/wfview.pro +++ b/wfview.pro @@ -237,6 +237,7 @@ HEADERS += wfmain.h \ rigcommander.h \ freqmemory.h \ rigidentities.h \ + sidebandchooser.h \ udpbase.h \ udphandler.h \ udpcivdata.h \ diff --git a/wfviewtypes.h b/wfviewtypes.h index 4df1add..db229f8 100644 --- a/wfviewtypes.h +++ b/wfviewtypes.h @@ -1,6 +1,10 @@ #ifndef WFVIEWTYPES_H #define WFVIEWTYPES_H +#include +#include +#include + enum underlay_t { underlayNone, underlayPeakHold, underlayPeakBuffer, underlayAverageBuffer }; enum meterKind { @@ -28,6 +32,32 @@ enum spectrumMode { spectModeUnknown=0xff }; +enum mode_kind { + modeLSB=0x00, + modeUSB=0x01, + modeAM=0x02, + modeCW=0x03, + modeRTTY=0x04, + modeFM=0x05, + modeCW_R=0x07, + modeRTTY_R=0x08, + modePSK = 0x12, + modePSK_R = 0x13, + modeLSB_D=0x80, + modeUSB_D=0x81, + modeDV=0x17, + modeDD=0x27, + modeWFM, + modeS_AMD, + modeS_AML, + modeS_AMU, + modeP25, + modedPMR, + modeNXDN_VN, + modeNXDN_N, + modeDCR +}; + struct freqt { quint64 Hz; double MHzDouble;