2018-06-19 19:58:52 +00:00
# include "wfmain.h"
# include "ui_wfmain.h"
# include "commhandler.h"
2018-11-24 08:10:05 +00:00
# include "rigidentities.h"
2021-02-23 21:21:22 +00:00
# include "logcategories.h"
2018-06-19 19:58:52 +00:00
2020-03-12 03:58:31 +00:00
// This code is copyright 2017-2020 Elliott H. Liggett
2019-01-24 01:19:35 +00:00
// All rights reserved
2021-02-02 09:05:59 +00:00
wfmain : : wfmain ( const QString serialPortCL , const QString hostCL , QWidget * parent ) :
2018-06-19 19:58:52 +00:00
QMainWindow ( parent ) ,
ui ( new Ui : : wfmain )
{
2020-01-05 01:12:35 +00:00
QGuiApplication : : setApplicationDisplayName ( " wfview " ) ;
QGuiApplication : : setApplicationName ( QString ( " wfview " ) ) ;
2019-02-09 00:19:36 +00:00
2020-03-13 03:06:33 +00:00
setWindowIcon ( QIcon ( QString ( " :resources/wfview.png " ) ) ) ;
2018-06-19 19:58:52 +00:00
ui - > setupUi ( this ) ;
2018-06-20 06:45:56 +00:00
theParent = parent ;
2018-11-28 06:02:37 +00:00
2020-01-05 01:12:35 +00:00
setWindowTitle ( QString ( " wfview " ) ) ;
2019-02-09 00:19:36 +00:00
2021-02-02 09:05:59 +00:00
this - > serialPortCL = serialPortCL ;
this - > hostCL = hostCL ;
2021-02-11 05:22:38 +00:00
cal = new calibrationWindow ( ) ;
2021-02-13 18:02:45 +00:00
sat = new satelliteSetup ( ) ;
2021-02-14 18:32:58 +00:00
srv = new udpServerSetup ( ) ;
2021-02-13 18:02:45 +00:00
2021-02-16 16:16:46 +00:00
connect ( this , SIGNAL ( sendServerConfig ( SERVERCONFIG ) ) , srv , SLOT ( receiveServerConfig ( SERVERCONFIG ) ) ) ;
connect ( srv , SIGNAL ( serverConfig ( SERVERCONFIG , bool ) ) , this , SLOT ( serverConfigRequested ( SERVERCONFIG , bool ) ) ) ;
2021-02-28 20:10:07 +00:00
2021-02-11 05:22:38 +00:00
2021-01-25 00:16:38 +00:00
haveRigCaps = false ;
2019-01-24 01:19:35 +00:00
ui - > bandStkLastUsedBtn - > setVisible ( false ) ;
ui - > bandStkVoiceBtn - > setVisible ( false ) ;
ui - > bandStkDataBtn - > setVisible ( false ) ;
ui - > bandStkCWBtn - > setVisible ( false ) ;
2018-11-28 06:02:37 +00:00
keyF1 = new QShortcut ( this ) ;
keyF1 - > setKey ( Qt : : Key_F1 ) ;
connect ( keyF1 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF1 ( ) ) ) ;
keyF2 = new QShortcut ( this ) ;
keyF2 - > setKey ( Qt : : Key_F2 ) ;
connect ( keyF2 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF2 ( ) ) ) ;
keyF3 = new QShortcut ( this ) ;
keyF3 - > setKey ( Qt : : Key_F3 ) ;
connect ( keyF3 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF3 ( ) ) ) ;
keyF4 = new QShortcut ( this ) ;
keyF4 - > setKey ( Qt : : Key_F4 ) ;
connect ( keyF4 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF4 ( ) ) ) ;
2019-01-24 01:19:35 +00:00
keyF5 = new QShortcut ( this ) ;
keyF5 - > setKey ( Qt : : Key_F5 ) ;
connect ( keyF5 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF5 ( ) ) ) ;
2019-01-28 23:36:17 +00:00
keyF6 = new QShortcut ( this ) ;
keyF6 - > setKey ( Qt : : Key_F6 ) ;
connect ( keyF6 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF6 ( ) ) ) ;
keyF7 = new QShortcut ( this ) ;
keyF7 - > setKey ( Qt : : Key_F7 ) ;
connect ( keyF7 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF7 ( ) ) ) ;
keyF8 = new QShortcut ( this ) ;
keyF8 - > setKey ( Qt : : Key_F8 ) ;
connect ( keyF8 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF8 ( ) ) ) ;
keyF9 = new QShortcut ( this ) ;
keyF9 - > setKey ( Qt : : Key_F9 ) ;
connect ( keyF9 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF9 ( ) ) ) ;
keyF10 = new QShortcut ( this ) ;
keyF10 - > setKey ( Qt : : Key_F10 ) ;
connect ( keyF10 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF10 ( ) ) ) ;
2019-02-01 20:21:54 +00:00
keyF11 = new QShortcut ( this ) ;
keyF11 - > setKey ( Qt : : Key_F11 ) ;
connect ( keyF11 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF11 ( ) ) ) ;
keyF12 = new QShortcut ( this ) ;
keyF12 - > setKey ( Qt : : Key_F12 ) ;
connect ( keyF12 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF12 ( ) ) ) ;
keyControlT = new QShortcut ( this ) ;
keyControlT - > setKey ( Qt : : CTRL + Qt : : Key_T ) ;
connect ( keyControlT , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlT ( ) ) ) ;
keyControlR = new QShortcut ( this ) ;
keyControlR - > setKey ( Qt : : CTRL + Qt : : Key_R ) ;
connect ( keyControlR , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlR ( ) ) ) ;
keyControlI = new QShortcut ( this ) ;
keyControlI - > setKey ( Qt : : CTRL + Qt : : Key_I ) ;
connect ( keyControlI , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlI ( ) ) ) ;
keyControlU = new QShortcut ( this ) ;
keyControlU - > setKey ( Qt : : CTRL + Qt : : Key_U ) ;
connect ( keyControlU , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlU ( ) ) ) ;
2018-11-28 06:02:37 +00:00
keyStar = new QShortcut ( this ) ;
keyStar - > setKey ( Qt : : Key_Asterisk ) ;
connect ( keyStar , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutStar ( ) ) ) ;
2019-01-28 23:46:14 +00:00
keySlash = new QShortcut ( this ) ;
keySlash - > setKey ( Qt : : Key_Slash ) ;
connect ( keySlash , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutSlash ( ) ) ) ;
2019-02-04 05:51:30 +00:00
keyMinus = new QShortcut ( this ) ;
keyMinus - > setKey ( Qt : : Key_Minus ) ;
connect ( keyMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutMinus ( ) ) ) ;
keyPlus = new QShortcut ( this ) ;
keyPlus - > setKey ( Qt : : Key_Plus ) ;
connect ( keyPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPlus ( ) ) ) ;
2019-02-04 18:32:16 +00:00
keyShiftMinus = new QShortcut ( this ) ;
2019-02-06 00:11:25 +00:00
keyShiftMinus - > setKey ( Qt : : SHIFT + Qt : : Key_Minus ) ;
2019-02-04 18:32:16 +00:00
connect ( keyShiftMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutShiftMinus ( ) ) ) ;
keyShiftPlus = new QShortcut ( this ) ;
2019-02-06 00:11:25 +00:00
keyShiftPlus - > setKey ( Qt : : SHIFT + Qt : : Key_Plus ) ;
2019-02-04 18:32:16 +00:00
connect ( keyShiftPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutShiftPlus ( ) ) ) ;
2019-02-06 00:11:25 +00:00
keyControlMinus = new QShortcut ( this ) ;
keyControlMinus - > setKey ( Qt : : CTRL + Qt : : Key_Minus ) ;
connect ( keyControlMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlMinus ( ) ) ) ;
keyControlPlus = new QShortcut ( this ) ;
keyControlPlus - > setKey ( Qt : : CTRL + Qt : : Key_Plus ) ;
connect ( keyControlPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlPlus ( ) ) ) ;
2020-03-10 18:08:36 +00:00
keyQuit = new QShortcut ( this ) ;
keyQuit - > setKey ( Qt : : CTRL + Qt : : Key_Q ) ;
connect ( keyQuit , SIGNAL ( activated ( ) ) , this , SLOT ( on_exitBtn_clicked ( ) ) ) ;
2020-03-17 22:15:01 +00:00
keyPageUp = new QShortcut ( this ) ;
keyPageUp - > setKey ( Qt : : Key_PageUp ) ;
connect ( keyPageUp , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPageUp ( ) ) ) ;
keyPageDown = new QShortcut ( this ) ;
keyPageDown - > setKey ( Qt : : Key_PageDown ) ;
connect ( keyPageDown , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPageDown ( ) ) ) ;
2019-02-07 18:15:10 +00:00
keyF = new QShortcut ( this ) ;
keyF - > setKey ( Qt : : Key_F ) ;
connect ( keyF , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF ( ) ) ) ;
2019-02-06 00:11:25 +00:00
2019-02-07 18:15:10 +00:00
keyM = new QShortcut ( this ) ;
keyM - > setKey ( Qt : : Key_M ) ;
connect ( keyM , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutM ( ) ) ) ;
2019-02-06 00:11:25 +00:00
2021-02-04 10:27:30 +00:00
// Enumerate audio devices, need to do before settings are loaded.
2021-02-08 16:53:26 +00:00
const auto audioOutputs = QAudioDeviceInfo : : availableDevices ( QAudio : : AudioOutput ) ;
for ( const QAudioDeviceInfo & deviceInfo : audioOutputs ) {
2021-02-04 10:27:30 +00:00
ui - > audioOutputCombo - > addItem ( deviceInfo . deviceName ( ) ) ;
}
2021-02-08 16:53:26 +00:00
const auto audioInputs = QAudioDeviceInfo : : availableDevices ( QAudio : : AudioInput ) ;
for ( const QAudioDeviceInfo & deviceInfo : audioInputs ) {
ui - > audioInputCombo - > addItem ( deviceInfo . deviceName ( ) ) ;
}
2018-11-25 06:21:36 +00:00
setDefaultColors ( ) ; // set of UI colors with defaults populated
2018-11-30 06:31:20 +00:00
setDefPrefs ( ) ; // other default options
2018-11-29 21:41:42 +00:00
loadSettings ( ) ; // Look for saved preferences
2021-02-22 07:58:23 +00:00
setTuningSteps ( ) ; // TODO: Combine into preferences
2018-11-29 21:41:42 +00:00
2021-03-01 05:41:27 +00:00
ui - > spectrumModeCombo - > addItem ( " Center " , ( spectrumMode ) spectModeCenter ) ;
ui - > spectrumModeCombo - > addItem ( " Fixed " , ( spectrumMode ) spectModeFixed ) ;
ui - > spectrumModeCombo - > addItem ( " Scroll-C " , ( spectrumMode ) spectModeScrollC ) ;
ui - > spectrumModeCombo - > addItem ( " Scroll-F " , ( spectrumMode ) spectModeScrollF ) ;
2018-11-29 21:41:42 +00:00
// if setting for serial port is "auto" then...
2021-01-30 06:09:09 +00:00
// if(prefs.serialPortRadio == QString("auto"))
// {
// // Find the ICOM IC-7300.
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Searching for serial port...";
2021-01-30 06:09:09 +00:00
// QDirIterator it("/dev/serial", QStringList() << "*IC-7300*", QDir::Files, QDirIterator::Subdirectories);
// while (it.hasNext())
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << it.next();
2021-01-30 06:09:09 +00:00
// // if (it.isEmpty()) // fail or default to ttyUSB0 if present
// // iterator might not make sense
// serialPortRig = it.filePath(); // first? last?
// if(serialPortRig.isEmpty())
// {
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Cannot find IC-7300 serial port. Trying /dev/ttyUSB0";
2021-01-30 06:09:09 +00:00
// serialPortRig = QString("/dev/ttyUSB0");
// }
// // end finding the 7300 code
// } else {
// serialPortRig = prefs.serialPortRadio;
// }
2018-11-29 21:41:42 +00:00
2021-02-16 16:16:46 +00:00
// Start server if enabled in config
if ( serverConfig . enabled ) {
udp = new udpServer ( serverConfig ) ;
serverThread = new QThread ( this ) ;
udp - > moveToThread ( serverThread ) ;
connect ( this , SIGNAL ( initServer ( ) ) , udp , SLOT ( init ( ) ) ) ;
connect ( serverThread , SIGNAL ( finished ( ) ) , udp , SLOT ( deleteLater ( ) ) ) ;
2021-02-18 09:14:41 +00:00
2021-02-16 16:16:46 +00:00
serverThread - > start ( ) ;
emit initServer ( ) ;
2021-02-28 20:10:07 +00:00
connect ( this , SIGNAL ( sendRigCaps ( rigCapabilities ) ) , udp , SLOT ( receiveRigCaps ( rigCapabilities ) ) ) ;
2021-02-16 16:16:46 +00:00
}
2018-11-29 21:41:42 +00:00
2018-06-19 19:58:52 +00:00
plot = ui - > plot ; // rename it waterfall.
wf = ui - > waterfall ;
2018-06-20 06:45:56 +00:00
tracer = new QCPItemTracer ( plot ) ;
//tracer->setGraphKey(5.5);
tracer - > setInterpolating ( true ) ;
2018-11-07 23:54:03 +00:00
tracer - > setStyle ( QCPItemTracer : : tsCrosshair ) ;
2018-06-20 06:45:56 +00:00
tracer - > setPen ( QPen ( Qt : : green ) ) ;
tracer - > setBrush ( Qt : : green ) ;
2018-11-07 23:54:03 +00:00
tracer - > setSize ( 30 ) ;
2018-06-19 19:58:52 +00:00
2021-01-25 00:16:38 +00:00
// spectWidth = 475; // fixed for now
// wfLength = 160; // fixed for now, time-length of waterfall
2018-06-19 19:58:52 +00:00
2021-01-25 00:16:38 +00:00
// // Initialize before use!
2018-06-19 19:58:52 +00:00
2021-01-25 00:16:38 +00:00
// QByteArray empty((int)spectWidth, '\x01');
// spectrumPeaks = QByteArray( (int)spectWidth, '\x01' );
// for(quint16 i=0; i<wfLength; i++)
// {
// wfimage.append(empty);
// }
2018-06-19 19:58:52 +00:00
2021-02-13 06:42:34 +00:00
ui - > modeSelectCombo - > addItem ( " LSB " , 0x00 ) ;
ui - > modeSelectCombo - > addItem ( " USB " , 0x01 ) ;
ui - > modeSelectCombo - > addItem ( " AM " , 0x02 ) ;
ui - > modeSelectCombo - > addItem ( " CW " , 0x03 ) ;
ui - > modeSelectCombo - > addItem ( " RTTY " , 0x04 ) ;
ui - > modeSelectCombo - > addItem ( " FM " , 0x05 ) ;
ui - > modeSelectCombo - > addItem ( " CW-R " , 0x07 ) ;
ui - > modeSelectCombo - > addItem ( " RTTY-R " , 0x08 ) ;
ui - > modeFilterCombo - > addItem ( " 1 " , 1 ) ;
ui - > modeFilterCombo - > addItem ( " 2 " , 2 ) ;
ui - > modeFilterCombo - > addItem ( " 3 " , 3 ) ;
2021-02-13 18:02:45 +00:00
ui - > modeFilterCombo - > addItem ( " Setup... " , 99 ) ;
2021-02-13 06:42:34 +00:00
2021-02-11 17:21:17 +00:00
2018-06-19 19:58:52 +00:00
spans < < " 2.5k " < < " 5.0k " < < " 10k " < < " 25k " ;
spans < < " 50k " < < " 100k " < < " 250k " < < " 500k " ;
ui - > scopeBWCombo - > insertItems ( 0 , spans ) ;
2021-02-27 04:12:17 +00:00
edges < < " 1 " < < " 2 " < < " 3 " < < " 4 " ; // yep
2021-02-22 00:24:48 +00:00
ui - > scopeEdgeCombo - > insertItems ( 0 , edges ) ;
2018-06-19 19:58:52 +00:00
2018-06-20 06:45:56 +00:00
ui - > splitter - > setHandleWidth ( 5 ) ;
2020-04-23 22:22:23 +00:00
ui - > rfGainSlider - > setTickInterval ( 100 ) ;
ui - > rfGainSlider - > setSingleStep ( 100 ) ;
ui - > afGainSlider - > setSingleStep ( 100 ) ;
ui - > afGainSlider - > setSingleStep ( 100 ) ;
2021-02-05 20:26:18 +00:00
rigStatus = new QLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( rigStatus ) ;
2021-02-02 09:05:59 +00:00
ui - > statusBar - > showMessage ( " Connecting to rig... " , 1000 ) ;
2018-06-20 06:45:56 +00:00
2021-03-01 16:26:59 +00:00
pttLed = new QLedLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( pttLed ) ;
pttLed - > setState ( QLedLabel : : State : : StateOk ) ;
connectedLed = new QLedLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( connectedLed ) ;
rigName = new QLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( rigName ) ;
rigName - > setText ( " NONE " ) ;
rigName - > setFixedWidth ( 40 ) ;
2021-01-30 08:44:36 +00:00
delayedCommand = new QTimer ( this ) ;
delayedCommand - > setInterval ( 250 ) ; // 250ms until we find rig civ and id, then 100ms.
delayedCommand - > setSingleShot ( true ) ;
connect ( delayedCommand , SIGNAL ( timeout ( ) ) , this , SLOT ( runDelayedCommand ( ) ) ) ;
2021-02-21 04:41:19 +00:00
periodicPollingTimer = new QTimer ( this ) ;
2021-02-26 08:01:23 +00:00
periodicPollingTimer - > setInterval ( 10 ) ;
2021-02-21 04:41:19 +00:00
periodicPollingTimer - > setSingleShot ( false ) ;
connect ( periodicPollingTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( runPeriodicCommands ( ) ) ) ;
2021-01-30 06:09:09 +00:00
openRig ( ) ;
2018-11-30 06:19:23 +00:00
2021-01-25 00:16:38 +00:00
qRegisterMetaType < rigCapabilities > ( ) ;
2021-02-19 05:47:19 +00:00
qRegisterMetaType < duplexMode > ( ) ;
qRegisterMetaType < rigInput > ( ) ;
2021-02-21 04:41:19 +00:00
qRegisterMetaType < meterKind > ( ) ;
2021-03-01 05:41:27 +00:00
qRegisterMetaType < spectrumMode > ( ) ;
2018-06-19 19:58:52 +00:00
connect ( rig , SIGNAL ( haveFrequency ( double ) ) , this , SLOT ( receiveFreq ( double ) ) ) ;
connect ( this , SIGNAL ( getFrequency ( ) ) , rig , SLOT ( getFrequency ( ) ) ) ;
connect ( this , SIGNAL ( getMode ( ) ) , rig , SLOT ( getMode ( ) ) ) ;
2018-06-25 07:34:33 +00:00
connect ( this , SIGNAL ( getDataMode ( ) ) , rig , SLOT ( getDataMode ( ) ) ) ;
2018-11-07 23:54:03 +00:00
connect ( this , SIGNAL ( setDataMode ( bool ) ) , rig , SLOT ( setDataMode ( bool ) ) ) ;
2018-11-16 22:08:21 +00:00
connect ( this , SIGNAL ( getBandStackReg ( char , char ) ) , rig , SLOT ( getBandStackReg ( char , char ) ) ) ;
2018-11-07 23:54:03 +00:00
connect ( rig , SIGNAL ( havePTTStatus ( bool ) ) , this , SLOT ( receivePTTstatus ( bool ) ) ) ;
2019-02-10 07:13:18 +00:00
connect ( this , SIGNAL ( setPTT ( bool ) ) , rig , SLOT ( setPTT ( bool ) ) ) ;
2021-02-15 04:45:48 +00:00
connect ( this , SIGNAL ( getPTT ( ) ) , rig , SLOT ( getPTT ( ) ) ) ;
2018-11-16 22:08:21 +00:00
connect ( rig , SIGNAL ( haveBandStackReg ( float , char , bool ) ) , this , SLOT ( receiveBandStackReg ( float , char , bool ) ) ) ;
2018-06-19 19:58:52 +00:00
connect ( this , SIGNAL ( getDebug ( ) ) , rig , SLOT ( getDebug ( ) ) ) ;
2018-12-18 22:34:04 +00:00
2018-06-19 19:58:52 +00:00
connect ( this , SIGNAL ( spectOutputDisable ( ) ) , rig , SLOT ( disableSpectOutput ( ) ) ) ;
connect ( this , SIGNAL ( spectOutputEnable ( ) ) , rig , SLOT ( enableSpectOutput ( ) ) ) ;
connect ( this , SIGNAL ( scopeDisplayDisable ( ) ) , rig , SLOT ( disableSpectrumDisplay ( ) ) ) ;
connect ( this , SIGNAL ( scopeDisplayEnable ( ) ) , rig , SLOT ( enableSpectrumDisplay ( ) ) ) ;
2021-02-14 07:42:51 +00:00
connect ( rig , SIGNAL ( haveMode ( unsigned char , unsigned char ) ) , this , SLOT ( receiveMode ( unsigned char , unsigned char ) ) ) ;
2018-11-16 22:08:21 +00:00
connect ( rig , SIGNAL ( haveDataMode ( bool ) ) , this , SLOT ( receiveDataModeStatus ( bool ) ) ) ;
2021-02-19 05:47:19 +00:00
connect ( this , SIGNAL ( getDuplexMode ( ) ) , rig , SLOT ( getDuplexMode ( ) ) ) ;
connect ( this , SIGNAL ( setDuplexMode ( duplexMode ) ) , rig , SLOT ( setDuplexMode ( duplexMode ) ) ) ;
connect ( rig , SIGNAL ( haveDuplexMode ( duplexMode ) ) , this , SLOT ( receiveDuplexMode ( duplexMode ) ) ) ;
2021-02-19 08:14:40 +00:00
connect ( this , SIGNAL ( getModInput ( bool ) ) , rig , SLOT ( getModInput ( bool ) ) ) ;
connect ( rig , SIGNAL ( haveModInput ( rigInput , bool ) ) , this , SLOT ( receiveModInput ( rigInput , bool ) ) ) ;
connect ( this , SIGNAL ( setModInput ( rigInput , bool ) ) , rig , SLOT ( setModInput ( rigInput , bool ) ) ) ;
2018-06-19 19:58:52 +00:00
connect ( rig , SIGNAL ( haveSpectrumData ( QByteArray , double , double ) ) , this , SLOT ( receiveSpectrumData ( QByteArray , double , double ) ) ) ;
2021-03-01 05:41:27 +00:00
connect ( rig , SIGNAL ( haveSpectrumMode ( spectrumMode ) ) , this , SLOT ( receiveSpectrumMode ( spectrumMode ) ) ) ;
connect ( this , SIGNAL ( setScopeMode ( spectrumMode ) ) , rig , SLOT ( setSpectrumMode ( spectrumMode ) ) ) ;
connect ( this , SIGNAL ( getScopeMode ( ) ) , rig , SLOT ( getScopeMode ( ) ) ) ;
2018-06-19 19:58:52 +00:00
connect ( this , SIGNAL ( setFrequency ( double ) ) , rig , SLOT ( setFrequency ( double ) ) ) ;
connect ( this , SIGNAL ( setScopeEdge ( char ) ) , rig , SLOT ( setScopeEdge ( char ) ) ) ;
connect ( this , SIGNAL ( setScopeSpan ( char ) ) , rig , SLOT ( setScopeSpan ( char ) ) ) ;
2018-12-18 22:34:04 +00:00
connect ( this , SIGNAL ( getScopeMode ( ) ) , rig , SLOT ( getScopeMode ( ) ) ) ;
connect ( this , SIGNAL ( getScopeEdge ( ) ) , rig , SLOT ( getScopeEdge ( ) ) ) ;
connect ( this , SIGNAL ( getScopeSpan ( ) ) , rig , SLOT ( getScopeSpan ( ) ) ) ;
2021-02-06 07:58:17 +00:00
connect ( this , SIGNAL ( setScopeFixedEdge ( double , double , unsigned char ) ) , rig , SLOT ( setSpectrumBounds ( double , double , unsigned char ) ) ) ;
2018-12-18 22:34:04 +00:00
2021-02-13 18:02:45 +00:00
connect ( this , SIGNAL ( setMode ( unsigned char , unsigned char ) ) , rig , SLOT ( setMode ( unsigned char , unsigned char ) ) ) ;
2021-02-16 01:15:28 +00:00
// Levels (read and write)
2021-02-16 04:32:14 +00:00
// Levels: Query:
2021-02-16 01:15:28 +00:00
connect ( this , SIGNAL ( getLevels ( ) ) , rig , SLOT ( getLevels ( ) ) ) ;
2018-11-16 22:08:21 +00:00
connect ( this , SIGNAL ( getRfGain ( ) ) , rig , SLOT ( getRfGain ( ) ) ) ;
2018-11-17 06:19:44 +00:00
connect ( this , SIGNAL ( getAfGain ( ) ) , rig , SLOT ( getAfGain ( ) ) ) ;
2021-02-16 04:32:14 +00:00
connect ( this , SIGNAL ( getSql ( ) ) , rig , SLOT ( getSql ( ) ) ) ;
connect ( this , SIGNAL ( getTxPower ( ) ) , rig , SLOT ( getTxLevel ( ) ) ) ;
connect ( this , SIGNAL ( getMicGain ( ) ) , rig , SLOT ( getMicGain ( ) ) ) ;
2021-02-16 06:33:21 +00:00
connect ( this , SIGNAL ( getSpectrumRefLevel ( ) ) , rig , SLOT ( getSpectrumRefLevel ( ) ) ) ;
2021-02-20 08:05:23 +00:00
connect ( this , SIGNAL ( getModInputLevel ( rigInput ) ) , rig , SLOT ( getModInputLevel ( rigInput ) ) ) ;
2021-02-16 04:32:14 +00:00
// Levels: Set:
2018-11-17 06:19:44 +00:00
connect ( this , SIGNAL ( setRfGain ( unsigned char ) ) , rig , SLOT ( setRfGain ( unsigned char ) ) ) ;
connect ( this , SIGNAL ( setAfGain ( unsigned char ) ) , rig , SLOT ( setAfGain ( unsigned char ) ) ) ;
2021-02-16 04:32:14 +00:00
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 ) ) ) ;
2021-02-16 05:40:31 +00:00
connect ( this , SIGNAL ( setSpectrumRefLevel ( int ) ) , rig , SLOT ( setSpectrumRefLevel ( int ) ) ) ;
2021-02-20 08:05:23 +00:00
connect ( this , SIGNAL ( setModLevel ( rigInput , unsigned char ) ) , rig , SLOT ( setModInputLevel ( rigInput , unsigned char ) ) ) ;
2021-02-16 04:32:14 +00:00
// Levels: handle return on query:
2018-11-17 06:19:44 +00:00
connect ( rig , SIGNAL ( haveRfGain ( unsigned char ) ) , this , SLOT ( receiveRfGain ( unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveAfGain ( unsigned char ) ) , this , SLOT ( receiveAfGain ( unsigned char ) ) ) ;
2018-11-18 08:01:20 +00:00
connect ( rig , SIGNAL ( haveSql ( unsigned char ) ) , this , SLOT ( receiveSql ( unsigned char ) ) ) ;
2021-02-16 01:15:28 +00:00
connect ( rig , SIGNAL ( haveTxPower ( unsigned char ) ) , this , SLOT ( receiveTxPower ( unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveMicGain ( unsigned char ) ) , this , SLOT ( receiveMicGain ( unsigned char ) ) ) ;
2021-02-16 06:33:21 +00:00
connect ( rig , SIGNAL ( haveSpectrumRefLevel ( int ) ) , this , SLOT ( receiveSpectrumRefLevel ( int ) ) ) ;
2021-02-20 08:05:23 +00:00
connect ( rig , SIGNAL ( haveACCGain ( unsigned char , unsigned char ) ) , this , SLOT ( receiveACCGain ( unsigned char , unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveUSBGain ( unsigned char ) ) , this , SLOT ( receiveUSBGain ( unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveLANGain ( unsigned char ) ) , this , SLOT ( receiveLANGain ( unsigned char ) ) ) ;
2021-02-16 01:15:28 +00:00
2021-02-21 04:41:19 +00:00
//Metering:
2021-02-26 07:57:37 +00:00
connect ( this , SIGNAL ( getMeters ( meterKind ) ) , rig , SLOT ( getMeters ( meterKind ) ) ) ;
2021-02-21 04:41:19 +00:00
connect ( rig , SIGNAL ( haveMeter ( meterKind , unsigned char ) ) , this , SLOT ( receiveMeter ( meterKind , unsigned char ) ) ) ;
// Rig and ATU info:
2018-11-17 06:19:44 +00:00
connect ( this , SIGNAL ( startATU ( ) ) , rig , SLOT ( startATU ( ) ) ) ;
2018-11-17 07:13:59 +00:00
connect ( this , SIGNAL ( setATU ( bool ) ) , rig , SLOT ( setATU ( bool ) ) ) ;
2018-12-20 18:56:54 +00:00
connect ( this , SIGNAL ( getATUStatus ( ) ) , rig , SLOT ( getATUStatus ( ) ) ) ;
2018-11-20 07:42:34 +00:00
connect ( this , SIGNAL ( getRigID ( ) ) , rig , SLOT ( getRigID ( ) ) ) ;
2018-12-20 18:56:54 +00:00
connect ( rig , SIGNAL ( haveATUStatus ( unsigned char ) ) , this , SLOT ( receiveATUStatus ( unsigned char ) ) ) ;
2021-01-25 00:16:38 +00:00
connect ( rig , SIGNAL ( haveRigID ( rigCapabilities ) ) , this , SLOT ( receiveRigID ( rigCapabilities ) ) ) ;
2018-11-17 07:13:59 +00:00
2021-01-25 00:16:38 +00:00
// Speech (emitted from rig speaker)
2019-02-01 20:21:54 +00:00
connect ( this , SIGNAL ( sayAll ( ) ) , rig , SLOT ( sayAll ( ) ) ) ;
connect ( this , SIGNAL ( sayFrequency ( ) ) , rig , SLOT ( sayFrequency ( ) ) ) ;
connect ( this , SIGNAL ( sayMode ( ) ) , rig , SLOT ( sayMode ( ) ) ) ;
2018-06-19 19:58:52 +00:00
2021-02-11 08:33:25 +00:00
// calibration window:
connect ( cal , SIGNAL ( requestRefAdjustCourse ( ) ) , rig , SLOT ( getRefAdjustCourse ( ) ) ) ;
connect ( cal , SIGNAL ( requestRefAdjustFine ( ) ) , rig , SLOT ( getRefAdjustFine ( ) ) ) ;
connect ( rig , SIGNAL ( haveRefAdjustCourse ( unsigned char ) ) , cal , SLOT ( handleRefAdjustCourse ( unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveRefAdjustFine ( unsigned char ) ) , cal , SLOT ( handleRefAdjustFine ( unsigned char ) ) ) ;
connect ( cal , SIGNAL ( setRefAdjustCourse ( unsigned char ) ) , rig , SLOT ( setRefAdjustCourse ( unsigned char ) ) ) ;
connect ( cal , SIGNAL ( setRefAdjustFine ( unsigned char ) ) , rig , SLOT ( setRefAdjustFine ( unsigned char ) ) ) ;
2018-06-19 19:58:52 +00:00
// Plot user interaction
connect ( plot , SIGNAL ( mouseDoubleClick ( QMouseEvent * ) ) , this , SLOT ( handlePlotDoubleClick ( QMouseEvent * ) ) ) ;
connect ( wf , SIGNAL ( mouseDoubleClick ( QMouseEvent * ) ) , this , SLOT ( handleWFDoubleClick ( QMouseEvent * ) ) ) ;
2018-11-07 23:54:03 +00:00
connect ( plot , SIGNAL ( mousePress ( QMouseEvent * ) ) , this , SLOT ( handlePlotClick ( QMouseEvent * ) ) ) ;
connect ( wf , SIGNAL ( mousePress ( QMouseEvent * ) ) , this , SLOT ( handleWFClick ( QMouseEvent * ) ) ) ;
2020-04-21 04:10:20 +00:00
connect ( wf , SIGNAL ( mouseWheel ( QWheelEvent * ) ) , this , SLOT ( handleWFScroll ( QWheelEvent * ) ) ) ;
connect ( plot , SIGNAL ( mouseWheel ( QWheelEvent * ) ) , this , SLOT ( handlePlotScroll ( QWheelEvent * ) ) ) ;
2018-06-19 19:58:52 +00:00
2021-02-19 09:32:30 +00:00
if ( serverConfig . enabled & & udp ! = Q_NULLPTR ) {
2021-02-19 09:28:03 +00:00
// Server
2021-02-28 20:10:07 +00:00
connect ( rig , SIGNAL ( haveAudioData ( AUDIOPACKET ) ) , udp , SLOT ( receiveAudioData ( AUDIOPACKET ) ) ) ;
2021-02-19 09:28:03 +00:00
connect ( rig , SIGNAL ( haveDataForServer ( QByteArray ) ) , udp , SLOT ( dataForServer ( QByteArray ) ) ) ;
connect ( udp , SIGNAL ( haveDataFromServer ( QByteArray ) ) , rig , SLOT ( dataFromServer ( QByteArray ) ) ) ;
}
2021-02-18 09:14:41 +00:00
2018-06-19 19:58:52 +00:00
ui - > plot - > addGraph ( ) ; // primary
ui - > plot - > addGraph ( 0 , 0 ) ; // secondary, peaks, same axis as first?
ui - > waterfall - > addGraph ( ) ;
2018-06-20 06:45:56 +00:00
tracer - > setGraph ( plot - > graph ( 0 ) ) ;
2018-06-19 19:58:52 +00:00
colorMap = new QCPColorMap ( wf - > xAxis , wf - > yAxis ) ;
colorMapData = NULL ;
2020-03-27 23:34:32 +00:00
# if QCUSTOMPLOT_VERSION < 0x020001
2018-06-19 19:58:52 +00:00
wf - > addPlottable ( colorMap ) ;
2020-03-27 23:34:32 +00:00
# endif
2018-06-19 19:58:52 +00:00
colorScale = new QCPColorScale ( wf ) ;
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
QColor color ( 20 + 200 / 4.0 * 1 , 70 * ( 1.6 - 1 / 4.0 ) , 150 , 150 ) ;
plot - > graph ( 1 ) - > setLineStyle ( QCPGraph : : lsLine ) ;
plot - > graph ( 1 ) - > setPen ( QPen ( color . lighter ( 200 ) ) ) ;
plot - > graph ( 1 ) - > setBrush ( QBrush ( color ) ) ;
drawPeaks = false ;
2021-02-27 01:11:41 +00:00
SMeterReadings . fill ( 0 , 30 ) ;
powerMeterReadings . fill ( 0 , 30 ) ;
2021-02-24 08:18:19 +00:00
2018-06-19 19:58:52 +00:00
ui - > freqMhzLineEdit - > setValidator ( new QDoubleValidator ( 0 , 100 , 6 , this ) ) ;
2021-02-14 18:19:13 +00:00
ui - > audioPortTxt - > setValidator ( new QIntValidator ( this ) ) ;
ui - > serialPortTxt - > setValidator ( new QIntValidator ( this ) ) ;
ui - > controlPortTxt - > setValidator ( new QIntValidator ( this ) ) ;
2018-06-19 19:58:52 +00:00
2019-01-24 01:19:35 +00:00
pttTimer = new QTimer ( this ) ;
pttTimer - > setInterval ( 180 * 1000 ) ; // 3 minute max transmit time in ms
pttTimer - > setSingleShot ( true ) ;
connect ( pttTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( handlePttLimit ( ) ) ) ;
2021-02-15 04:45:48 +00:00
amTransmitting = false ;
2021-02-27 01:32:06 +00:00
ui - > tuneLockChk - > setChecked ( false ) ;
freqLock = false ;
2019-01-24 01:19:35 +00:00
// Not needed since we automate this now.
/*
2018-06-25 07:34:33 +00:00
foreach ( const QSerialPortInfo & serialPortInfo , QSerialPortInfo : : availablePorts ( ) )
{
portList . append ( serialPortInfo . portName ( ) ) ;
2019-01-24 01:19:35 +00:00
// ui->commPortDrop->addItem(serialPortInfo.portName());
2018-06-25 07:34:33 +00:00
}
2019-01-24 01:19:35 +00:00
*/
2018-06-25 07:34:33 +00:00
2019-01-28 23:36:17 +00:00
# ifdef QT_DEBUG
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Running with debugging options enabled. " ;
2019-01-28 23:36:17 +00:00
ui - > debugBtn - > setVisible ( true ) ;
# else
ui - > debugBtn - > setVisible ( false ) ;
# endif
2018-11-18 08:01:20 +00:00
// Initial state of UI:
2018-11-25 06:21:36 +00:00
ui - > fullScreenChk - > setChecked ( prefs . useFullScreen ) ;
on_fullScreenChk_clicked ( prefs . useFullScreen ) ;
ui - > useDarkThemeChk - > setChecked ( prefs . useDarkMode ) ;
on_useDarkThemeChk_clicked ( prefs . useDarkMode ) ;
2021-02-19 06:38:50 +00:00
ui - > useSystemThemeChk - > setChecked ( prefs . useSystemTheme ) ;
on_useSystemThemeChk_clicked ( prefs . useSystemTheme ) ;
2018-11-25 06:21:36 +00:00
ui - > drawPeakChk - > setChecked ( prefs . drawPeaks ) ;
on_drawPeakChk_clicked ( prefs . drawPeaks ) ;
drawPeaks = prefs . drawPeaks ;
2018-11-18 08:01:20 +00:00
2021-01-30 06:09:09 +00:00
//getInitialRigState();
2018-07-04 00:20:03 +00:00
oldFreqDialVal = ui - > freqDial - > value ( ) ;
2018-06-19 19:58:52 +00:00
}
wfmain : : ~ wfmain ( )
{
2021-02-03 19:36:35 +00:00
rigThread - > quit ( ) ;
2021-02-03 23:58:11 +00:00
rigThread - > wait ( ) ;
2021-02-16 16:16:46 +00:00
if ( serverThread ! = Q_NULLPTR ) {
serverThread - > quit ( ) ;
serverThread - > wait ( ) ;
}
2018-06-19 19:58:52 +00:00
delete ui ;
}
2021-01-30 06:09:09 +00:00
void wfmain : : openRig ( )
{
// This function is intended to handle opening a connection to the rig.
// the connection can be either serial or network,
// and this function is also responsible for initiating the search for a rig model and capabilities.
// Any errors, such as unable to open connection or unable to open port, are to be reported to the user.
//TODO: if(hasRunPreviously)
//TODO: if(useNetwork){...
// } else {
// if (prefs.fileWasNotFound) {
// showRigSettings(); // rig setting dialog box for network/serial, CIV, hostname, port, baud rate, serial device, etc
// TODO: How do we know if the setting was loaded?
2021-02-02 09:05:59 +00:00
// TODO: Use these if they are found
# ifdef QT_DEBUG
if ( ! serialPortCL . isEmpty ( ) )
2021-01-30 06:09:09 +00:00
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Serial port specified by user: " < < serialPortCL ;
2021-02-02 09:05:59 +00:00
} else {
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Serial port not specified. " ;
2021-02-02 09:05:59 +00:00
}
if ( ! hostCL . isEmpty ( ) )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Remote host name specified by user: " < < hostCL ;
2021-02-02 09:05:59 +00:00
}
# endif
2021-02-07 12:59:41 +00:00
if ( rigThread = = Q_NULLPTR )
{
rig = new rigCommander ( ) ;
rigThread = new QThread ( this ) ;
rig - > moveToThread ( rigThread ) ;
connect ( rigThread , SIGNAL ( started ( ) ) , rig , SLOT ( process ( ) ) ) ;
connect ( rigThread , SIGNAL ( finished ( ) ) , rig , SLOT ( deleteLater ( ) ) ) ;
rigThread - > start ( ) ;
connect ( rig , SIGNAL ( haveSerialPortError ( QString , QString ) ) , this , SLOT ( receiveSerialPortError ( QString , QString ) ) ) ;
connect ( rig , SIGNAL ( haveStatusUpdate ( QString ) ) , this , SLOT ( receiveStatusUpdate ( QString ) ) ) ;
2021-02-27 00:37:00 +00:00
connect ( this , SIGNAL ( sendCommSetup ( unsigned char , QString , quint16 , quint16 , quint16 , QString , QString , quint16 , quint16 , quint16 , quint8 , quint16 , quint8 ) ) , rig , SLOT ( commSetup ( unsigned char , QString , quint16 , quint16 , quint16 , QString , QString , quint16 , quint16 , quint16 , quint8 , quint16 , quint8 ) ) ) ;
2021-02-07 12:59:41 +00:00
connect ( this , SIGNAL ( sendCommSetup ( unsigned char , QString , quint32 ) ) , rig , SLOT ( commSetup ( unsigned char , QString , quint32 ) ) ) ;
connect ( this , SIGNAL ( sendCloseComm ( ) ) , rig , SLOT ( closeComm ( ) ) ) ;
2021-02-27 00:37:00 +00:00
connect ( this , SIGNAL ( sendChangeLatency ( quint16 ) ) , rig , SLOT ( changeLatency ( quint16 ) ) ) ;
2021-02-07 12:59:41 +00:00
connect ( this , SIGNAL ( getRigCIV ( ) ) , rig , SLOT ( findRigs ( ) ) ) ;
connect ( rig , SIGNAL ( discoveredRigID ( rigCapabilities ) ) , this , SLOT ( receiveFoundRigID ( rigCapabilities ) ) ) ;
connect ( rig , SIGNAL ( commReady ( ) ) , this , SLOT ( receiveCommReady ( ) ) ) ;
}
2021-02-06 05:44:50 +00:00
if ( prefs . enableLAN )
2021-02-02 09:05:59 +00:00
{
2021-02-08 16:53:26 +00:00
emit sendCommSetup ( prefs . radioCIVAddr , prefs . ipAddress , prefs . controlLANPort ,
2021-02-27 00:37:00 +00:00
prefs . serialLANPort , prefs . audioLANPort , prefs . username , prefs . password , prefs . audioRXLatency , prefs . audioTXLatency , prefs . audioRXSampleRate , prefs . audioRXCodec , prefs . audioTXSampleRate , prefs . audioTXCodec ) ;
2021-02-06 05:44:50 +00:00
} else {
2021-02-02 09:05:59 +00:00
2021-02-06 05:44:50 +00:00
if ( ( prefs . serialPortRadio = = QString ( " auto " ) ) & & ( serialPortCL . isEmpty ( ) ) )
2021-01-30 06:09:09 +00:00
{
2021-02-06 05:44:50 +00:00
// Find the ICOM
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Searching for serial port...";
2021-02-06 05:44:50 +00:00
QDirIterator it73 ( " /dev/serial " , QStringList ( ) < < " *IC-7300* " , QDir : : Files , QDirIterator : : Subdirectories ) ;
QDirIterator it97 ( " /dev/serial " , QStringList ( ) < < " *IC-9700*A* " , QDir : : Files , QDirIterator : : Subdirectories ) ;
QDirIterator it785x ( " /dev/serial " , QStringList ( ) < < " *IC-785*A* " , QDir : : Files , QDirIterator : : Subdirectories ) ;
QDirIterator it705 ( " /dev/serial " , QStringList ( ) < < " *IC-705*A " , QDir : : Files , QDirIterator : : Subdirectories ) ;
if ( ! it73 . filePath ( ) . isEmpty ( ) )
{
// use
serialPortRig = it73 . filePath ( ) ; // first
} else if ( ! it97 . filePath ( ) . isEmpty ( ) )
{
// IC-9700 port
serialPortRig = it97 . filePath ( ) ;
} else if ( ! it785x . filePath ( ) . isEmpty ( ) )
{
// IC-785x port
serialPortRig = it785x . filePath ( ) ;
} else if ( ! it705 . filePath ( ) . isEmpty ( ) )
{
// IC-705
serialPortRig = it705 . filePath ( ) ;
} else {
//fall back:
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences. " ;
2021-02-02 09:05:59 +00:00
# ifdef Q_OS_MAC
2021-02-06 05:44:50 +00:00
serialPortRig = QString ( " /dev/tty.SLAB_USBtoUART " ) ;
2021-02-02 09:05:59 +00:00
# endif
# ifdef Q_OS_LINUX
2021-02-06 05:44:50 +00:00
serialPortRig = QString ( " /dev/ttyUSB0 " ) ;
2021-02-02 09:05:59 +00:00
# endif
2021-02-06 05:44:50 +00:00
# ifdef Q_OS_WIN
serialPortRig = QString ( " COM1 " ) ;
2021-02-02 09:05:59 +00:00
# endif
2021-02-06 05:44:50 +00:00
}
2021-02-02 09:05:59 +00:00
} else {
2021-02-06 05:44:50 +00:00
if ( serialPortCL . isEmpty ( ) )
{
serialPortRig = prefs . serialPortRadio ;
} else {
serialPortRig = serialPortCL ;
}
2021-02-02 09:05:59 +00:00
}
2021-01-30 06:09:09 +00:00
2021-02-06 05:44:50 +00:00
// Here, the radioCIVAddr is being set from a default preference, which is for the 7300.
// However, we will not use it initially. OTOH, if it is set explicitedly to a value in the prefs,
// then we skip auto detection.
2021-02-07 12:59:41 +00:00
emit sendCommSetup ( prefs . radioCIVAddr , serialPortRig , prefs . serialPortBaud ) ;
2021-02-06 05:44:50 +00:00
}
2021-02-07 12:59:41 +00:00
2021-02-02 09:05:59 +00:00
ui - > statusBar - > showMessage ( QString ( " Connecting to rig using serial port " ) . append ( serialPortRig ) , 1000 ) ;
2021-01-30 06:09:09 +00:00
2021-02-07 09:03:02 +00:00
/*
2021-01-30 06:09:09 +00:00
if ( prefs . radioCIVAddr = = 0 )
{
// tell rigCommander to broadcast a request for all rig IDs.
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
2021-02-02 09:05:59 +00:00
ui - > statusBar - > showMessage ( QString ( " Searching CIV bus for connected radios. " ) , 1000 ) ;
2021-01-30 06:09:09 +00:00
emit getRigCIV ( ) ;
cmdOutQue . append ( cmdGetRigCIV ) ;
2021-01-30 08:44:36 +00:00
delayedCommand - > start ( ) ;
2021-01-30 06:09:09 +00:00
} else {
// don't bother, they told us the CIV they want, stick with it.
// We still query the rigID to find the model, but at least we know the CIV.
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Skipping automatic CIV, using user-supplied value of " < < prefs . radioCIVAddr ;
2021-01-30 06:09:09 +00:00
getInitialRigState ( ) ;
}
2021-02-07 09:03:02 +00:00
*/
2021-01-30 06:09:09 +00:00
}
2021-02-07 09:03:02 +00:00
void wfmain : : receiveCommReady ( )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Received CommReady!! " ;
2021-02-07 09:03:02 +00:00
// taken from above:
if ( prefs . radioCIVAddr = = 0 )
{
// tell rigCommander to broadcast a request for all rig IDs.
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
2021-02-07 09:03:02 +00:00
ui - > statusBar - > showMessage ( QString ( " Searching CIV bus for connected radios. " ) , 1000 ) ;
emit getRigCIV ( ) ;
cmdOutQue . append ( cmdGetRigCIV ) ;
delayedCommand - > start ( ) ;
} else {
// don't bother, they told us the CIV they want, stick with it.
// We still query the rigID to find the model, but at least we know the CIV.
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Skipping automatic CIV, using user-supplied value of " < < prefs . radioCIVAddr ;
2021-02-07 09:03:02 +00:00
getInitialRigState ( ) ;
}
2021-02-07 12:59:41 +00:00
2021-02-07 09:03:02 +00:00
}
2021-01-30 06:09:09 +00:00
void wfmain : : receiveFoundRigID ( rigCapabilities rigCaps )
{
// Entry point for unknown rig being identified at the start of the program.
//now we know what the rig ID is:
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
2021-02-11 17:09:45 +00:00
2021-01-30 08:44:36 +00:00
delayedCommand - > setInterval ( 100 ) ; // faster polling is ok now.
2021-01-30 06:09:09 +00:00
receiveRigID ( rigCaps ) ;
getInitialRigState ( ) ;
2021-02-02 09:05:59 +00:00
QString message = QString ( " Found model: " ) . append ( rigCaps . modelName ) ;
2021-02-20 12:42:57 +00:00
ui - > statusBar - > showMessage ( message , 0 ) ;
2021-02-02 09:05:59 +00:00
2021-01-30 06:09:09 +00:00
return ;
}
2021-02-02 09:05:59 +00:00
void wfmain : : receiveSerialPortError ( QString port , QString errorText )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " wfmain: received serial port error for port: " < < port < < " with message: " < < errorText ;
2021-02-02 09:05:59 +00:00
ui - > statusBar - > showMessage ( QString ( " ERROR: using port " ) . append ( port ) . append ( " : " ) . append ( errorText ) , 10000 ) ;
// TODO: Dialog box, exit, etc
}
2021-01-30 06:09:09 +00:00
2021-02-05 20:26:18 +00:00
void wfmain : : receiveStatusUpdate ( QString text )
{
this - > rigStatus - > setText ( text ) ;
}
2018-11-25 06:21:36 +00:00
void wfmain : : setDefPrefs ( )
{
2021-02-05 05:03:16 +00:00
defPrefs . useFullScreen = false ;
2018-11-25 06:21:36 +00:00
defPrefs . useDarkMode = true ;
2021-02-19 06:38:50 +00:00
defPrefs . useSystemTheme = false ;
2018-11-25 06:21:36 +00:00
defPrefs . drawPeaks = true ;
2019-02-09 00:05:45 +00:00
defPrefs . stylesheetPath = QString ( " qdarkstyle/style.qss " ) ;
2021-01-30 06:09:09 +00:00
defPrefs . radioCIVAddr = 0x00 ; // previously was 0x94 for 7300.
2018-11-29 21:41:42 +00:00
defPrefs . serialPortRadio = QString ( " auto " ) ;
2020-03-30 21:09:52 +00:00
defPrefs . serialPortBaud = 115200 ;
2018-11-25 06:21:36 +00:00
defPrefs . enablePTT = false ;
defPrefs . niceTS = true ;
2021-02-05 04:54:34 +00:00
defPrefs . enableLAN = false ;
defPrefs . ipAddress = QString ( " " ) ;
defPrefs . controlLANPort = 50001 ;
defPrefs . serialLANPort = 50002 ;
defPrefs . audioLANPort = 50003 ;
defPrefs . username = QString ( " " ) ;
defPrefs . password = QString ( " " ) ;
2021-02-08 16:53:26 +00:00
defPrefs . audioOutput = QAudioDeviceInfo : : defaultOutputDevice ( ) . deviceName ( ) ;
defPrefs . audioInput = QAudioDeviceInfo : : defaultInputDevice ( ) . deviceName ( ) ;
2021-02-27 00:37:00 +00:00
defPrefs . audioRXLatency = 150 ;
defPrefs . audioTXLatency = 150 ;
2021-02-09 12:43:28 +00:00
defPrefs . audioRXSampleRate = 48000 ;
defPrefs . audioRXCodec = 4 ;
defPrefs . audioTXSampleRate = 48000 ;
defPrefs . audioTXCodec = 4 ;
2021-02-05 04:54:34 +00:00
2018-11-25 06:21:36 +00:00
}
2018-11-24 08:10:05 +00:00
void wfmain : : loadSettings ( )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Loading settings from " < < settings . fileName ( ) ;
2018-11-24 08:10:05 +00:00
// Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc)
2018-11-25 06:21:36 +00:00
settings . beginGroup ( " Interface " ) ;
prefs . useFullScreen = settings . value ( " UseFullScreen " , defPrefs . useFullScreen ) . toBool ( ) ;
prefs . useDarkMode = settings . value ( " UseDarkMode " , defPrefs . useDarkMode ) . toBool ( ) ;
2021-02-19 06:38:50 +00:00
prefs . useSystemTheme = settings . value ( " UseSystemTheme " , defPrefs . useSystemTheme ) . toBool ( ) ;
2018-11-25 06:21:36 +00:00
prefs . drawPeaks = settings . value ( " DrawPeaks " , defPrefs . drawPeaks ) . toBool ( ) ;
2019-02-09 00:05:45 +00:00
prefs . stylesheetPath = settings . value ( " StylesheetPath " , defPrefs . stylesheetPath ) . toString ( ) ;
2020-04-04 22:39:59 +00:00
ui - > splitter - > restoreState ( settings . value ( " splitter " ) . toByteArray ( ) ) ;
2020-04-04 23:51:46 +00:00
restoreGeometry ( settings . value ( " windowGeometry " ) . toByteArray ( ) ) ;
restoreState ( settings . value ( " windowState " ) . toByteArray ( ) ) ;
setWindowState ( Qt : : WindowActive ) ; // Works around QT bug to returns window+keyboard focus.
2018-11-25 06:21:36 +00:00
settings . endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Radio and Comms: C-IV addr, port to use
2018-11-25 06:21:36 +00:00
settings . beginGroup ( " Radio " ) ;
2018-12-18 22:34:04 +00:00
prefs . radioCIVAddr = ( unsigned char ) settings . value ( " RigCIVuInt " , defPrefs . radioCIVAddr ) . toInt ( ) ;
2018-11-25 06:21:36 +00:00
prefs . serialPortRadio = settings . value ( " SerialPortRadio " , defPrefs . serialPortRadio ) . toString ( ) ;
2020-03-30 21:09:52 +00:00
prefs . serialPortBaud = ( quint32 ) settings . value ( " SerialPortBaud " , defPrefs . serialPortBaud ) . toInt ( ) ;
2018-11-25 06:21:36 +00:00
settings . endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Misc. user settings (enable PTT, draw peaks, etc)
2018-11-25 06:21:36 +00:00
settings . beginGroup ( " Controls " ) ;
prefs . enablePTT = settings . value ( " EnablePTT " , defPrefs . enablePTT ) . toBool ( ) ;
2019-02-10 07:13:18 +00:00
ui - > pttEnableChk - > setChecked ( prefs . enablePTT ) ;
2018-11-25 06:21:36 +00:00
prefs . niceTS = settings . value ( " NiceTS " , defPrefs . niceTS ) . toBool ( ) ;
settings . endGroup ( ) ;
2018-11-24 08:10:05 +00:00
2021-02-03 19:36:35 +00:00
settings . beginGroup ( " LAN " ) ;
prefs . enableLAN = settings . value ( " EnableLAN " , defPrefs . enableLAN ) . toBool ( ) ;
ui - > lanEnableChk - > setChecked ( prefs . enableLAN ) ;
2021-02-08 16:53:26 +00:00
2021-02-03 19:36:35 +00:00
prefs . ipAddress = settings . value ( " IPAddress " , defPrefs . ipAddress ) . toString ( ) ;
ui - > ipAddressTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > ipAddressTxt - > setText ( prefs . ipAddress ) ;
2021-02-08 16:53:26 +00:00
2021-02-03 19:36:35 +00:00
prefs . controlLANPort = settings . value ( " ControlLANPort " , defPrefs . controlLANPort ) . toInt ( ) ;
ui - > controlPortTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > controlPortTxt - > setText ( QString ( " %1 " ) . arg ( prefs . controlLANPort ) ) ;
2021-02-08 16:53:26 +00:00
2021-02-03 19:36:35 +00:00
prefs . serialLANPort = settings . value ( " SerialLANPort " , defPrefs . serialLANPort ) . toInt ( ) ;
ui - > serialPortTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > serialPortTxt - > setText ( QString ( " %1 " ) . arg ( prefs . serialLANPort ) ) ;
2021-02-08 16:53:26 +00:00
2021-02-03 19:36:35 +00:00
prefs . audioLANPort = settings . value ( " AudioLANPort " , defPrefs . audioLANPort ) . toInt ( ) ;
ui - > audioPortTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > audioPortTxt - > setText ( QString ( " %1 " ) . arg ( prefs . audioLANPort ) ) ;
prefs . username = settings . value ( " Username " , defPrefs . username ) . toString ( ) ;
ui - > usernameTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > usernameTxt - > setText ( QString ( " %1 " ) . arg ( prefs . username ) ) ;
2021-02-08 16:53:26 +00:00
2021-02-03 19:36:35 +00:00
prefs . password = settings . value ( " Password " , defPrefs . password ) . toString ( ) ;
ui - > passwordTxt - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > passwordTxt - > setText ( QString ( " %1 " ) . arg ( prefs . password ) ) ;
2021-02-04 10:27:30 +00:00
2021-02-27 00:37:00 +00:00
prefs . audioRXLatency = settings . value ( " AudioRXLatency " , defPrefs . audioRXLatency ) . toInt ( ) ;
ui - > rxLatencySlider - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
2021-02-27 10:04:36 +00:00
ui - > rxLatencySlider - > setValue ( prefs . audioRXLatency ) ;
2021-02-27 00:37:00 +00:00
ui - > rxLatencySlider - > setTracking ( false ) ; // Stop it sending value on every change.
prefs . audioTXLatency = settings . value ( " AudioTXLatency " , defPrefs . audioTXLatency ) . toInt ( ) ;
2021-02-27 09:34:56 +00:00
ui - > txLatencySlider - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
ui - > txLatencySlider - > setValue ( prefs . audioTXLatency ) ;
ui - > txLatencySlider - > setTracking ( false ) ; // Stop it sending value on every change.
2021-02-08 16:53:26 +00:00
2021-02-09 12:43:28 +00:00
prefs . audioRXSampleRate = settings . value ( " AudioRXSampleRate " , defPrefs . audioRXSampleRate ) . toInt ( ) ;
prefs . audioTXSampleRate = settings . value ( " AudioTXSampleRate " , defPrefs . audioTXSampleRate ) . toInt ( ) ;
2021-02-08 16:53:26 +00:00
ui - > audioSampleRateCombo - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
2021-02-09 12:43:28 +00:00
int audioSampleRateIndex = ui - > audioSampleRateCombo - > findText ( QString : : number ( prefs . audioRXSampleRate ) ) ;
if ( audioSampleRateIndex ! = - 1 ) {
2021-02-08 16:53:26 +00:00
ui - > audioOutputCombo - > setCurrentIndex ( audioSampleRateIndex ) ;
2021-02-09 12:43:28 +00:00
}
2021-02-08 16:53:26 +00:00
2021-02-09 12:43:28 +00:00
// Add codec combobox items here so that we can add userdata!
ui - > audioRXCodecCombo - > addItem ( " LPCM 1ch 16bit " , 4 ) ;
2021-02-11 19:18:35 +00:00
ui - > audioRXCodecCombo - > addItem ( " LPCM 1ch 8bit " , 2 ) ;
ui - > audioRXCodecCombo - > addItem ( " uLaw 1ch 8bit " , 1 ) ;
2021-02-09 12:43:28 +00:00
ui - > audioRXCodecCombo - > addItem ( " LPCM 2ch 16bit " , 16 ) ;
ui - > audioRXCodecCombo - > addItem ( " uLaw 2ch 8bit " , 32 ) ;
ui - > audioRXCodecCombo - > addItem ( " PCM 2ch 8bit " , 8 ) ;
prefs . audioRXCodec = settings . value ( " AudioRXCodec " , defPrefs . audioRXCodec ) . toInt ( ) ;
ui - > audioRXCodecCombo - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
for ( int f = 0 ; f < ui - > audioRXCodecCombo - > count ( ) ; f + + )
if ( ui - > audioRXCodecCombo - > itemData ( f ) . toInt ( ) = = prefs . audioRXCodec )
ui - > audioRXCodecCombo - > setCurrentIndex ( f ) ;
ui - > audioTXCodecCombo - > addItem ( " LPCM 1ch 16bit " , 4 ) ;
2021-02-11 19:18:35 +00:00
ui - > audioTXCodecCombo - > addItem ( " LPCM 1ch 8bit " , 2 ) ;
ui - > audioTXCodecCombo - > addItem ( " uLaw 1ch 8bit " , 1 ) ;
2021-02-09 12:43:28 +00:00
prefs . audioTXCodec = settings . value ( " AudioTXCodec " , defPrefs . audioTXCodec ) . toInt ( ) ;
ui - > audioTXCodecCombo - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
for ( int f = 0 ; f < ui - > audioTXCodecCombo - > count ( ) ; f + + )
if ( ui - > audioTXCodecCombo - > itemData ( f ) . toInt ( ) = = prefs . audioTXCodec )
ui - > audioTXCodecCombo - > setCurrentIndex ( f ) ;
2021-02-08 16:53:26 +00:00
2021-02-04 10:27:30 +00:00
prefs . audioOutput = settings . value ( " AudioOutput " , defPrefs . audioOutput ) . toString ( ) ;
ui - > audioOutputCombo - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
2021-02-08 16:53:26 +00:00
int audioOutputIndex = ui - > audioOutputCombo - > findText ( prefs . audioOutput ) ;
if ( audioOutputIndex ! = - 1 )
ui - > audioOutputCombo - > setCurrentIndex ( audioOutputIndex ) ;
prefs . audioInput = settings . value ( " AudioInput " , defPrefs . audioInput ) . toString ( ) ;
ui - > audioInputCombo - > setEnabled ( ui - > lanEnableChk - > isChecked ( ) ) ;
int audioInputIndex = ui - > audioInputCombo - > findText ( prefs . audioInput ) ;
if ( audioInputIndex ! = - 1 )
ui - > audioOutputCombo - > setCurrentIndex ( audioInputIndex ) ;
2021-02-04 10:27:30 +00:00
2021-02-03 19:36:35 +00:00
settings . endGroup ( ) ;
2021-02-16 16:16:46 +00:00
settings . beginGroup ( " Server " ) ;
serverConfig . enabled = settings . value ( " ServerEnabled " , false ) . toBool ( ) ;
serverConfig . controlPort = settings . value ( " ServerControlPort " , 50001 ) . toInt ( ) ;
serverConfig . civPort = settings . value ( " ServerCivPort " , 50002 ) . toInt ( ) ;
serverConfig . audioPort = settings . value ( " ServerAudioPort " , 50003 ) . toInt ( ) ;
2021-02-16 16:42:56 +00:00
int numUsers = settings . value ( " ServerNumUsers " , 2 ) . toInt ( ) ;
2021-02-16 16:16:46 +00:00
serverConfig . users . clear ( ) ;
for ( int f = 0 ; f < numUsers ; f + + )
{
SERVERUSER user ;
2021-02-16 16:42:56 +00:00
user . username = settings . value ( " ServerUsername_ " + QString : : number ( f ) , " " ) . toString ( ) ;
user . password = settings . value ( " ServerPassword_ " + QString : : number ( f ) , " " ) . toString ( ) ;
2021-02-22 00:24:48 +00:00
user . userType = settings . value ( " ServerUserType_ " + QString : : number ( f ) , 0 ) . toInt ( ) ;
2021-02-16 16:16:46 +00:00
serverConfig . users . append ( user ) ;
}
settings . endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Memory channels
2018-11-25 06:21:36 +00:00
settings . beginGroup ( " Memory " ) ;
int size = settings . beginReadArray ( " Channel " ) ;
int chan = 0 ;
double freq ;
unsigned char mode ;
bool isSet ;
2018-11-27 07:10:23 +00:00
// Annoying: QSettings will write the array to the
// preference file starting the array at 1 and ending at 100.
// Thus, we are writing the channel number each time.
// It is also annoying that they get written with their array
// numbers in alphabetical order without zero padding.
// Also annoying that the preference groups are not written in
// the order they are specified here.
2018-11-25 06:21:36 +00:00
for ( int i = 0 ; i < size ; i + + )
{
settings . setArrayIndex ( i ) ;
chan = settings . value ( " chan " , 0 ) . toInt ( ) ;
freq = settings . value ( " freq " , 12.345 ) . toDouble ( ) ;
mode = settings . value ( " mode " , 0 ) . toInt ( ) ;
isSet = settings . value ( " isSet " , false ) . toBool ( ) ;
if ( isSet )
{
mem . setPreset ( chan , freq , ( mode_kind ) mode ) ;
}
}
settings . endArray ( ) ;
settings . endGroup ( ) ;
2021-02-16 16:16:46 +00:00
emit sendServerConfig ( serverConfig ) ;
2018-11-24 08:10:05 +00:00
}
2020-04-04 23:51:46 +00:00
2018-11-24 08:10:05 +00:00
void wfmain : : saveSettings ( )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Saving settings to " < < settings . fileName ( ) ;
2018-11-24 08:10:05 +00:00
// Basic things to load:
// UI: (full screen, dark theme, draw peaks, colors, etc)
settings . beginGroup ( " Interface " ) ;
2018-11-27 07:10:23 +00:00
settings . setValue ( " UseFullScreen " , prefs . useFullScreen ) ;
2021-02-19 06:38:50 +00:00
settings . setValue ( " UseSystemTheme " , prefs . useSystemTheme ) ;
2018-11-27 07:10:23 +00:00
settings . setValue ( " UseDarkMode " , prefs . useDarkMode ) ;
settings . setValue ( " DrawPeaks " , prefs . drawPeaks ) ;
2019-02-09 00:05:45 +00:00
settings . setValue ( " StylesheetPath " , prefs . stylesheetPath ) ;
2020-04-04 22:39:59 +00:00
settings . setValue ( " splitter " , ui - > splitter - > saveState ( ) ) ;
2020-04-04 23:51:46 +00:00
settings . setValue ( " windowGeometry " , saveGeometry ( ) ) ;
settings . setValue ( " windowState " , saveState ( ) ) ;
2018-11-24 08:10:05 +00:00
settings . endGroup ( ) ;
// Radio and Comms: C-IV addr, port to use
settings . beginGroup ( " Radio " ) ;
2018-11-27 07:10:23 +00:00
settings . setValue ( " RigCIVuInt " , prefs . radioCIVAddr ) ;
settings . setValue ( " SerialPortRadio " , prefs . serialPortRadio ) ;
2020-03-30 21:09:52 +00:00
settings . setValue ( " SerialPortBaud " , prefs . serialPortBaud ) ;
2018-11-24 08:10:05 +00:00
settings . endGroup ( ) ;
// Misc. user settings (enable PTT, draw peaks, etc)
settings . beginGroup ( " Controls " ) ;
2018-11-27 07:10:23 +00:00
settings . setValue ( " EnablePTT " , prefs . enablePTT ) ;
settings . setValue ( " NiceTS " , prefs . niceTS ) ;
2018-11-24 08:10:05 +00:00
settings . endGroup ( ) ;
2021-02-03 19:36:35 +00:00
settings . beginGroup ( " LAN " ) ;
settings . setValue ( " EnableLAN " , prefs . enableLAN ) ;
settings . setValue ( " IPAddress " , prefs . ipAddress ) ;
settings . setValue ( " ControlLANPort " , prefs . controlLANPort ) ;
settings . setValue ( " SerialLANPort " , prefs . serialLANPort ) ;
settings . setValue ( " AudioLANPort " , prefs . audioLANPort ) ;
settings . setValue ( " Username " , prefs . username ) ;
settings . setValue ( " Password " , prefs . password ) ;
2021-02-27 00:37:00 +00:00
settings . setValue ( " AudioRXLatency " , prefs . audioRXLatency ) ;
settings . setValue ( " AudioTXLatency " , prefs . audioTXLatency ) ;
2021-02-09 12:43:28 +00:00
settings . setValue ( " AudioRXSampleRate " , prefs . audioRXSampleRate ) ;
settings . setValue ( " AudioRXCodec " , prefs . audioRXCodec ) ;
settings . setValue ( " AudioTXSampleRate " , prefs . audioRXSampleRate ) ;
settings . setValue ( " AudioTXCodec " , prefs . audioTXCodec ) ;
2021-02-04 10:27:30 +00:00
settings . setValue ( " AudioOutput " , prefs . audioOutput ) ;
2021-02-08 16:53:26 +00:00
settings . setValue ( " AudioInput " , prefs . audioInput ) ;
2021-02-03 19:36:35 +00:00
settings . endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Memory channels
settings . beginGroup ( " Memory " ) ;
settings . beginWriteArray ( " Channel " , ( int ) mem . getNumPresets ( ) ) ;
preset_kind temp ;
for ( int i = 0 ; i < ( int ) mem . getNumPresets ( ) ; i + + )
{
temp = mem . getPreset ( ( int ) i ) ;
settings . setArrayIndex ( i ) ;
2018-11-25 06:21:36 +00:00
settings . setValue ( " chan " , i ) ;
2018-11-24 08:10:05 +00:00
settings . setValue ( " freq " , temp . frequency ) ;
settings . setValue ( " mode " , temp . mode ) ;
2018-11-25 06:21:36 +00:00
settings . setValue ( " isSet " , temp . isSet ) ;
2018-11-24 08:10:05 +00:00
}
settings . endArray ( ) ;
settings . endGroup ( ) ;
2018-11-25 06:21:36 +00:00
// Note: X and Y get the same colors. See setPlotTheme() function
settings . beginGroup ( " DarkColors " ) ;
settings . setValue ( " Dark_PlotBackground " , QColor ( 0 , 0 , 0 , 255 ) ) ;
settings . setValue ( " Dark_PlotAxisPen " , QColor ( 75 , 75 , 75 , 255 ) ) ;
settings . setValue ( " Dark_PlotLegendTextColor " , QColor ( 255 , 255 , 255 , 255 ) ) ;
settings . setValue ( " Dark_PlotLegendBorderPen " , QColor ( 255 , 255 , 255 , 255 ) ) ;
settings . setValue ( " Dark_PlotLegendBrush " , QColor ( 0 , 0 , 0 , 200 ) ) ;
settings . setValue ( " Dark_PlotTickLabel " , QColor ( Qt : : white ) ) ;
settings . setValue ( " Dark_PlotBasePen " , QColor ( Qt : : white ) ) ;
settings . setValue ( " Dark_PlotTickPen " , QColor ( Qt : : white ) ) ;
settings . setValue ( " Dark_PlotFreqTracer " , QColor ( Qt : : yellow ) ) ;
settings . endGroup ( ) ;
settings . beginGroup ( " LightColors " ) ;
settings . setValue ( " Light_PlotBackground " , QColor ( 255 , 255 , 255 , 255 ) ) ;
settings . setValue ( " Light_PlotAxisPen " , QColor ( 200 , 200 , 200 , 255 ) ) ;
settings . setValue ( " Light_PlotLegendTextColor " , QColor ( 0 , 0 , 0 , 255 ) ) ;
settings . setValue ( " Light_PlotLegendBorderPen " , QColor ( 0 , 0 , 0 , 255 ) ) ;
settings . setValue ( " Light_PlotLegendBrush " , QColor ( 255 , 255 , 255 , 200 ) ) ;
settings . setValue ( " Light_PlotTickLabel " , QColor ( Qt : : black ) ) ;
settings . setValue ( " Light_PlotBasePen " , QColor ( Qt : : black ) ) ;
settings . setValue ( " Light_PlotTickPen " , QColor ( Qt : : black ) ) ;
settings . setValue ( " Light_PlotFreqTracer " , QColor ( Qt : : blue ) ) ;
settings . endGroup ( ) ;
// This is a reference to see how the preference file is encoded.
settings . beginGroup ( " StandardColors " ) ;
settings . setValue ( " white " , QColor ( Qt : : white ) ) ;
settings . setValue ( " black " , QColor ( Qt : : black ) ) ;
settings . setValue ( " red_opaque " , QColor ( Qt : : red ) ) ;
settings . setValue ( " red_translucent " , QColor ( 255 , 0 , 0 , 128 ) ) ;
settings . setValue ( " green_opaque " , QColor ( Qt : : green ) ) ;
settings . setValue ( " green_translucent " , QColor ( 0 , 255 , 0 , 128 ) ) ;
settings . setValue ( " blue_opaque " , QColor ( Qt : : blue ) ) ;
settings . setValue ( " blue_translucent " , QColor ( 0 , 0 , 255 , 128 ) ) ;
settings . endGroup ( ) ;
2021-02-16 16:16:46 +00:00
settings . beginGroup ( " Server " ) ;
settings . setValue ( " ServerEnabled " , serverConfig . enabled ) ;
settings . setValue ( " ServerControlPort " , serverConfig . controlPort ) ;
settings . setValue ( " ServerCivPort " , serverConfig . civPort ) ;
settings . setValue ( " ServerAudioPort " , serverConfig . audioPort ) ;
settings . setValue ( " ServerNumUsers " , serverConfig . users . count ( ) ) ;
for ( int f = 0 ; f < serverConfig . users . count ( ) ; f + + )
{
2021-02-16 16:42:56 +00:00
settings . setValue ( " ServerUsername_ " + QString : : number ( f ) , serverConfig . users [ f ] . username ) ;
settings . setValue ( " ServerPassword_ " + QString : : number ( f ) , serverConfig . users [ f ] . password ) ;
2021-02-22 00:24:48 +00:00
settings . setValue ( " ServerUserType_ " + QString : : number ( f ) , serverConfig . users [ f ] . userType ) ;
2021-02-16 16:16:46 +00:00
}
settings . endGroup ( ) ;
2018-11-25 06:21:36 +00:00
2018-11-24 08:10:05 +00:00
settings . sync ( ) ; // Automatic, not needed (supposedly)
}
2021-01-25 00:16:38 +00:00
void wfmain : : prepareWf ( )
{
// All this code gets moved in from the constructor of wfmain.
if ( haveRigCaps )
{
// do things
spectWidth = rigCaps . spectLenMax ; // was fixed at 475
2021-02-13 06:42:34 +00:00
wfLength = 160 ; // fixed for now, time-length of waterfall
2021-01-25 00:16:38 +00:00
// Initialize before use!
QByteArray empty ( ( int ) spectWidth , ' \x01 ' ) ;
spectrumPeaks = QByteArray ( ( int ) spectWidth , ' \x01 ' ) ;
for ( quint16 i = 0 ; i < wfLength ; i + + )
{
wfimage . append ( empty ) ;
}
// from line 305-313:
colorMap - > data ( ) - > setValueRange ( QCPRange ( 0 , wfLength - 1 ) ) ;
colorMap - > data ( ) - > setKeyRange ( QCPRange ( 0 , spectWidth - 1 ) ) ;
colorMap - > setDataRange ( QCPRange ( 0 , rigCaps . spectAmpMax ) ) ;
colorMap - > setGradient ( QCPColorGradient : : gpJet ) ; // TODO: Add preference
colorMapData = new QCPColorMapData ( spectWidth , wfLength , QCPRange ( 0 , spectWidth - 1 ) , QCPRange ( 0 , wfLength - 1 ) ) ;
colorMap - > setData ( colorMapData ) ;
spectRowCurrent = 0 ;
wf - > yAxis - > setRangeReversed ( true ) ;
wf - > xAxis - > setVisible ( false ) ;
2021-03-01 16:26:59 +00:00
rigName - > setText ( rigCaps . modelName ) ;
2021-01-25 00:16:38 +00:00
} else {
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Cannot prepare WF view without rigCaps. Waiting on this. " ;
2021-01-25 00:16:38 +00:00
return ;
}
}
2018-11-24 08:10:05 +00:00
2018-11-28 06:02:37 +00:00
// Key shortcuts (hotkeys)
void wfmain : : shortcutF11 ( )
{
if ( onFullscreen )
{
this - > showNormal ( ) ;
onFullscreen = false ;
} else {
this - > showFullScreen ( ) ;
onFullscreen = true ;
}
2021-02-05 05:03:16 +00:00
ui - > fullScreenChk - > setChecked ( onFullscreen ) ;
2018-11-28 06:02:37 +00:00
}
void wfmain : : shortcutF1 ( )
{
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
}
void wfmain : : shortcutF2 ( )
{
ui - > tabWidget - > setCurrentIndex ( 1 ) ;
}
void wfmain : : shortcutF3 ( )
{
ui - > tabWidget - > setCurrentIndex ( 2 ) ;
2018-11-30 06:20:27 +00:00
ui - > freqMhzLineEdit - > clear ( ) ;
ui - > freqMhzLineEdit - > setFocus ( ) ;
2018-11-28 06:02:37 +00:00
}
void wfmain : : shortcutF4 ( )
{
ui - > tabWidget - > setCurrentIndex ( 3 ) ;
}
2019-01-28 23:36:17 +00:00
// Mode switch keys:
2018-11-28 06:02:37 +00:00
void wfmain : : shortcutF5 ( )
{
2019-01-28 23:36:17 +00:00
// LSB
2021-02-17 06:32:05 +00:00
changeMode ( modeLSB , false ) ;
2019-01-28 23:36:17 +00:00
}
void wfmain : : shortcutF6 ( )
{
// USB
2021-02-17 06:32:05 +00:00
changeMode ( modeUSB , false ) ;
2019-01-28 23:36:17 +00:00
}
void wfmain : : shortcutF7 ( )
{
// AM
2021-02-17 06:32:05 +00:00
changeMode ( modeAM , false ) ;
2019-01-28 23:36:17 +00:00
}
void wfmain : : shortcutF8 ( )
{
// CW
2021-02-17 06:32:05 +00:00
changeMode ( modeCW , false ) ;
2019-01-28 23:36:17 +00:00
}
void wfmain : : shortcutF9 ( )
{
// USB-D
2021-02-17 06:32:05 +00:00
changeMode ( modeUSB , true ) ;
2019-01-28 23:36:17 +00:00
}
void wfmain : : shortcutF10 ( )
{
2021-02-17 06:32:05 +00:00
// FM
changeMode ( modeFM , false ) ;
2018-11-28 06:02:37 +00:00
}
2019-02-01 20:21:54 +00:00
void wfmain : : shortcutF12 ( )
{
// Speak current frequency and mode via IC-7300
showStatusBarText ( " Sending speech command to radio. " ) ;
emit sayAll ( ) ;
}
void wfmain : : shortcutControlT ( )
{
// Transmit
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Activated Control-T shortcut " ;
2020-03-12 03:58:31 +00:00
showStatusBarText ( QString ( " Transmitting. Press Control-R to receive. " ) ) ;
2019-02-01 20:21:54 +00:00
ui - > pttOnBtn - > click ( ) ;
}
void wfmain : : shortcutControlR ( )
{
// Receive
2021-02-15 06:40:04 +00:00
emit setPTT ( false ) ;
issueDelayedCommand ( cmdGetPTT ) ;
2019-02-01 20:21:54 +00:00
}
void wfmain : : shortcutControlI ( )
{
// Enable ATU
ui - > tuneEnableChk - > click ( ) ;
}
void wfmain : : shortcutControlU ( )
{
// Run ATU tuning cycle
ui - > tuneNowBtn - > click ( ) ;
}
2018-11-28 06:02:37 +00:00
void wfmain : : shortcutStar ( )
{
// Jump to frequency tab from Asterisk key on keypad
ui - > tabWidget - > setCurrentIndex ( 2 ) ;
2018-11-30 06:19:23 +00:00
ui - > freqMhzLineEdit - > clear ( ) ;
ui - > freqMhzLineEdit - > setFocus ( ) ;
2018-11-28 06:02:37 +00:00
}
2019-01-28 23:46:14 +00:00
void wfmain : : shortcutSlash ( )
{
// Cycle through available modes
2019-02-01 20:21:54 +00:00
ui - > modeSelectCombo - > setCurrentIndex ( ( ui - > modeSelectCombo - > currentIndex ( ) + 1 ) % ui - > modeSelectCombo - > count ( ) ) ;
2019-02-03 22:09:06 +00:00
on_modeSelectCombo_activated ( ui - > modeSelectCombo - > currentIndex ( ) ) ;
2019-01-28 23:46:14 +00:00
}
2018-11-28 06:02:37 +00:00
2021-02-22 07:58:23 +00:00
void wfmain : : setTuningSteps ( )
{
// TODO: interact with preferences, tuning step drop down box, and current operating mode
// Units are MHz:
2021-02-22 10:24:29 +00:00
tsPlusControl = 0.010f ;
tsPlus = 0.001f ;
tsPlusShift = 0.0001f ;
tsPage = 1.0f ;
tsPageShift = 0.5f ; // TODO, unbind this keystroke from the dial
2021-02-27 01:32:06 +00:00
tsWfScroll = 0.0001f ;
2021-02-22 07:58:23 +00:00
}
double wfmain : : roundFrequency ( double frequency )
{
return round ( frequency * 100000 ) / 100000.0 ;
}
2019-02-04 05:51:30 +00:00
void wfmain : : shortcutMinus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz - tsPlus ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() - ui->freqDial->singleStep() );
2019-02-04 05:51:30 +00:00
}
void wfmain : : shortcutPlus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
knobFreqMhz = roundFrequency ( freqMhz + tsPlus ) ;
freqMhz = knobFreqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() + ui->freqDial->singleStep() );
2019-02-04 05:51:30 +00:00
}
2019-02-04 18:32:16 +00:00
void wfmain : : shortcutShiftMinus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz - tsPlusShift ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() - ui->freqDial->pageStep() );
2019-02-04 18:32:16 +00:00
}
void wfmain : : shortcutShiftPlus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz + tsPlusShift ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() + ui->freqDial->pageStep() );
2019-02-04 18:32:16 +00:00
}
2019-02-06 00:11:25 +00:00
void wfmain : : shortcutControlMinus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz - tsPlusControl ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() - ui->freqDial->pageStep() );
2019-02-06 00:11:25 +00:00
}
2019-02-04 18:32:16 +00:00
2019-02-06 00:11:25 +00:00
void wfmain : : shortcutControlPlus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz + tsPlusControl ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
//ui->freqDial->setValue( ui->freqDial->value() + ui->freqDial->pageStep() );
2019-02-06 00:11:25 +00:00
}
2019-02-04 18:32:16 +00:00
2020-03-17 22:15:01 +00:00
void wfmain : : shortcutPageUp ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz + tsPage ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
2020-03-17 22:15:01 +00:00
}
void wfmain : : shortcutPageDown ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
freqMhz = roundFrequency ( freqMhz - tsPage ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
issueDelayedCommand ( cmdGetFreq ) ;
2020-03-17 22:15:01 +00:00
}
2019-02-07 18:15:10 +00:00
void wfmain : : shortcutF ( )
{
showStatusBarText ( " Sending speech command (frequency) to radio. " ) ;
emit sayFrequency ( ) ;
}
void wfmain : : shortcutM ( )
{
showStatusBarText ( " Sending speech command (mode) to radio. " ) ;
emit sayMode ( ) ;
}
2019-02-04 05:51:30 +00:00
2021-01-30 08:44:36 +00:00
void wfmain : : getInitialRigState ( )
2018-06-23 07:31:41 +00:00
{
2018-11-24 08:10:05 +00:00
// Initial list of queries to the radio.
// These are made when the program starts up
// and are used to adjust the UI to match the radio settings
2021-02-13 06:42:34 +00:00
// the polling interval is set at 200ms. Faster is possible but slower
2018-11-24 08:10:05 +00:00
// computers will glitch occassionally.
2018-06-23 07:31:41 +00:00
cmdOutQue . append ( cmdGetFreq ) ;
cmdOutQue . append ( cmdGetMode ) ;
2018-11-24 08:10:05 +00:00
cmdOutQue . append ( cmdNone ) ;
2018-11-16 22:08:21 +00:00
2018-06-23 07:31:41 +00:00
cmdOutQue . append ( cmdGetFreq ) ;
cmdOutQue . append ( cmdGetMode ) ;
2021-02-19 05:47:19 +00:00
// From left to right in the UI:
cmdOutQue . append ( cmdGetDataMode ) ;
2021-02-20 08:05:23 +00:00
cmdOutQue . append ( cmdGetModInput ) ;
cmdOutQue . append ( cmdGetModDataInput ) ;
2018-11-17 06:19:44 +00:00
cmdOutQue . append ( cmdGetRxGain ) ;
cmdOutQue . append ( cmdGetAfGain ) ;
2021-02-16 04:32:14 +00:00
cmdOutQue . append ( cmdGetSql ) ;
cmdOutQue . append ( cmdGetTxPower ) ;
2021-02-20 08:05:23 +00:00
cmdOutQue . append ( cmdGetCurrentModLevel ) ; // level for currently selected mod sources
2021-02-19 05:47:19 +00:00
cmdOutQue . append ( cmdGetSpectrumRefLevel ) ;
cmdOutQue . append ( cmdGetDuplexMode ) ;
2021-02-16 04:32:14 +00:00
2018-11-24 08:10:05 +00:00
cmdOutQue . append ( cmdDispEnable ) ;
cmdOutQue . append ( cmdSpecOn ) ;
2021-02-19 08:14:40 +00:00
cmdOutQue . append ( cmdGetModInput ) ;
cmdOutQue . append ( cmdGetModDataInput ) ;
2018-12-20 19:22:52 +00:00
cmdOutQue . append ( cmdNone ) ;
2021-02-21 04:41:19 +00:00
cmdOutQue . append ( cmdStartRegularPolling ) ;
2021-02-19 05:47:19 +00:00
2021-02-13 06:42:34 +00:00
if ( rigCaps . hasATU )
{
cmdOutQue . append ( cmdGetATUStatus ) ;
}
2018-06-23 07:31:41 +00:00
cmdOut = cmdNone ;
delayedCommand - > start ( ) ;
}
2018-11-07 23:54:03 +00:00
void wfmain : : showStatusBarText ( QString text )
{
ui - > statusBar - > showMessage ( text , 5000 ) ;
}
2018-06-23 07:31:41 +00:00
2018-06-22 23:31:52 +00:00
void wfmain : : on_useDarkThemeChk_clicked ( bool checked )
2018-06-20 06:45:56 +00:00
{
2021-02-19 06:38:50 +00:00
//setAppTheme(checked);
2018-06-22 23:31:52 +00:00
setPlotTheme ( wf , checked ) ;
setPlotTheme ( plot , checked ) ;
2018-11-27 07:10:23 +00:00
prefs . useDarkMode = checked ;
2018-06-22 23:31:52 +00:00
}
2021-02-19 06:38:50 +00:00
void wfmain : : on_useSystemThemeChk_clicked ( bool checked )
2018-06-22 23:31:52 +00:00
{
2021-02-19 06:38:50 +00:00
setAppTheme ( ! checked ) ;
prefs . useSystemTheme = checked ;
}
void wfmain : : setAppTheme ( bool isCustom )
{
if ( isCustom )
2018-06-22 23:31:52 +00:00
{
2021-02-24 22:55:29 +00:00
# ifdef Q_OS_WIN
QFile f ( " : " + prefs . stylesheetPath ) ; // built-in resource
# else
2020-01-05 01:12:35 +00:00
QFile f ( " /usr/share/wfview/stylesheets/ " + prefs . stylesheetPath ) ;
2021-02-24 22:55:29 +00:00
# endif
2018-06-22 23:31:52 +00:00
if ( ! f . exists ( ) )
{
printf ( " Unable to set stylesheet, file not found \n " ) ;
2020-03-10 18:08:36 +00:00
printf ( " Tried to load: [%s] \n " , QString ( QString ( " /usr/share/wfview/stylesheets/ " ) + prefs . stylesheetPath ) . toStdString ( ) . c_str ( ) ) ;
2018-06-22 23:31:52 +00:00
}
else
{
f . open ( QFile : : ReadOnly | QFile : : Text ) ;
QTextStream ts ( & f ) ;
qApp - > setStyleSheet ( ts . readAll ( ) ) ;
}
} else {
qApp - > setStyleSheet ( " " ) ;
}
}
2018-11-25 06:21:36 +00:00
void wfmain : : setDefaultColors ( )
{
defaultColors . Dark_PlotBackground = QColor ( 0 , 0 , 0 , 255 ) ;
defaultColors . Dark_PlotAxisPen = QColor ( 75 , 75 , 75 , 255 ) ;
defaultColors . Dark_PlotLegendTextColor = QColor ( 255 , 255 , 255 , 255 ) ;
defaultColors . Dark_PlotLegendBorderPen = QColor ( 255 , 255 , 255 , 255 ) ;
defaultColors . Dark_PlotLegendBrush = QColor ( 0 , 0 , 0 , 200 ) ;
defaultColors . Dark_PlotTickLabel = QColor ( Qt : : white ) ;
defaultColors . Dark_PlotBasePen = QColor ( Qt : : white ) ;
defaultColors . Dark_PlotTickPen = QColor ( Qt : : white ) ;
defaultColors . Dark_PlotFreqTracer = QColor ( Qt : : yellow ) ;
defaultColors . Light_PlotBackground = QColor ( 255 , 255 , 255 , 255 ) ;
defaultColors . Light_PlotAxisPen = QColor ( 200 , 200 , 200 , 255 ) ;
defaultColors . Light_PlotLegendTextColor = QColor ( 0 , 0 , 0 , 255 ) ;
defaultColors . Light_PlotLegendBorderPen = QColor ( 0 , 0 , 0 , 255 ) ;
defaultColors . Light_PlotLegendBrush = QColor ( 255 , 255 , 255 , 200 ) ;
defaultColors . Light_PlotTickLabel = QColor ( Qt : : black ) ;
defaultColors . Light_PlotBasePen = QColor ( Qt : : black ) ;
defaultColors . Light_PlotTickPen = QColor ( Qt : : black ) ;
defaultColors . Light_PlotFreqTracer = QColor ( Qt : : blue ) ;
}
2018-06-22 23:31:52 +00:00
void wfmain : : setPlotTheme ( QCustomPlot * plot , bool isDark )
{
if ( isDark )
{
plot - > setBackground ( QColor ( 0 , 0 , 0 , 255 ) ) ;
plot - > xAxis - > grid ( ) - > setPen ( QColor ( 75 , 75 , 75 , 255 ) ) ;
plot - > yAxis - > grid ( ) - > setPen ( QColor ( 75 , 75 , 75 , 255 ) ) ;
plot - > legend - > setTextColor ( QColor ( 255 , 255 , 255 , 255 ) ) ;
plot - > legend - > setBorderPen ( QColor ( 255 , 255 , 255 , 255 ) ) ;
plot - > legend - > setBrush ( QColor ( 0 , 0 , 0 , 200 ) ) ;
plot - > xAxis - > setTickLabelColor ( Qt : : white ) ;
plot - > xAxis - > setLabelColor ( Qt : : white ) ;
plot - > yAxis - > setTickLabelColor ( Qt : : white ) ;
plot - > yAxis - > setLabelColor ( Qt : : white ) ;
plot - > xAxis - > setBasePen ( QPen ( Qt : : white ) ) ;
plot - > xAxis - > setTickPen ( QPen ( Qt : : white ) ) ;
plot - > yAxis - > setBasePen ( QPen ( Qt : : white ) ) ;
plot - > yAxis - > setTickPen ( QPen ( Qt : : white ) ) ;
2018-07-04 00:20:03 +00:00
plot - > graph ( 0 ) - > setPen ( QPen ( Qt : : yellow ) ) ; // magenta, yellow, green, lightGray
2018-06-22 23:31:52 +00:00
} else {
2018-06-23 07:31:41 +00:00
//color = ui->groupBox->palette().color(QPalette::Button);
2018-06-22 23:31:52 +00:00
plot - > setBackground ( QColor ( 255 , 255 , 255 , 255 ) ) ;
2018-06-23 07:31:41 +00:00
//plot->setBackground(color);
2018-06-22 23:31:52 +00:00
plot - > xAxis - > grid ( ) - > setPen ( QColor ( 200 , 200 , 200 , 255 ) ) ;
plot - > yAxis - > grid ( ) - > setPen ( QColor ( 200 , 200 , 200 , 255 ) ) ;
plot - > legend - > setTextColor ( QColor ( 0 , 0 , 0 , 255 ) ) ;
plot - > legend - > setBorderPen ( QColor ( 0 , 0 , 0 , 255 ) ) ;
plot - > legend - > setBrush ( QColor ( 255 , 255 , 255 , 200 ) ) ;
plot - > xAxis - > setTickLabelColor ( Qt : : black ) ;
plot - > xAxis - > setLabelColor ( Qt : : black ) ;
plot - > yAxis - > setTickLabelColor ( Qt : : black ) ;
plot - > yAxis - > setLabelColor ( Qt : : black ) ;
plot - > xAxis - > setBasePen ( QPen ( Qt : : black ) ) ;
plot - > xAxis - > setTickPen ( QPen ( Qt : : black ) ) ;
plot - > yAxis - > setBasePen ( QPen ( Qt : : black ) ) ;
plot - > yAxis - > setTickPen ( QPen ( Qt : : black ) ) ;
plot - > graph ( 0 ) - > setPen ( QPen ( Qt : : blue ) ) ;
}
2018-06-20 06:45:56 +00:00
}
2021-02-21 04:41:19 +00:00
void wfmain : : runPeriodicCommands ( )
{
// These commands are run at a regular interval. They are to be used sparingly.
// For general radio state queries, use the runDelayedCommand() queue,
// accessed by the insertPeriodicCommands() function.
// To insert commands to this queue, uset the insertPeriodicCommands() function.
// TODO: Queue should not remove items, just hit a different item each time.
int nCmds = periodicCmdQueue . length ( ) ;
cmds pcmd ;
if ( ! periodicCmdQueue . isEmpty ( ) )
{
pcmd = periodicCmdQueue . at ( ( pCmdNum + + ) % nCmds ) ;
switch ( pcmd )
{
case cmdNone :
break ;
// Metering commands:
case cmdGetSMeter :
2021-02-26 07:57:37 +00:00
if ( ! amTransmitting )
emit getMeters ( meterS ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdGetPowerMeter :
2021-02-26 07:57:37 +00:00
if ( amTransmitting )
emit getMeters ( meterPower ) ;
break ;
case cmdGetIdMeter :
emit getMeters ( meterCurrent ) ;
break ;
case cmdGetVdMeter :
emit getMeters ( meterVoltage ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdGetALCMeter :
2021-02-26 07:57:37 +00:00
if ( amTransmitting )
emit getMeters ( meterALC ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdGetCompMeter :
2021-02-26 07:57:37 +00:00
if ( amTransmitting )
emit getMeters ( meterComp ) ;
2021-02-21 04:41:19 +00:00
break ;
2021-02-26 07:57:37 +00:00
// Standard commands we are already checking:
2021-02-21 04:41:19 +00:00
case cmdGetRigID :
emit getRigID ( ) ;
break ;
case cmdGetRigCIV :
// if(!know rig civ already)
if ( ! haveRigCaps )
{
emit getRigCIV ( ) ;
cmdOutQue . append ( cmdGetRigCIV ) ; // This way, we stay here until we get an answer.
}
break ;
case cmdGetFreq :
emit getFrequency ( ) ;
break ;
case cmdGetMode :
emit getMode ( ) ;
break ;
case cmdGetDataMode :
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Sending query for data mode";
2021-02-21 04:41:19 +00:00
emit getDataMode ( ) ;
break ;
case cmdSetDataModeOff :
emit setDataMode ( false ) ;
break ;
case cmdSetDataModeOn :
emit setDataMode ( true ) ;
break ;
case cmdGetModInput :
emit getModInput ( false ) ;
break ;
case cmdGetModDataInput :
emit getModInput ( true ) ;
break ;
case cmdGetCurrentModLevel :
emit getModInputLevel ( currentModSrc ) ;
emit getModInputLevel ( currentModDataSrc ) ;
break ;
case cmdGetDuplexMode :
emit getDuplexMode ( ) ;
break ;
case cmdDispEnable :
emit scopeDisplayEnable ( ) ;
break ;
case cmdDispDisable :
emit scopeDisplayDisable ( ) ;
break ;
case cmdSpecOn :
emit spectOutputEnable ( ) ;
break ;
case cmdSpecOff :
emit spectOutputDisable ( ) ;
break ;
case cmdGetRxGain :
emit getRfGain ( ) ;
break ;
case cmdGetAfGain :
emit getAfGain ( ) ;
break ;
case cmdGetSql :
emit getSql ( ) ;
break ;
case cmdGetTxPower :
emit getTxPower ( ) ;
break ;
case cmdGetMicGain :
emit getMicGain ( ) ;
break ;
case cmdGetSpectrumRefLevel :
emit getSpectrumRefLevel ( ) ;
break ;
case cmdGetATUStatus :
emit getATUStatus ( ) ;
break ;
case cmdScopeCenterMode :
2021-03-01 05:41:27 +00:00
emit setScopeMode ( spectModeCenter ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdScopeFixedMode :
2021-03-01 05:41:27 +00:00
emit setScopeMode ( spectModeFixed ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdGetPTT :
emit getPTT ( ) ;
break ;
case cmdStartRegularPolling :
periodicPollingTimer - > start ( ) ;
break ;
case cmdStopRegularPolling :
periodicPollingTimer - > stop ( ) ;
break ;
default :
break ;
}
}
}
2018-06-19 19:58:52 +00:00
void wfmain : : runDelayedCommand ( )
{
2018-06-23 07:31:41 +00:00
cmds qdCmd ;
2020-03-17 22:15:01 +00:00
// Note: This cmdOut queue will be removed entirely soon and only the cmdOutQue will be available.
2018-06-19 19:58:52 +00:00
switch ( cmdOut )
{
case cmdGetFreq :
emit getFrequency ( ) ;
break ;
case cmdGetMode :
emit getMode ( ) ;
break ;
default :
break ;
}
2018-06-25 07:34:33 +00:00
cmdOut = cmdNone ; // yep. Hope this wasn't called twice in a row rapidly.
2018-06-23 07:31:41 +00:00
2019-01-10 06:44:48 +00:00
// Note: All command should use this queue. There is no need to use the above system.
2018-06-23 07:31:41 +00:00
if ( ! cmdOutQue . isEmpty ( ) )
{
qdCmd = cmdOutQue . takeFirst ( ) ;
switch ( qdCmd )
{
2018-11-20 07:42:34 +00:00
case cmdNone :
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "NOOP";
2018-11-20 07:42:34 +00:00
break ;
case cmdGetRigID :
emit getRigID ( ) ;
break ;
2021-01-30 06:09:09 +00:00
case cmdGetRigCIV :
2021-01-30 08:44:36 +00:00
// if(!know rig civ already)
if ( ! haveRigCaps )
{
emit getRigCIV ( ) ;
cmdOutQue . append ( cmdGetRigCIV ) ; // This way, we stay here until we get an answer.
}
2021-01-30 06:09:09 +00:00
break ;
2018-06-23 07:31:41 +00:00
case cmdGetFreq :
emit getFrequency ( ) ;
break ;
case cmdGetMode :
emit getMode ( ) ;
break ;
case cmdGetDataMode :
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Sending query for data mode";
2018-06-25 07:34:33 +00:00
emit getDataMode ( ) ;
2018-06-23 07:31:41 +00:00
break ;
2018-11-07 23:54:03 +00:00
case cmdSetDataModeOff :
emit setDataMode ( false ) ;
break ;
case cmdSetDataModeOn :
emit setDataMode ( true ) ;
break ;
2021-02-19 08:14:40 +00:00
case cmdGetModInput :
emit getModInput ( false ) ;
break ;
case cmdGetModDataInput :
emit getModInput ( true ) ;
break ;
2021-02-20 08:05:23 +00:00
case cmdGetCurrentModLevel :
emit getModInputLevel ( currentModSrc ) ;
emit getModInputLevel ( currentModDataSrc ) ;
break ;
2021-02-19 05:47:19 +00:00
case cmdGetDuplexMode :
emit getDuplexMode ( ) ;
break ;
2018-11-16 22:08:21 +00:00
case cmdDispEnable :
emit scopeDisplayEnable ( ) ;
break ;
case cmdDispDisable :
emit scopeDisplayDisable ( ) ;
break ;
2021-03-01 05:41:27 +00:00
case cmdGetSpectrumMode :
emit getScopeMode ( ) ;
break ;
2018-11-16 22:08:21 +00:00
case cmdSpecOn :
emit spectOutputEnable ( ) ;
break ;
case cmdSpecOff :
emit spectOutputDisable ( ) ;
break ;
2018-11-17 06:19:44 +00:00
case cmdGetRxGain :
emit getRfGain ( ) ;
break ;
case cmdGetAfGain :
emit getAfGain ( ) ;
break ;
2018-11-18 08:01:20 +00:00
case cmdGetSql :
emit getSql ( ) ;
break ;
2021-02-16 04:32:14 +00:00
case cmdGetTxPower :
emit getTxPower ( ) ;
break ;
case cmdGetMicGain :
emit getMicGain ( ) ;
break ;
2021-02-16 06:37:35 +00:00
case cmdGetSpectrumRefLevel :
emit getSpectrumRefLevel ( ) ;
2021-02-16 07:34:19 +00:00
break ;
2018-12-20 18:56:54 +00:00
case cmdGetATUStatus :
emit getATUStatus ( ) ;
break ;
2021-02-06 07:58:17 +00:00
case cmdScopeCenterMode :
2021-03-01 05:41:27 +00:00
emit setScopeMode ( spectModeCenter ) ;
2021-02-06 07:58:17 +00:00
break ;
case cmdScopeFixedMode :
2021-03-01 05:41:27 +00:00
emit setScopeMode ( spectModeFixed ) ;
2021-02-06 07:58:17 +00:00
break ;
2021-02-15 04:45:48 +00:00
case cmdGetPTT :
emit getPTT ( ) ;
break ;
2021-02-21 04:41:19 +00:00
case cmdStartRegularPolling :
periodicPollingTimer - > start ( ) ;
break ;
case cmdStopRegularPolling :
periodicPollingTimer - > stop ( ) ;
break ;
2018-06-23 07:31:41 +00:00
default :
break ;
}
}
if ( cmdOutQue . isEmpty ( ) )
{
// done
} else {
// next
2018-11-28 06:02:37 +00:00
// TODO: If we always do ->start, then it will not be necessary for
// every command insertion to include a ->start.... probably worth doing.
2018-06-23 07:31:41 +00:00
delayedCommand - > start ( ) ;
}
2018-06-19 19:58:52 +00:00
}
2021-02-15 04:45:48 +00:00
void wfmain : : issueDelayedCommand ( cmds cmd )
{
cmdOutQue . append ( cmd ) ;
delayedCommand - > start ( ) ;
}
2021-02-15 04:51:18 +00:00
void wfmain : : issueDelayedCommandPriority ( cmds cmd )
{
// Places the new command at the top of the queue
// Use only when needed.
cmdOutQue . prepend ( cmd ) ;
delayedCommand - > start ( ) ;
}
2021-01-25 00:16:38 +00:00
void wfmain : : receiveRigID ( rigCapabilities rigCaps )
{
// Note: We intentionally request rigID several times
// because without rigID, we can't do anything with the waterfall.
if ( haveRigCaps )
{
return ;
} else {
2021-02-02 09:05:59 +00:00
# ifdef QT_DEBUG
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Rig name: " < < rigCaps . modelName ;
qDebug ( logSystem ( ) ) < < " Has LAN capabilities: " < < rigCaps . hasLan ;
qDebug ( logSystem ( ) ) < < " Rig ID received into wfmain: spectLenMax: " < < rigCaps . spectLenMax ;
qDebug ( logSystem ( ) ) < < " Rig ID received into wfmain: spectAmpMax: " < < rigCaps . spectAmpMax ;
qDebug ( logSystem ( ) ) < < " Rig ID received into wfmain: spectSeqMax: " < < rigCaps . spectSeqMax ;
qDebug ( logSystem ( ) ) < < " Rig ID received into wfmain: hasSpectrum: " < < rigCaps . hasSpectrum ;
2021-02-02 09:05:59 +00:00
# endif
2021-01-25 00:16:38 +00:00
this - > rigCaps = rigCaps ;
this - > spectWidth = rigCaps . spectLenMax ; // used once haveRigCaps is true.
haveRigCaps = true ;
2021-02-28 20:10:07 +00:00
// Added so that server receives rig capabilities.
emit sendRigCaps ( rigCaps ) ;
2021-02-13 06:42:34 +00:00
if ( rigCaps . model = = model7850 )
{
ui - > modeSelectCombo - > addItem ( " PSK " , 0x12 ) ;
ui - > modeSelectCombo - > addItem ( " PSK-R " , 0x13 ) ;
}
if ( rigCaps . hasDV )
{
ui - > modeSelectCombo - > addItem ( " DV " , 0x17 ) ;
}
if ( rigCaps . hasDD )
{
ui - > modeSelectCombo - > addItem ( " DD " , 0x22 ) ;
}
2021-02-16 06:46:26 +00:00
if ( rigCaps . model = = model9700 )
{
ui - > satOpsBtn - > setDisabled ( false ) ;
ui - > adjRefBtn - > setDisabled ( false ) ;
} else {
ui - > satOpsBtn - > setDisabled ( true ) ;
ui - > adjRefBtn - > setDisabled ( true ) ;
}
2021-02-19 08:14:40 +00:00
QString inName ;
for ( int i = 0 ; i < rigCaps . inputs . length ( ) ; i + + )
{
switch ( rigCaps . inputs . at ( i ) )
{
case inputMic :
inName = " Mic " ;
break ;
case inputLAN :
inName = " LAN " ;
break ;
case inputUSB :
inName = " USB " ;
break ;
case inputACC :
inName = " ACC " ;
break ;
case inputACCA :
inName = " ACCA " ;
break ;
case inputACCB :
inName = " ACCB " ;
break ;
default :
inName = " Unknown " ;
break ;
}
ui - > modInputCombo - > addItem ( inName , rigCaps . inputs . at ( i ) ) ;
ui - > modInputDataCombo - > addItem ( inName , rigCaps . inputs . at ( i ) ) ;
}
if ( rigCaps . inputs . length ( ) = = 0 )
{
ui - > modInputCombo - > addItem ( " None " , inputNone ) ;
ui - > modInputDataCombo - > addItem ( " None " , inputNone ) ;
}
2021-02-16 06:46:26 +00:00
2021-02-13 06:42:34 +00:00
ui - > tuneEnableChk - > setEnabled ( rigCaps . hasATU ) ;
ui - > tuneNowBtn - > setEnabled ( rigCaps . hasATU ) ;
2021-02-07 17:40:38 +00:00
ui - > connectBtn - > setText ( " Disconnect " ) ; // We must be connected now.
2021-01-25 00:16:38 +00:00
prepareWf ( ) ;
// Adding these here because clearly at this point we have valid
// rig comms. In the future, we should establish comms and then
// do all the initial grabs. For now, this hack of adding them here and there:
cmdOutQue . append ( cmdGetFreq ) ;
cmdOutQue . append ( cmdGetMode ) ;
2021-02-21 04:41:19 +00:00
initPeriodicCommands ( ) ;
}
}
void wfmain : : initPeriodicCommands ( )
{
// This function places periodic polling commands into a queue.
// The commands are run using a timer,
// and the timer is started by the delayed command cmdStartPeriodicTimer.
2021-02-26 07:57:37 +00:00
insertPeriodicCommand ( cmdGetSMeter , 128 ) ;
insertPeriodicCommand ( cmdGetPowerMeter , 128 ) ;
2021-02-21 04:41:19 +00:00
}
void wfmain : : insertPeriodicCommand ( cmds cmd , unsigned char priority )
{
// TODO: meaningful priority
if ( priority < 10 )
{
periodicCmdQueue . prepend ( cmd ) ;
} else {
periodicCmdQueue . append ( cmd ) ;
2021-01-25 00:16:38 +00:00
}
}
2018-06-19 19:58:52 +00:00
void wfmain : : receiveFreq ( double freqMhz )
{
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz;
2018-06-19 19:58:52 +00:00
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( freqMhz , 0 , ' f ' ) ) ;
2018-06-20 06:45:56 +00:00
this - > freqMhz = freqMhz ;
2018-07-04 00:20:03 +00:00
this - > knobFreqMhz = freqMhz ;
2019-12-26 08:27:14 +00:00
//showStatusBarText(QString("Frequency: %1").arg(freqMhz));
2018-11-07 23:54:03 +00:00
}
void wfmain : : receivePTTstatus ( bool pttOn )
{
2021-02-15 04:45:48 +00:00
// This is the only place where amTransmitting and the transmit button text should be changed:
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " PTT status: " < < pttOn ;
2021-03-01 16:26:59 +00:00
if ( pttOn & & ! amTransmitting )
{
pttLed - > setState ( QLedLabel : : State : : StateError ) ;
}
else if ( ! pttOn & & amTransmitting )
{
pttLed - > setState ( QLedLabel : : State : : StateOk ) ;
}
2021-02-15 04:45:48 +00:00
amTransmitting = pttOn ;
changeTxBtn ( ) ;
}
void wfmain : : changeTxBtn ( )
{
if ( amTransmitting )
{
ui - > transmitBtn - > setText ( " Receive " ) ;
} else {
ui - > transmitBtn - > setText ( " Transmit " ) ;
}
2018-06-19 19:58:52 +00:00
}
2021-02-15 04:45:48 +00:00
2018-06-19 19:58:52 +00:00
void wfmain : : receiveSpectrumData ( QByteArray spectrum , double startFreq , double endFreq )
{
2021-01-25 00:16:38 +00:00
if ( ! haveRigCaps )
{
2021-02-02 09:05:59 +00:00
# ifdef QT_DEBUG
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Spectrum received, but RigID incomplete. " ;
2021-02-02 09:05:59 +00:00
# endif
2021-01-25 00:16:38 +00:00
return ;
}
2018-06-19 19:58:52 +00:00
if ( ( startFreq ! = oldLowerFreq ) | | ( endFreq ! = oldUpperFreq ) )
{
2019-01-10 06:44:48 +00:00
// If the frequency changed and we were drawing peaks, now is the time to clearn them
2018-06-19 19:58:52 +00:00
if ( drawPeaks )
2019-01-10 06:44:48 +00:00
{
// TODO: create non-button function to do this
// This will break if the button is ever moved or renamed.
2018-06-19 19:58:52 +00:00
on_clearPeakBtn_clicked ( ) ;
2019-01-10 06:44:48 +00:00
}
2018-06-19 19:58:52 +00:00
}
oldLowerFreq = startFreq ;
oldUpperFreq = endFreq ;
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "start: " << startFreq << " end: " << endFreq;
2018-06-19 19:58:52 +00:00
quint16 specLen = spectrum . length ( ) ;
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "Spectrum data received at UI! Length: " << specLen;
2021-01-25 00:16:38 +00:00
//if( (specLen != 475) || (specLen!=689) )
if ( specLen ! = rigCaps . spectLenMax )
2018-06-19 19:58:52 +00:00
{
2021-02-02 09:05:59 +00:00
# ifdef QT_DEBUG
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " ------------------------------------------- " ;
qDebug ( logSystem ( ) ) < < " ------ Unusual spectrum received, length: " < < specLen ;
qDebug ( logSystem ( ) ) < < " ------ Expected spectrum length: " < < rigCaps . spectLenMax ;
qDebug ( logSystem ( ) ) < < " ------ This should happen once at most. " ;
2021-02-02 09:05:59 +00:00
# endif
2018-06-19 19:58:52 +00:00
return ; // safe. Using these unusual length things is a problem.
}
QVector < double > x ( spectWidth ) , y ( spectWidth ) , y2 ( spectWidth ) ;
for ( int i = 0 ; i < spectWidth ; i + + )
{
x [ i ] = ( i * ( endFreq - startFreq ) / spectWidth ) + startFreq ;
}
for ( int i = 0 ; i < specLen ; i + + )
{
//x[i] = (i * (endFreq-startFreq)/specLen) + startFreq;
y [ i ] = spectrum . at ( i ) ;
if ( drawPeaks )
{
if ( spectrum . at ( i ) > spectrumPeaks . at ( i ) )
{
spectrumPeaks [ i ] = spectrum . at ( i ) ;
}
y2 [ i ] = spectrumPeaks . at ( i ) ;
}
}
//ui->qcp->addGraph();
plot - > graph ( 0 ) - > setData ( x , y ) ;
2018-06-20 06:45:56 +00:00
if ( ( freqMhz < endFreq ) & & ( freqMhz > startFreq ) )
{
2018-07-04 00:20:03 +00:00
// tracer->setGraphKey(freqMhz);
tracer - > setGraphKey ( knobFreqMhz ) ;
2018-06-20 06:45:56 +00:00
}
2018-06-19 19:58:52 +00:00
if ( drawPeaks )
{
plot - > graph ( 1 ) - > setData ( x , y2 ) ; // peaks
}
2021-02-13 01:21:32 +00:00
plot - > yAxis - > setRange ( 0 , rigCaps . spectAmpMax + 1 ) ;
2018-06-19 19:58:52 +00:00
plot - > xAxis - > setRange ( startFreq , endFreq ) ;
plot - > replot ( ) ;
if ( specLen = = spectWidth )
{
wfimage . prepend ( spectrum ) ;
if ( wfimage . length ( ) > wfLength )
{
wfimage . remove ( wfLength ) ;
}
// Waterfall:
for ( int row = 0 ; row < wfLength ; row + + )
{
for ( int col = 0 ; col < spectWidth ; col + + )
{
//colorMap->data()->cellToCoord(xIndex, yIndex, &x, &y)
// Very fast but doesn't roll downward:
//colorMap->data()->setCell( col, spectRowCurrent, spectrum.at(col) );
// Slow but rolls:
colorMap - > data ( ) - > setCell ( col , row , wfimage . at ( row ) . at ( col ) ) ;
}
}
//colorMap->data()->setRange(QCPRange(startFreq, endFreq), QCPRange(0,wfLength-1));
wf - > yAxis - > setRange ( 0 , wfLength - 1 ) ;
wf - > xAxis - > setRange ( 0 , spectWidth - 1 ) ;
wf - > replot ( ) ;
spectRowCurrent = ( spectRowCurrent + 1 ) % wfLength ;
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << "updating spectrum, new row is: " << spectRowCurrent;
2018-06-19 19:58:52 +00:00
}
}
2021-03-01 05:41:27 +00:00
void wfmain : : receiveSpectrumMode ( spectrumMode spectMode )
2021-02-05 06:44:15 +00:00
{
2021-03-01 05:41:27 +00:00
for ( int i = 0 ; i < ui - > spectrumModeCombo - > count ( ) ; i + + )
{
if ( static_cast < spectrumMode > ( ui - > spectrumModeCombo - > itemData ( i ) . toInt ( ) ) = = spectMode )
{
ui - > spectrumModeCombo - > blockSignals ( true ) ;
ui - > spectrumModeCombo - > setCurrentIndex ( i ) ;
ui - > spectrumModeCombo - > blockSignals ( false ) ;
}
}
2021-02-05 06:44:15 +00:00
}
2021-03-01 05:41:27 +00:00
2018-06-19 19:58:52 +00:00
void wfmain : : handlePlotDoubleClick ( QMouseEvent * me )
{
double x ;
2018-11-07 23:54:03 +00:00
//double y;
2018-06-19 19:58:52 +00:00
//double px;
2021-02-26 08:24:02 +00:00
if ( ! freqLock )
{
//y = plot->yAxis->pixelToCoord(me->pos().y());
x = plot - > xAxis - > pixelToCoord ( me - > pos ( ) . x ( ) ) ;
emit setFrequency ( x ) ;
2021-02-28 08:54:37 +00:00
issueDelayedCommand ( cmdGetFreq ) ;
2021-02-26 08:24:02 +00:00
showStatusBarText ( QString ( " Going to %1 MHz " ) . arg ( x ) ) ;
}
2018-06-19 19:58:52 +00:00
}
void wfmain : : handleWFDoubleClick ( QMouseEvent * me )
{
double x ;
//double y;
//x = wf->xAxis->pixelToCoord(me->pos().x());
//y = wf->yAxis->pixelToCoord(me->pos().y());
// cheap trick until I figure out how the axis works on the WF:
2021-02-26 08:24:02 +00:00
if ( ! freqLock )
{
x = plot - > xAxis - > pixelToCoord ( me - > pos ( ) . x ( ) ) ;
emit setFrequency ( x ) ;
2021-02-28 08:54:37 +00:00
issueDelayedCommand ( cmdGetFreq ) ;
2021-02-26 08:24:02 +00:00
showStatusBarText ( QString ( " Going to %1 MHz " ) . arg ( x ) ) ;
}
2018-06-19 19:58:52 +00:00
}
void wfmain : : handlePlotClick ( QMouseEvent * me )
{
2018-11-07 23:54:03 +00:00
double x = plot - > xAxis - > pixelToCoord ( me - > pos ( ) . x ( ) ) ;
showStatusBarText ( QString ( " Selected %1 MHz " ) . arg ( x ) ) ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : handleWFClick ( QMouseEvent * me )
{
2018-11-07 23:54:03 +00:00
double x = plot - > xAxis - > pixelToCoord ( me - > pos ( ) . x ( ) ) ;
showStatusBarText ( QString ( " Selected %1 MHz " ) . arg ( x ) ) ;
2018-06-19 19:58:52 +00:00
}
2020-04-21 04:10:20 +00:00
void wfmain : : handleWFScroll ( QWheelEvent * we )
{
// The wheel event is typically
// .y() and is +/- 120.
// We will click the dial once for every 120 received.
//QPoint delta = we->angleDelta();
2021-02-02 09:05:59 +00:00
2021-02-27 01:32:06 +00:00
if ( freqLock )
return ;
int clicks = we - > angleDelta ( ) . y ( ) / 120 ;
float steps = tsWfScroll * clicks ;
2021-02-02 09:05:59 +00:00
2020-04-21 04:23:34 +00:00
Qt : : KeyboardModifiers key = we - > modifiers ( ) ;
if ( key = = Qt : : ShiftModifier )
{
2021-02-27 01:32:06 +00:00
steps / = 10 ;
2020-04-21 04:23:34 +00:00
} else if ( key = = Qt : : ControlModifier )
{
steps * = 10 ;
}
2021-02-27 01:32:06 +00:00
freqMhz = roundFrequency ( freqMhz - steps ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( freqMhz , 0 , ' f ' ) ) ;
issueDelayedCommand ( cmdGetFreq ) ;
2020-04-21 04:10:20 +00:00
}
void wfmain : : handlePlotScroll ( QWheelEvent * we )
{
2021-02-27 01:32:06 +00:00
if ( freqLock )
return ;
int clicks = we - > angleDelta ( ) . y ( ) / 120 ;
float steps = tsWfScroll * clicks ;
2020-04-21 04:23:34 +00:00
Qt : : KeyboardModifiers key = we - > modifiers ( ) ;
if ( key = = Qt : : ShiftModifier )
{
2021-02-27 01:32:06 +00:00
steps / = 10 ;
2020-04-21 04:23:34 +00:00
} else if ( key = = Qt : : ControlModifier )
{
steps * = 10 ;
}
2021-02-27 01:32:06 +00:00
freqMhz = roundFrequency ( freqMhz - steps ) ;
knobFreqMhz = freqMhz ;
emit setFrequency ( freqMhz ) ;
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( freqMhz , 0 , ' f ' ) ) ;
issueDelayedCommand ( cmdGetFreq ) ;
2020-04-21 04:10:20 +00:00
}
2021-02-09 07:31:44 +00:00
void wfmain : : on_scopeEnableWFBtn_clicked ( bool checked )
{
if ( checked )
{
emit spectOutputEnable ( ) ;
} else {
emit spectOutputDisable ( ) ;
}
}
2018-06-19 19:58:52 +00:00
2021-02-14 07:42:51 +00:00
void wfmain : : receiveMode ( unsigned char mode , unsigned char filter )
2018-06-19 19:58:52 +00:00
{
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << __func__ << "Received mode " << mode << " current mode: " << currentModeIndex;
2021-02-13 06:42:34 +00:00
2021-02-13 07:35:17 +00:00
bool found = false ;
if ( mode < 0x23 )
2021-02-13 06:42:34 +00:00
{
2021-02-13 07:35:17 +00:00
for ( int i = 0 ; i < ui - > modeSelectCombo - > count ( ) ; i + + )
{
if ( ui - > modeSelectCombo - > itemData ( i ) . toInt ( ) = = mode )
{
ui - > modeSelectCombo - > blockSignals ( true ) ;
ui - > modeSelectCombo - > setCurrentIndex ( i ) ;
ui - > modeSelectCombo - > blockSignals ( false ) ;
found = true ;
}
}
2021-02-13 06:42:34 +00:00
currentModeIndex = mode ;
2021-02-13 07:35:17 +00:00
} else {
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < __func__ < < " Invalid mode " < < mode < < " received. " ;
2021-02-13 07:35:17 +00:00
}
if ( ! found )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < __func__ < < " Received mode " < < mode < < " but could not match to any index within the modeSelectCombo. " ;
2021-02-13 06:42:34 +00:00
}
2021-02-14 07:42:51 +00:00
if ( ( filter ) & & ( filter < 4 ) ) {
ui - > modeFilterCombo - > blockSignals ( true ) ;
ui - > modeFilterCombo - > setCurrentIndex ( filter - 1 ) ;
ui - > modeFilterCombo - > blockSignals ( false ) ;
}
( void ) filter ;
2021-02-13 06:42:34 +00:00
2018-06-19 19:58:52 +00:00
// Note: we need to know if the DATA mode is active to reach mode-D
// some kind of queued query:
2018-11-16 22:08:21 +00:00
cmdOutQue . append ( cmdGetDataMode ) ;
delayedCommand - > start ( ) ; // why was that commented out?
}
void wfmain : : receiveDataModeStatus ( bool dataEnabled )
{
2021-02-13 06:49:42 +00:00
ui - > dataModeBtn - > blockSignals ( true ) ;
ui - > dataModeBtn - > setChecked ( dataEnabled ) ;
ui - > dataModeBtn - > blockSignals ( false ) ;
2021-02-20 08:05:23 +00:00
usingDataMode = dataEnabled ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : on_clearPeakBtn_clicked ( )
{
2021-01-25 00:16:38 +00:00
if ( haveRigCaps )
{
spectrumPeaks = QByteArray ( ( int ) spectWidth , ' \x01 ' ) ;
}
return ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : on_drawPeakChk_clicked ( bool checked )
{
if ( checked )
{
on_clearPeakBtn_clicked ( ) ; // clear
drawPeaks = true ;
} else {
drawPeaks = false ;
2020-03-27 23:34:32 +00:00
# if QCUSTOMPLOT_VERSION >= 0x020000
plot - > graph ( 1 ) - > data ( ) - > clear ( ) ;
# else
2018-06-19 19:58:52 +00:00
plot - > graph ( 1 ) - > clearData ( ) ;
2020-03-27 23:34:32 +00:00
# endif
2018-06-19 19:58:52 +00:00
}
2018-11-27 07:10:23 +00:00
prefs . drawPeaks = checked ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : on_fullScreenChk_clicked ( bool checked )
{
if ( checked )
2018-11-28 06:02:37 +00:00
{
2018-06-19 19:58:52 +00:00
this - > showFullScreen ( ) ;
2018-11-28 06:02:37 +00:00
onFullscreen = true ;
} else {
2018-06-19 19:58:52 +00:00
this - > showNormal ( ) ;
2018-11-28 06:02:37 +00:00
onFullscreen = false ;
}
2018-11-27 07:10:23 +00:00
prefs . useFullScreen = checked ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : on_goFreqBtn_clicked ( )
{
bool ok = false ;
double freq = ui - > freqMhzLineEdit - > text ( ) . toDouble ( & ok ) ;
if ( ok )
{
emit setFrequency ( freq ) ;
2021-02-28 07:47:09 +00:00
issueDelayedCommand ( cmdGetFreq ) ;
2018-06-19 19:58:52 +00:00
}
ui - > freqMhzLineEdit - > selectAll ( ) ;
freqTextSelected = true ;
2018-11-16 22:08:21 +00:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : checkFreqSel ( )
{
if ( freqTextSelected )
{
freqTextSelected = false ;
ui - > freqMhzLineEdit - > clear ( ) ;
}
}
void wfmain : : on_f0btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 0 " ) ) ;
}
void wfmain : : on_f1btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 1 " ) ) ;
}
void wfmain : : on_f2btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 2 " ) ) ;
}
void wfmain : : on_f3btn_clicked ( )
{
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 3 " ) ) ;
}
void wfmain : : on_f4btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 4 " ) ) ;
}
void wfmain : : on_f5btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 5 " ) ) ;
}
void wfmain : : on_f6btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 6 " ) ) ;
}
void wfmain : : on_f7btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 7 " ) ) ;
}
void wfmain : : on_f8btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 8 " ) ) ;
}
void wfmain : : on_f9btn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " 9 " ) ) ;
}
void wfmain : : on_fDotbtn_clicked ( )
{
checkFreqSel ( ) ;
ui - > freqMhzLineEdit - > setText ( ui - > freqMhzLineEdit - > text ( ) . append ( " . " ) ) ;
}
void wfmain : : on_fBackbtn_clicked ( )
{
QString currentFreq = ui - > freqMhzLineEdit - > text ( ) ;
currentFreq . chop ( 1 ) ;
ui - > freqMhzLineEdit - > setText ( currentFreq ) ;
}
void wfmain : : on_fCEbtn_clicked ( )
{
ui - > freqMhzLineEdit - > clear ( ) ;
freqTextSelected = false ;
}
2021-03-01 05:41:27 +00:00
void wfmain : : on_spectrumModeCombo_currentIndexChanged ( int index )
2018-06-19 19:58:52 +00:00
{
2021-03-01 05:41:27 +00:00
emit setScopeMode ( static_cast < spectrumMode > ( ui - > spectrumModeCombo - > itemData ( index ) . toInt ( ) ) ) ;
2018-06-19 19:58:52 +00:00
}
void wfmain : : on_fEnterBtn_clicked ( )
{
2018-11-24 08:10:05 +00:00
// TODO: do not jump to main tab on enter, only on return
// or something.
// Maybe this should be an option in settings.
2018-06-19 19:58:52 +00:00
on_goFreqBtn_clicked ( ) ;
}
void wfmain : : on_scopeBWCombo_currentIndexChanged ( int index )
{
emit setScopeSpan ( ( char ) index ) ;
}
void wfmain : : on_scopeEdgeCombo_currentIndexChanged ( int index )
{
emit setScopeEdge ( ( char ) index + 1 ) ;
}
2021-02-17 06:32:05 +00:00
void wfmain : : changeMode ( mode_kind mode )
{
bool dataOn = false ;
if ( ( ( unsigned char ) mode > > 4 ) = = 0x08 )
{
dataOn = true ;
mode = ( mode_kind ) ( ( int ) mode & 0x0f ) ;
}
changeMode ( mode , dataOn ) ;
}
void wfmain : : changeMode ( mode_kind mode , bool dataOn )
{
int filter = ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ;
emit setMode ( ( unsigned char ) mode , filter ) ;
if ( dataOn )
{
issueDelayedCommand ( cmdSetDataModeOn ) ;
ui - > dataModeBtn - > blockSignals ( true ) ;
ui - > dataModeBtn - > setChecked ( true ) ;
ui - > dataModeBtn - > blockSignals ( false ) ;
} else {
issueDelayedCommand ( cmdSetDataModeOff ) ;
ui - > dataModeBtn - > blockSignals ( true ) ;
ui - > dataModeBtn - > setChecked ( false ) ;
ui - > dataModeBtn - > blockSignals ( false ) ;
}
issueDelayedCommand ( cmdGetMode ) ;
}
2018-06-25 07:34:33 +00:00
void wfmain : : on_modeSelectCombo_activated ( int index )
{
2019-02-03 22:09:06 +00:00
// The "acticvated" signal means the user initiated a mode change.
// This function is not called if code initated the change.
2018-06-19 19:58:52 +00:00
2021-02-13 07:18:01 +00:00
unsigned char newMode = static_cast < unsigned char > ( ui - > modeSelectCombo - > itemData ( index ) . toUInt ( ) ) ;
2021-02-13 07:35:17 +00:00
currentModeIndex = newMode ;
2018-06-25 07:34:33 +00:00
2021-02-13 18:02:45 +00:00
int filterSelection = ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ;
if ( filterSelection = = 99 )
{
// oops, we forgot to reset the combo box
} else {
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < __func__ < < " at index " < < index < < " has newMode: " < < newMode ;
2021-02-13 18:02:45 +00:00
emit setMode ( newMode , filterSelection ) ;
}
2018-06-19 19:58:52 +00:00
}
2018-06-22 23:31:52 +00:00
2018-06-25 07:34:33 +00:00
void wfmain : : on_freqDial_valueChanged ( int value )
{
2021-02-22 07:58:23 +00:00
int maxVal = ui - > freqDial - > maximum ( ) ;
2018-11-07 23:54:03 +00:00
double stepSize = 0.000100 ; // 100 Hz steps
2018-07-04 00:20:03 +00:00
double newFreqMhz = 0 ;
volatile int delta = 0 ;
int directPath = 0 ;
int crossingPath = 0 ;
2021-02-22 07:58:23 +00:00
2018-07-04 00:20:03 +00:00
int distToMaxNew = 0 ;
int distToMaxOld = 0 ;
2021-02-22 07:58:23 +00:00
if ( freqLock )
{
ui - > freqDial - > blockSignals ( true ) ;
ui - > freqDial - > setValue ( oldFreqDialVal ) ;
ui - > freqDial - > blockSignals ( false ) ;
return ;
}
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Old value: " << oldFreqDialVal << " New value: " << value ;
2021-02-22 07:58:23 +00:00
2018-07-04 00:20:03 +00:00
if ( value = = 0 )
{
distToMaxNew = 0 ;
} else {
distToMaxNew = maxVal - value ;
}
if ( oldFreqDialVal ! = 0 )
{
distToMaxOld = maxVal - oldFreqDialVal ;
} else {
distToMaxOld = 0 ;
}
directPath = abs ( value - oldFreqDialVal ) ;
if ( value < maxVal / 2 )
{
crossingPath = value + distToMaxOld ;
} else {
crossingPath = distToMaxNew + oldFreqDialVal ;
}
if ( directPath > crossingPath )
{
// use crossing path, it is shorter
delta = crossingPath ;
// mnow calculate the direction:
if ( value > oldFreqDialVal )
{
// CW
delta = delta ;
} else {
// CCW
delta * = - 1 ;
}
} else {
// use direct path
// crossing path is larger than direct path, use direct path
//delta = directPath;
// now calculate the direction
delta = value - oldFreqDialVal ;
}
newFreqMhz = knobFreqMhz + ( delta * stepSize ) ;
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "old freq: " << knobFreqMhz << " new freq: " << newFreqMhz << "knobDelta: " << delta << " freq delta: " << newFreqMhz - knobFreqMhz;
2018-07-04 00:20:03 +00:00
2018-11-16 22:08:21 +00:00
if ( ui - > tuningFloorZerosChk - > isChecked ( ) )
{
newFreqMhz = ( double ) round ( newFreqMhz * 10000 ) / 10000.0 ;
}
2018-07-04 00:20:03 +00:00
this - > knobFreqMhz = newFreqMhz ; // the frequency we think we should be on.
oldFreqDialVal = value ;
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( knobFreqMhz , 0 , ' f ' ) ) ;
2021-02-22 07:58:23 +00:00
this - > freqMhz = knobFreqMhz ;
2018-07-04 00:20:03 +00:00
emit setFrequency ( newFreqMhz ) ;
//emit getFrequency();
2018-06-25 07:34:33 +00:00
}
2018-11-16 22:08:21 +00:00
void wfmain : : receiveBandStackReg ( float freq , char mode , bool dataOn )
{
// read the band stack and apply by sending out commands
setFrequency ( freq ) ;
2021-02-13 18:02:45 +00:00
int filterSelection = ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ;
setMode ( mode , ( unsigned char ) filterSelection ) ; // make sure this is what you think it is
2018-11-16 22:08:21 +00:00
// setDataMode(dataOn); // signal out
if ( dataOn )
{
cmdOutQue . append ( cmdSetDataModeOn ) ;
} else {
cmdOutQue . append ( cmdSetDataModeOff ) ;
}
cmdOutQue . append ( cmdGetFreq ) ;
cmdOutQue . append ( cmdGetMode ) ;
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
delayedCommand - > start ( ) ;
}
void wfmain : : bandStackBtnClick ( )
{
bandStkRegCode = ui - > bandStkPopdown - > currentIndex ( ) + 1 ;
waitingForBandStackRtn = true ; // so that when the return is parsed we jump to this frequency/mode info
emit getBandStackReg ( bandStkBand , bandStkRegCode ) ;
}
void wfmain : : on_band6mbtn_clicked ( )
{
bandStkBand = 0x10 ; // 6 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band10mbtn_clicked ( )
{
bandStkBand = 0x09 ; // 10 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band12mbtn_clicked ( )
{
bandStkBand = 0x08 ; // 12 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band15mbtn_clicked ( )
{
bandStkBand = 0x07 ; // 15 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band17mbtn_clicked ( )
{
bandStkBand = 0x06 ; // 17 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band20mbtn_clicked ( )
{
bandStkBand = 0x05 ; // 20 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band30mbtn_clicked ( )
{
bandStkBand = 0x04 ; // 30 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band40mbtn_clicked ( )
{
bandStkBand = 0x03 ; // 40 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band60mbtn_clicked ( )
{
// This one is tricky. There isn't a band stack register on the
// 7300 for 60 meters, so we just drop to the middle of the band:
// Channel 1: 5330.5 kHz
// Channel 2: 5346.5 kHz
// Channel 3: 5357.0 kHz
// Channel 4: 5371.5 kHz
// Channel 5: 5403.5 kHz
// Really not sure what the best strategy here is, don't want to
// clutter the UI with 60M channel buttons...
setFrequency ( 5.3305 ) ;
}
void wfmain : : on_band80mbtn_clicked ( )
{
bandStkBand = 0x02 ; // 80 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band160mbtn_clicked ( )
{
bandStkBand = 0x01 ; // 160 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_bandGenbtn_clicked ( )
{
// "GENE" general coverage frequency outside the ham bands
// which does probably include any 60 meter frequencies used.
bandStkBand = 0x11 ; // GEN
bandStackBtnClick ( ) ;
}
void wfmain : : on_aboutBtn_clicked ( )
{
// Show.....
// Build date, time, git checksum (short)
// QT library version
// stylesheet credit
// contact information
2020-03-12 00:44:47 +00:00
QMessageBox msgBox ( this ) ;
2020-03-14 02:43:12 +00:00
msgBox . setWindowTitle ( " Abou wfview " ) ;
2020-03-12 00:44:47 +00:00
msgBox . setTextFormat ( Qt : : RichText ) ;
2020-03-13 03:06:33 +00:00
msgBox . setWindowIcon ( QIcon ( " :resources/wfview.png " ) ) ;
2020-03-12 00:44:47 +00:00
// TODO: change style of link color based on current CSS sheet.
2021-02-14 07:42:51 +00:00
QString head = QString ( " <html><head></head><body> " ) ;
QString copyright = QString ( " Copyright 2017-2021 Elliott H. Liggett, W6EL. All rights reserved. " ) ;
QString nacode = QString ( " <br/><br/>Networking and audio code written by Phil Taylor, M0VSE " ) ;
QString doctest = QString ( " <br/><br/>Testing, documentation, bug fixes, and development mentorship from Roeland Jansen, PA3MET, and Jim Nijkamp, PA8E. " ) ;
QString ssCredit = QString ( " <br/><br/>Stylesheet qdarkstyle used under MIT license, stored in /usr/share/wfview/stylesheets/. " ) ;
2020-03-12 00:44:47 +00:00
QString website = QString ( " <br/><br/>Get the latest version from our gitlab repo: <a href='https://gitlab.com/eliggett/wfview' style='color: cyan;'>https://gitlab.com/eliggett/wfview</a> " ) ;
QString docs = QString ( " <br/>Also see the <a href='https://gitlab.com/eliggett/wfview/-/wikis/home' style='color: cyan;'>wiki</a> for the <a href='https://gitlab.com/eliggett/wfview/-/wikis/User-FAQ' style='color: cyan;'>FAQ</a>, <a href='https://gitlab.com/eliggett/wfview/-/wikis/Keystrokes' style='color: cyan;'>Keystrokes</a>, and more. " ) ;
2021-02-14 07:42:51 +00:00
QString contact = QString ( " <br/>email the author: kilocharlie8@gmail.com or W6EL on the air! " ) ;
2020-03-12 00:44:47 +00:00
QString buildInfo = QString ( " <br/><br/>Build " + QString ( GITSHORT ) + " on " + QString ( __DATE__ ) + " at " + __TIME__ + " by " + UNAME + " @ " + HOST ) ;
2021-02-14 07:42:51 +00:00
QString end = QString ( " </body></html> " ) ;
2018-11-16 22:08:21 +00:00
2021-02-14 07:42:51 +00:00
QString aboutText = head + copyright + " \n " + nacode + " \n " + doctest + " \n " + ssCredit + " \n " ;
aboutText . append ( website + " \n " + docs + contact + " \n " + buildInfo + end ) ;
2018-11-16 22:08:21 +00:00
2020-03-12 00:44:47 +00:00
msgBox . setText ( aboutText ) ;
msgBox . exec ( ) ;
2018-11-16 22:08:21 +00:00
}
void wfmain : : on_fStoBtn_clicked ( )
{
// sequence:
// type frequency
// press Enter or Go
// change mode if desired
2018-11-24 08:10:05 +00:00
// type in index number 0 through 99
2018-11-16 22:08:21 +00:00
// press STO
2018-11-24 08:10:05 +00:00
bool ok ;
QString freqString ;
int preset_number = ui - > freqMhzLineEdit - > text ( ) . toInt ( & ok ) ;
if ( ok & & ( preset_number > = 0 ) & & ( preset_number < 100 ) )
{
// TODO: keep an enum around with the current mode
mem . setPreset ( preset_number , freqMhz , ( mode_kind ) ui - > modeSelectCombo - > currentIndex ( ) ) ;
2020-03-30 21:09:52 +00:00
showStatusBarText ( QString ( " Storing frequency %1 to memory location %2 " ) . arg ( freqMhz ) . arg ( preset_number ) ) ;
2018-11-24 08:10:05 +00:00
} else {
2020-03-30 21:09:52 +00:00
showStatusBarText ( QString ( " Could not store preset to %1. Valid preset numbers are 0 to 99 " ) . arg ( preset_number ) ) ;
2018-11-24 08:10:05 +00:00
}
2018-11-16 22:08:21 +00:00
}
void wfmain : : on_fRclBtn_clicked ( )
{
// Sequence:
// type memory location 0 through 99
// press RCL
// Program recalls data stored in vector at position specified
// drop contents into text box, press go button
// add delayed command for mode and data mode
2018-11-24 08:10:05 +00:00
preset_kind temp ;
bool ok ;
QString freqString ;
int preset_number = ui - > freqMhzLineEdit - > text ( ) . toInt ( & ok ) ;
if ( ok & & ( preset_number > = 0 ) & & ( preset_number < 100 ) )
{
temp = mem . getPreset ( preset_number ) ;
freqString = QString ( " %1 " ) . arg ( temp . frequency ) ;
ui - > freqMhzLineEdit - > setText ( freqString ) ;
ui - > goFreqBtn - > click ( ) ;
} else {
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Could not recall preset. Valid presets are 0 through 99. " ;
2018-11-24 08:10:05 +00:00
}
2018-11-16 22:08:21 +00:00
}
2018-11-17 06:19:44 +00:00
void wfmain : : on_rfGainSlider_valueChanged ( int value )
{
emit setRfGain ( ( unsigned char ) value ) ;
}
void wfmain : : on_afGainSlider_valueChanged ( int value )
{
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Setting AF gain to " << value;
2018-11-17 06:19:44 +00:00
emit setAfGain ( ( unsigned char ) value ) ;
}
void wfmain : : receiveRfGain ( unsigned char level )
{
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Receive RF level of" << (int)level << " = " << 100*level/255.0 << "%";
2018-12-19 20:31:44 +00:00
ui - > rfGainSlider - > blockSignals ( true ) ;
2018-11-17 06:19:44 +00:00
ui - > rfGainSlider - > setValue ( level ) ;
2018-12-19 20:31:44 +00:00
ui - > rfGainSlider - > blockSignals ( false ) ;
2018-11-17 06:19:44 +00:00
}
void wfmain : : receiveAfGain ( unsigned char level )
{
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Receive AF level of" << (int)level << " = " << 100*level/255.0 << "%";
2018-12-19 20:31:44 +00:00
ui - > afGainSlider - > blockSignals ( true ) ;
2018-11-17 06:19:44 +00:00
ui - > afGainSlider - > setValue ( level ) ;
2018-12-19 20:31:44 +00:00
ui - > afGainSlider - > blockSignals ( false ) ;
2018-11-17 06:19:44 +00:00
}
2018-11-18 08:01:20 +00:00
void wfmain : : receiveSql ( unsigned char level )
{
2021-02-11 05:22:38 +00:00
ui - > sqlSlider - > setValue ( level ) ;
2018-11-18 08:01:20 +00:00
}
2018-11-17 06:19:44 +00:00
void wfmain : : on_drawTracerChk_toggled ( bool checked )
{
tracer - > setVisible ( checked ) ;
2018-11-27 07:10:23 +00:00
prefs . drawTracer = checked ;
2018-11-17 06:19:44 +00:00
}
void wfmain : : on_tuneNowBtn_clicked ( )
{
emit startATU ( ) ;
2018-12-20 19:22:52 +00:00
showStatusBarText ( " Starting ATU tuning cycle... " ) ;
2018-12-19 20:31:44 +00:00
cmdOutQue . append ( cmdGetATUStatus ) ;
delayedCommand - > start ( ) ;
2018-11-17 07:13:59 +00:00
}
2018-11-17 06:19:44 +00:00
2018-11-17 07:13:59 +00:00
void wfmain : : on_tuneEnableChk_clicked ( bool checked )
{
emit setATU ( checked ) ;
if ( checked )
{
showStatusBarText ( " Turning on ATU " ) ;
} else {
showStatusBarText ( " Turning off ATU " ) ;
}
2018-11-17 06:19:44 +00:00
}
2018-11-20 07:42:34 +00:00
void wfmain : : on_exitBtn_clicked ( )
{
// Are you sure?
QApplication : : exit ( ) ;
}
2018-11-24 08:10:05 +00:00
void wfmain : : on_pttOnBtn_clicked ( )
{
// is it enabled?
2019-01-24 01:19:35 +00:00
if ( ! ui - > pttEnableChk - > isChecked ( ) )
{
2020-03-12 03:58:31 +00:00
showStatusBarText ( " PTT is disabled, not sending command. Change under Settings tab. " ) ;
2019-01-24 01:19:35 +00:00
return ;
}
2018-11-24 08:10:05 +00:00
2019-01-24 01:19:35 +00:00
// Are we already PTT? Not a big deal, just send again anyway.
2020-03-12 03:58:31 +00:00
showStatusBarText ( " Sending PTT ON command. Use Control-R to receive. " ) ;
2019-01-24 01:19:35 +00:00
emit setPTT ( true ) ;
2018-11-24 08:10:05 +00:00
// send PTT
// Start 3 minute timer
2019-01-24 01:19:35 +00:00
pttTimer - > start ( ) ;
2021-02-15 04:51:18 +00:00
issueDelayedCommand ( cmdGetPTT ) ;
2018-11-24 08:10:05 +00:00
}
void wfmain : : on_pttOffBtn_clicked ( )
{
// Send the PTT OFF command (more than once?)
2019-01-24 01:19:35 +00:00
showStatusBarText ( " Sending PTT OFF command " ) ;
emit setPTT ( false ) ;
2018-11-24 08:10:05 +00:00
2018-11-27 07:10:23 +00:00
// Stop the 3 min timer
2019-01-24 01:19:35 +00:00
pttTimer - > stop ( ) ;
2021-02-15 04:51:18 +00:00
issueDelayedCommand ( cmdGetPTT ) ;
2019-01-24 01:19:35 +00:00
}
void wfmain : : handlePttLimit ( )
{
// transmission time exceeded!
showStatusBarText ( " Transmit timeout at 3 minutes. Sending PTT OFF command now. " ) ;
emit setPTT ( false ) ;
2021-02-17 06:32:05 +00:00
issueDelayedCommand ( cmdGetPTT ) ;
2018-11-24 08:10:05 +00:00
}
2018-11-27 07:10:23 +00:00
void wfmain : : on_saveSettingsBtn_clicked ( )
{
saveSettings ( ) ; // save memory, UI, and radio settings
}
2018-12-19 20:31:44 +00:00
void wfmain : : receiveATUStatus ( unsigned char atustatus )
{
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Received ATU status update: " << (unsigned int) atustatus;
2018-12-19 20:31:44 +00:00
switch ( atustatus )
{
case 0x00 :
// ATU not active
ui - > tuneEnableChk - > blockSignals ( true ) ;
ui - > tuneEnableChk - > setChecked ( false ) ;
ui - > tuneEnableChk - > blockSignals ( false ) ;
showStatusBarText ( " ATU not enabled. " ) ;
break ;
case 0x01 :
// ATU enabled
ui - > tuneEnableChk - > blockSignals ( true ) ;
ui - > tuneEnableChk - > setChecked ( true ) ;
ui - > tuneEnableChk - > blockSignals ( false ) ;
showStatusBarText ( " ATU enabled. " ) ;
break ;
case 0x02 :
// ATU tuning in-progress.
// Add command queue to check again and update status bar
2021-02-23 21:21:22 +00:00
// qDebug(logSystem()) << "Received ATU status update that *tuning* is taking place";
2018-12-20 19:22:52 +00:00
showStatusBarText ( " ATU is Tuning... " ) ;
cmdOutQue . append ( cmdGetATUStatus ) ; // Sometimes the first hit seems to be missed.
2018-12-19 20:31:44 +00:00
cmdOutQue . append ( cmdGetATUStatus ) ;
delayedCommand - > start ( ) ;
break ;
2018-12-20 18:56:54 +00:00
default :
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Did not understand ATU status: " < < ( unsigned int ) atustatus ;
2018-12-20 19:22:52 +00:00
break ;
2018-12-19 20:31:44 +00:00
}
}
2019-02-10 07:13:18 +00:00
void wfmain : : on_pttEnableChk_clicked ( bool checked )
{
prefs . enablePTT = checked ;
}
2021-02-03 19:36:35 +00:00
void wfmain : : on_lanEnableChk_clicked ( bool checked )
{
prefs . enableLAN = checked ;
2021-02-05 04:54:34 +00:00
ui - > ipAddressTxt - > setEnabled ( checked ) ;
ui - > controlPortTxt - > setEnabled ( checked ) ;
ui - > serialPortTxt - > setEnabled ( checked ) ;
ui - > audioPortTxt - > setEnabled ( checked ) ;
ui - > usernameTxt - > setEnabled ( checked ) ;
ui - > passwordTxt - > setEnabled ( checked ) ;
if ( checked )
{
showStatusBarText ( " After filling in values, press Save Settings and re-start wfview. " ) ;
}
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_ipAddressTxt_textChanged ( QString text )
{
prefs . ipAddress = text ;
}
void wfmain : : on_controlPortTxt_textChanged ( QString text )
{
2021-02-05 04:54:34 +00:00
prefs . controlLANPort = text . toUInt ( ) ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_serialPortTxt_textChanged ( QString text )
{
2021-02-05 04:54:34 +00:00
prefs . serialLANPort = text . toUInt ( ) ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_audioPortTxt_textChanged ( QString text )
{
2021-02-05 04:54:34 +00:00
prefs . audioLANPort = text . toUInt ( ) ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_usernameTxt_textChanged ( QString text )
{
prefs . username = text ;
}
void wfmain : : on_passwordTxt_textChanged ( QString text )
{
prefs . password = text ;
}
2021-02-04 10:27:30 +00:00
void wfmain : : on_audioOutputCombo_currentIndexChanged ( QString text )
{
prefs . audioOutput = text ;
}
2021-02-08 16:53:26 +00:00
void wfmain : : on_audioInputCombo_currentIndexChanged ( QString text )
{
prefs . audioInput = text ;
}
void wfmain : : on_audioSampleRateCombo_currentIndexChanged ( QString text )
{
2021-02-09 12:43:28 +00:00
prefs . audioRXSampleRate = text . toInt ( ) ;
prefs . audioTXSampleRate = text . toInt ( ) ;
}
void wfmain : : on_audioRXCodecCombo_currentIndexChanged ( int value )
{
prefs . audioRXCodec = ui - > audioRXCodecCombo - > itemData ( value ) . toInt ( ) ;
2021-02-08 16:53:26 +00:00
}
2021-02-09 12:43:28 +00:00
void wfmain : : on_audioTXCodecCombo_currentIndexChanged ( int value )
2021-02-08 16:53:26 +00:00
{
2021-02-09 12:43:28 +00:00
prefs . audioTXCodec = ui - > audioTXCodecCombo - > itemData ( value ) . toInt ( ) ;
2021-02-08 16:53:26 +00:00
}
2021-02-27 00:37:00 +00:00
void wfmain : : on_rxLatencySlider_valueChanged ( int value )
{
prefs . audioRXLatency = value ;
ui - > rxLatencyValue - > setText ( QString : : number ( value ) ) ;
emit sendChangeLatency ( value ) ;
}
void wfmain : : on_txLatencySlider_valueChanged ( int value )
2021-02-08 16:53:26 +00:00
{
2021-02-27 00:37:00 +00:00
prefs . audioTXLatency = value ;
ui - > txLatencyValue - > setText ( QString : : number ( value ) ) ;
2021-02-08 16:53:26 +00:00
}
2021-02-06 07:58:17 +00:00
void wfmain : : on_toFixedBtn_clicked ( )
{
emit setScopeFixedEdge ( oldLowerFreq , oldUpperFreq , ui - > scopeEdgeCombo - > currentIndex ( ) + 1 ) ;
emit setScopeEdge ( ui - > scopeEdgeCombo - > currentIndex ( ) + 1 ) ;
2021-03-01 05:41:27 +00:00
issueDelayedCommand ( cmdScopeFixedMode ) ;
2021-02-06 07:58:17 +00:00
}
2021-03-01 05:41:27 +00:00
2021-02-07 12:59:41 +00:00
void wfmain : : on_connectBtn_clicked ( )
{
2021-02-07 17:40:38 +00:00
this - > rigStatus - > setText ( " " ) ; // Clear status
2021-02-07 12:59:41 +00:00
if ( haveRigCaps ) {
emit sendCloseComm ( ) ;
ui - > connectBtn - > setText ( " Connect " ) ;
haveRigCaps = false ;
}
else
{
2021-02-07 17:40:38 +00:00
emit sendCloseComm ( ) ; // Just in case there is a failed connection open.
2021-02-07 12:59:41 +00:00
openRig ( ) ;
}
}
2021-02-14 18:32:58 +00:00
void wfmain : : on_udpServerSetupBtn_clicked ( )
{
srv - > show ( ) ;
}
2021-02-11 05:22:38 +00:00
void wfmain : : on_sqlSlider_valueChanged ( int value )
{
emit setSql ( ( unsigned char ) value ) ;
}
2021-02-11 17:21:17 +00:00
void wfmain : : on_modeFilterCombo_activated ( int index )
{
2021-02-13 18:02:45 +00:00
int filterSelection = ui - > modeFilterCombo - > itemData ( index ) . toInt ( ) ;
if ( filterSelection = = 99 )
2021-02-11 17:21:17 +00:00
{
2021-02-13 18:02:45 +00:00
// TODO:
// Bump the filter selected back to F1, F2, or F3
// possibly track the filter in the class. Would make this easier.
// filterSetup.show();
//
} else {
unsigned char newMode = static_cast < unsigned char > ( ui - > modeSelectCombo - > currentData ( ) . toUInt ( ) ) ;
currentModeIndex = newMode ; // we track this for other functions
emit setMode ( newMode , ( unsigned char ) filterSelection ) ;
2021-02-11 17:21:17 +00:00
}
}
2021-02-11 05:22:38 +00:00
2021-02-14 07:42:51 +00:00
void wfmain : : on_dataModeBtn_toggled ( bool checked )
{
setDataMode ( checked ) ;
2021-02-20 08:05:23 +00:00
usingDataMode = checked ;
2021-02-20 08:15:47 +00:00
if ( usingDataMode )
{
changeModLabelAndSlider ( currentModDataSrc ) ;
} else {
changeModLabelAndSlider ( currentModSrc ) ;
}
2021-02-14 07:42:51 +00:00
}
2021-02-15 04:45:48 +00:00
void wfmain : : on_transmitBtn_clicked ( )
{
if ( ! amTransmitting )
{
// Currently receiving
if ( ! ui - > pttEnableChk - > isChecked ( ) )
{
showStatusBarText ( " PTT is disabled, not sending command. Change under Settings tab. " ) ;
return ;
}
// Are we already PTT? Not a big deal, just send again anyway.
showStatusBarText ( " Sending PTT ON command. Use Control-R to receive. " ) ;
emit setPTT ( true ) ;
// send PTT
// Start 3 minute timer
pttTimer - > start ( ) ;
issueDelayedCommand ( cmdGetPTT ) ;
//changeTxBtn();
} else {
// Currently transmitting
emit setPTT ( false ) ;
2021-02-17 06:32:05 +00:00
pttTimer - > stop ( ) ;
2021-02-15 04:45:48 +00:00
issueDelayedCommand ( cmdGetPTT ) ;
}
}
2021-02-15 06:40:04 +00:00
void wfmain : : on_adjRefBtn_clicked ( )
{
cal - > show ( ) ;
}
void wfmain : : on_satOpsBtn_clicked ( )
{
sat - > show ( ) ;
}
2021-02-16 01:15:28 +00:00
void wfmain : : changeSliderQuietly ( QSlider * slider , int value )
{
slider - > blockSignals ( true ) ;
slider - > setValue ( value ) ;
slider - > blockSignals ( false ) ;
}
void wfmain : : receiveTxPower ( unsigned char power )
{
changeSliderQuietly ( ui - > txPowerSlider , power ) ;
}
void wfmain : : receiveMicGain ( unsigned char gain )
{
2021-02-20 08:05:23 +00:00
processModLevel ( inputMic , gain ) ;
}
void wfmain : : processModLevel ( rigInput source , unsigned char level )
{
rigInput currentIn ;
if ( usingDataMode )
{
currentIn = currentModDataSrc ;
} else {
currentIn = currentModSrc ;
}
switch ( source )
{
case inputMic :
micGain = level ;
break ;
case inputACC :
accGain = level ;
break ;
case inputACCA :
accAGain = level ;
break ;
case inputACCB :
accBGain = level ;
break ;
case inputUSB :
usbGain = level ;
break ;
case inputLAN :
lanGain = level ;
break ;
default :
break ;
}
if ( currentIn = = source )
{
changeSliderQuietly ( ui - > micGainSlider , level ) ;
}
2021-02-16 01:15:28 +00:00
}
2021-02-19 08:14:40 +00:00
void wfmain : : receiveModInput ( rigInput input , bool dataOn )
2021-02-18 07:47:34 +00:00
{
2021-02-19 08:14:40 +00:00
QComboBox * box ;
2021-02-20 08:05:23 +00:00
QString inputName ;
2021-02-19 08:14:40 +00:00
bool found ;
2021-02-20 08:05:23 +00:00
bool foundCurrent = false ;
2021-02-19 08:14:40 +00:00
if ( dataOn )
{
box = ui - > modInputDataCombo ;
2021-02-20 08:05:23 +00:00
currentModDataSrc = input ;
if ( usingDataMode )
foundCurrent = true ;
2021-02-19 08:14:40 +00:00
} else {
box = ui - > modInputCombo ;
2021-02-20 08:05:23 +00:00
currentModSrc = input ;
if ( ! usingDataMode )
foundCurrent = true ;
2021-02-19 08:14:40 +00:00
}
for ( int i = 0 ; i < box - > count ( ) ; i + + )
{
if ( box - > itemData ( i ) . toInt ( ) = = ( int ) input )
{
box - > blockSignals ( true ) ;
box - > setCurrentIndex ( i ) ;
box - > blockSignals ( false ) ;
found = true ;
}
}
2021-02-20 08:05:23 +00:00
if ( foundCurrent )
{
changeModLabel ( input ) ;
}
2021-02-19 08:14:40 +00:00
if ( ! found )
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Could not find modulation input: " < < ( int ) input ;
2021-02-18 07:47:34 +00:00
}
void wfmain : : receiveDuplexMode ( duplexMode dm )
{
2021-02-19 05:47:19 +00:00
switch ( dm )
{
case dmSimplex :
ui - > rptSimplexBtn - > setChecked ( true ) ;
break ;
case dmDupPlus :
ui - > rptDupPlusBtn - > setChecked ( true ) ;
break ;
case dmDupMinus :
ui - > rptDupMinusBtn - > setChecked ( true ) ;
break ;
default :
break ;
}
2021-02-18 07:47:34 +00:00
( void ) dm ;
}
void wfmain : : receiveACCGain ( unsigned char level , unsigned char ab )
{
2021-02-20 08:05:23 +00:00
if ( ab = = 1 )
{
processModLevel ( inputACCB , level ) ;
} else {
if ( rigCaps . model = = model7850 )
{
processModLevel ( inputACCA , level ) ;
} else {
processModLevel ( inputACC , level ) ;
}
}
2021-02-18 07:47:34 +00:00
}
void wfmain : : receiveUSBGain ( unsigned char level )
{
2021-02-20 08:05:23 +00:00
processModLevel ( inputUSB , level ) ;
2021-02-18 07:47:34 +00:00
}
void wfmain : : receiveLANGain ( unsigned char level )
{
2021-02-20 08:05:23 +00:00
processModLevel ( inputLAN , level ) ;
2021-02-18 07:47:34 +00:00
}
2021-02-21 04:41:19 +00:00
void wfmain : : receiveMeter ( meterKind inMeter , unsigned char level )
{
2021-02-24 08:18:19 +00:00
2021-02-24 15:56:12 +00:00
unsigned int peak = 0 ;
unsigned int sum = 0 ;
unsigned int average = 0 ;
2021-02-24 08:18:19 +00:00
2021-02-21 04:41:19 +00:00
switch ( inMeter )
{
case meterS :
2021-02-24 08:18:19 +00:00
SMeterReadings [ ( smeterPos + + ) % SMeterReadings . length ( ) ] = level ;
for ( int i = 0 ; i < SMeterReadings . length ( ) ; i + + )
{
2021-02-24 17:38:34 +00:00
if ( ( unsigned char ) SMeterReadings . at ( i ) > peak )
peak = ( unsigned char ) SMeterReadings . at ( i ) ;
sum + = ( unsigned char ) SMeterReadings . at ( i ) ;
2021-02-24 08:18:19 +00:00
}
average = sum / SMeterReadings . length ( ) ;
ui - > meterWidget - > setLevels ( level , peak , average ) ;
2021-02-24 17:38:34 +00:00
ui - > meterWidget - > repaint ( ) ;
2021-02-24 08:18:19 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterSWR :
2021-02-22 06:13:21 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterPower :
2021-02-24 08:18:19 +00:00
powerMeterReadings [ ( powerMeterPos + + ) % powerMeterReadings . length ( ) ] = level ;
for ( int i = 0 ; i < powerMeterReadings . length ( ) ; i + + )
{
2021-02-24 17:38:34 +00:00
if ( ( unsigned char ) powerMeterReadings . at ( i ) > peak )
peak = ( unsigned char ) powerMeterReadings . at ( i ) ;
sum + = ( unsigned char ) powerMeterReadings . at ( i ) ;
2021-02-24 08:18:19 +00:00
}
average = sum / powerMeterReadings . length ( ) ;
ui - > meterWidget - > setLevels ( level , peak , average ) ;
2021-02-24 15:56:12 +00:00
ui - > meterWidget - > update ( ) ;
2021-02-24 08:18:19 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterALC :
2021-02-22 06:13:21 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterComp :
2021-02-22 06:13:21 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterCurrent :
2021-02-22 06:13:21 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
case meterVoltage :
2021-02-22 06:13:21 +00:00
//ui->levelIndicator->setValue((int)level);
2021-02-21 04:41:19 +00:00
break ;
default :
break ;
}
}
2021-02-16 01:15:28 +00:00
void wfmain : : receiveCompLevel ( unsigned char compLevel )
{
( void ) compLevel ;
}
void wfmain : : receiveMonitorGain ( unsigned char monitorGain )
{
( void ) monitorGain ;
}
void wfmain : : receiveVoxGain ( unsigned char voxGain )
{
( void ) voxGain ;
}
void wfmain : : receiveAntiVoxGain ( unsigned char antiVoxGain )
{
( void ) antiVoxGain ;
}
2021-02-16 04:32:14 +00:00
void wfmain : : on_txPowerSlider_valueChanged ( int value )
{
emit setTxPower ( value ) ;
}
void wfmain : : on_micGainSlider_valueChanged ( int value )
{
2021-02-20 08:05:23 +00:00
processChangingCurrentModLevel ( ( unsigned char ) value ) ;
2021-02-16 04:32:14 +00:00
}
void wfmain : : on_scopeRefLevelSlider_valueChanged ( int value )
{
2021-02-16 05:40:31 +00:00
value = ( value / 5 ) * 5 ; // rounded to "nearest 5"
emit setSpectrumRefLevel ( value ) ;
2021-02-16 04:32:14 +00:00
}
2021-02-16 06:33:21 +00:00
void wfmain : : receiveSpectrumRefLevel ( int level )
{
changeSliderQuietly ( ui - > scopeRefLevelSlider , level ) ;
}
2021-02-16 01:15:28 +00:00
2021-02-16 16:16:46 +00:00
// Slot to send/receive server config.
// If store is true then write to config otherwise send current config by signal
void wfmain : : serverConfigRequested ( SERVERCONFIG conf , bool store )
{
if ( ! store ) {
emit sendServerConfig ( serverConfig ) ;
}
else {
// Store config in file!
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Storing server config " ;
2021-02-16 16:16:46 +00:00
serverConfig = conf ;
}
2021-02-16 20:26:26 +00:00
}
2021-02-19 05:47:19 +00:00
void wfmain : : on_rptDupPlusBtn_clicked ( )
{
// DUP+
emit setDuplexMode ( dmDupAutoOff ) ;
emit setDuplexMode ( dmDupPlus ) ;
}
void wfmain : : on_rptSimplexBtn_clicked ( )
{
// Simplex
emit setDuplexMode ( dmDupAutoOff ) ;
emit setDuplexMode ( dmSimplex ) ;
}
void wfmain : : on_rptDupMinusBtn_clicked ( )
{
// DUP-
emit setDuplexMode ( dmDupAutoOff ) ;
emit setDuplexMode ( dmDupMinus ) ;
}
void wfmain : : on_rptAutoBtn_clicked ( )
{
// Auto Rptr (enable this feature)
// TODO: Hide an AutoOff button somewhere for non-US users
emit setDuplexMode ( dmDupAutoOn ) ;
}
2021-02-19 06:38:50 +00:00
2021-02-19 08:14:40 +00:00
void wfmain : : on_modInputCombo_activated ( int index )
{
emit setModInput ( ( rigInput ) ui - > modInputCombo - > currentData ( ) . toInt ( ) , false ) ;
2021-02-20 08:05:23 +00:00
currentModSrc = ( rigInput ) ui - > modInputCombo - > currentData ( ) . toInt ( ) ;
issueDelayedCommand ( cmdGetCurrentModLevel ) ;
if ( ! usingDataMode )
{
changeModLabel ( currentModSrc ) ;
}
( void ) index ;
2021-02-19 08:14:40 +00:00
}
void wfmain : : on_modInputDataCombo_activated ( int index )
{
emit setModInput ( ( rigInput ) ui - > modInputDataCombo - > currentData ( ) . toInt ( ) , true ) ;
2021-02-20 08:05:23 +00:00
currentModDataSrc = ( rigInput ) ui - > modInputDataCombo - > currentData ( ) . toInt ( ) ;
issueDelayedCommand ( cmdGetCurrentModLevel ) ;
if ( usingDataMode )
{
changeModLabel ( currentModDataSrc ) ;
}
( void ) index ;
}
2021-02-20 08:15:47 +00:00
void wfmain : : changeModLabelAndSlider ( rigInput source )
{
changeModLabel ( source , true ) ;
}
2021-02-20 08:05:23 +00:00
void wfmain : : changeModLabel ( rigInput input )
2021-02-20 08:15:47 +00:00
{
changeModLabel ( input , false ) ;
}
void wfmain : : changeModLabel ( rigInput input , bool updateLevel )
2021-02-20 08:05:23 +00:00
{
QString inputName ;
2021-02-20 08:15:47 +00:00
unsigned char gain = 0 ;
2021-02-20 08:05:23 +00:00
switch ( input )
{
case inputMic :
inputName = " Mic " ;
2021-02-20 08:15:47 +00:00
gain = micGain ;
2021-02-20 08:05:23 +00:00
break ;
case inputACC :
inputName = " ACC " ;
2021-02-20 08:15:47 +00:00
gain = accGain ;
2021-02-20 08:05:23 +00:00
break ;
case inputACCA :
inputName = " ACCA " ;
2021-02-20 08:15:47 +00:00
gain = accAGain ;
2021-02-20 08:05:23 +00:00
break ;
case inputACCB :
inputName = " ACCB " ;
2021-02-20 08:15:47 +00:00
gain = accBGain ;
2021-02-20 08:05:23 +00:00
break ;
case inputUSB :
inputName = " USB " ;
2021-02-20 08:15:47 +00:00
gain = usbGain ;
2021-02-20 08:05:23 +00:00
break ;
case inputLAN :
inputName = " LAN " ;
2021-02-20 08:15:47 +00:00
gain = lanGain ;
2021-02-20 08:05:23 +00:00
break ;
default :
inputName = " UNK " ;
2021-02-20 08:15:47 +00:00
gain = 0 ;
break ;
2021-02-20 08:05:23 +00:00
}
ui - > modSliderLbl - > setText ( inputName ) ;
2021-02-20 08:15:47 +00:00
if ( updateLevel )
{
changeSliderQuietly ( ui - > micGainSlider , gain ) ;
}
2021-02-20 08:05:23 +00:00
}
void wfmain : : processChangingCurrentModLevel ( unsigned char level )
{
// slider moved, so find the current mod and issue the level set command.
rigInput currentIn ;
if ( usingDataMode )
{
currentIn = currentModDataSrc ;
} else {
currentIn = currentModSrc ;
}
2021-02-23 21:21:22 +00:00
//qDebug(logSystem()) << __func__ << ": setting current level: " << level;
2021-02-20 08:05:23 +00:00
emit setModLevel ( currentIn , level ) ;
2021-02-19 08:14:40 +00:00
}
2021-02-22 07:58:23 +00:00
void wfmain : : on_tuneLockChk_clicked ( bool checked )
{
freqLock = checked ;
}
2021-02-19 08:14:40 +00:00
// --- DEBUG FUNCTION ---
void wfmain : : on_debugBtn_clicked ( )
{
2021-02-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Debug button pressed. " ;
2021-02-19 08:14:40 +00:00
// TODO: Why don't these commands work?!
//emit getScopeMode();
//emit getScopeEdge(); // 1,2,3 only in "fixed" mode
//emit getScopeSpan(); // in khz, only in "center" mode
// emit getLevels();
// emit getMeters(amTransmitting);
// emit getTSQL();
2021-03-01 05:41:27 +00:00
qDebug ( logSystem ( ) ) < < " Getting scope mode " ;
emit getScopeMode ( ) ;
2021-02-19 08:14:40 +00:00
}
2021-03-01 05:41:27 +00:00