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-05-20 18:24:40 +00:00
wfmain : : wfmain ( const QString serialPortCL , const QString hostCL , const QString settingsFile , 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 ) ;
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-03-31 06:37:35 +00:00
rpt = new repeaterSetup ( ) ;
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-03-01 19:53:12 +00:00
qRegisterMetaType < udpPreferences > ( ) ; // Needs to be registered early.
2021-05-29 04:01:29 +00:00
qRegisterMetaType < rigCapabilities > ( ) ;
qRegisterMetaType < duplexMode > ( ) ;
qRegisterMetaType < rptAccessTxRx > ( ) ;
qRegisterMetaType < rigInput > ( ) ;
qRegisterMetaType < meterKind > ( ) ;
qRegisterMetaType < spectrumMode > ( ) ;
qRegisterMetaType < freqt > ( ) ;
qRegisterMetaType < audioPacket > ( ) ;
2021-06-04 07:24:26 +00:00
qRegisterMetaType < audioSetup > ( ) ;
2021-02-11 05:22:38 +00:00
2021-01-25 00:16:38 +00:00
haveRigCaps = false ;
2021-05-29 03:51:19 +00:00
setupKeyShortcuts ( ) ;
2019-02-01 20:21:54 +00:00
2021-05-29 03:51:19 +00:00
setupMainUI ( ) ;
2019-02-01 20:21:54 +00:00
2021-05-29 04:01:29 +00:00
setSerialDevicesUI ( ) ;
2019-02-01 20:21:54 +00:00
2021-05-29 04:01:29 +00:00
setAudioDevicesUI ( ) ;
2019-02-01 20:21:54 +00:00
2021-06-01 16:48:19 +00:00
setupShuttleDevice ( ) ;
2021-05-29 04:27:06 +00:00
setDefaultColors ( ) ;
setDefPrefs ( ) ;
2019-02-01 20:21:54 +00:00
2021-05-29 04:27:06 +00:00
getSettingsFilePath ( settingsFile ) ;
2019-02-01 20:21:54 +00:00
2021-05-29 03:51:19 +00:00
setupPlots ( ) ;
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-28 06:02:37 +00:00
2021-05-29 03:51:19 +00:00
setUIToPrefs ( ) ;
2019-01-28 23:46:14 +00:00
2021-05-29 04:27:06 +00:00
setServerToPrefs ( ) ;
2019-02-04 05:51:30 +00:00
2021-05-29 04:27:06 +00:00
setInitialTiming ( ) ;
2019-02-04 05:51:30 +00:00
2021-01-30 06:09:09 +00:00
openRig ( ) ;
2019-02-04 18:32:16 +00:00
2021-05-29 03:51:19 +00:00
rigConnections ( ) ;
2019-02-04 18:32:16 +00:00
2021-05-29 03:51:19 +00:00
if ( serverConfig . enabled & & udp ! = Q_NULLPTR ) {
// Server
connect ( rig , SIGNAL ( haveAudioData ( audioPacket ) ) , udp , SLOT ( receiveAudioData ( audioPacket ) ) ) ;
connect ( rig , SIGNAL ( haveDataForServer ( QByteArray ) ) , udp , SLOT ( dataForServer ( QByteArray ) ) ) ;
connect ( udp , SIGNAL ( haveDataFromServer ( QByteArray ) ) , rig , SLOT ( dataFromServer ( QByteArray ) ) ) ;
}
2019-02-06 00:11:25 +00:00
2021-05-29 03:51:19 +00:00
amTransmitting = false ;
}
2019-02-06 00:11:25 +00:00
2021-05-29 03:51:19 +00:00
wfmain : : ~ wfmain ( )
{
rigThread - > quit ( ) ;
rigThread - > wait ( ) ;
if ( serverThread ! = Q_NULLPTR ) {
serverThread - > quit ( ) ;
serverThread - > wait ( ) ;
}
if ( rigCtl ! = Q_NULLPTR ) {
delete rigCtl ;
}
delete rpt ;
delete ui ;
delete settings ;
2021-06-01 16:48:19 +00:00
if ( shuttleThread ! = Q_NULLPTR ) {
shuttleThread - > quit ( ) ;
shuttleThread - > wait ( ) ;
}
2021-05-29 03:51:19 +00:00
}
2020-03-10 18:08:36 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : closeEvent ( QCloseEvent * event )
{
// Are you sure?
QMessageBox : : StandardButton resBtn = QMessageBox : : question ( this , QString ( " Confirm close " ) ,
tr ( " Are you sure you wish to exit? \n " ) ,
QMessageBox : : No | QMessageBox : : Yes ,
QMessageBox : : Yes ) ;
if ( resBtn = = QMessageBox : : Yes ) {
QApplication : : exit ( ) ;
} else {
event - > ignore ( ) ;
}
}
2020-03-17 22:15:01 +00:00
2021-05-29 03:51:19 +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.
2020-03-17 22:15:01 +00:00
2021-05-29 03:51:19 +00:00
//TODO: if(hasRunPreviously)
2019-02-06 00:11:25 +00:00
2021-05-29 03:51:19 +00:00
//TODO: if(useNetwork){...
2019-02-06 00:11:25 +00:00
2021-05-29 03:51:19 +00:00
// } else {
2021-05-20 04:36:34 +00:00
2021-05-29 03:51:19 +00:00
// 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-05-20 04:36:34 +00:00
2021-02-08 16:53:26 +00:00
2021-05-29 03:51:19 +00:00
// TODO: Use these if they are found
if ( ! serialPortCL . isEmpty ( ) )
2021-05-05 13:11:00 +00:00
{
2021-05-29 03:51:19 +00:00
qDebug ( logSystem ( ) ) < < " Serial port specified by user: " < < serialPortCL ;
} else {
qDebug ( logSystem ( ) ) < < " Serial port not specified. " ;
2021-05-05 13:11:00 +00:00
}
2021-05-11 08:38:05 +00:00
2021-05-29 03:51:19 +00:00
if ( ! hostCL . isEmpty ( ) )
2021-05-05 13:11:00 +00:00
{
2021-05-29 03:51:19 +00:00
qDebug ( logSystem ( ) ) < < " Remote host name specified by user: " < < hostCL ;
2021-05-05 13:11:00 +00:00
}
2021-05-11 08:38:05 +00:00
2021-05-29 03:51:19 +00:00
// Start rigctld
2021-05-31 06:26:36 +00:00
if ( prefs . enableRigCtlD & & rigCtl = = Q_NULLPTR ) {
2021-05-29 03:51:19 +00:00
rigCtl = new rigCtlD ( this ) ;
2021-05-05 13:11:00 +00:00
2021-05-29 03:51:19 +00:00
rigCtl - > startServer ( prefs . rigCtlPort ) ;
connect ( this , SIGNAL ( sendRigCaps ( rigCapabilities ) ) , rigCtl , SLOT ( receiveRigCaps ( rigCapabilities ) ) ) ;
}
2021-05-05 13:11:00 +00:00
2021-05-29 03:51:19 +00:00
makeRig ( ) ;
2021-05-05 13:11:00 +00:00
2021-05-29 03:51:19 +00:00
if ( prefs . enableLAN )
2021-05-20 18:24:40 +00:00
{
2021-05-29 03:51:19 +00:00
ui - > lanEnableBtn - > setChecked ( true ) ;
2021-06-04 07:24:26 +00:00
// We need to setup the tx/rx audio:
emit sendCommSetup ( prefs . radioCIVAddr , udpPrefs , rxSetup , txSetup , prefs . virtualSerialPort ) ;
2021-05-29 03:51:19 +00:00
} else {
ui - > serialEnableBtn - > setChecked ( true ) ;
if ( ( prefs . serialPortRadio . toLower ( ) = = QString ( " auto " ) ) & & ( serialPortCL . isEmpty ( ) ) )
2021-05-20 18:24:40 +00:00
{
2021-05-29 03:51:19 +00:00
findSerialPort ( ) ;
2020-03-17 22:15:01 +00:00
2021-05-29 03:51:19 +00:00
} else {
if ( serialPortCL . isEmpty ( ) )
2021-05-20 18:24:40 +00:00
{
2021-05-29 03:51:19 +00:00
serialPortRig = prefs . serialPortRadio ;
} else {
serialPortRig = serialPortCL ;
2021-05-20 18:24:40 +00:00
}
}
2021-05-29 03:51:19 +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.
emit sendCommSetup ( prefs . radioCIVAddr , serialPortRig , prefs . serialPortBaud , prefs . virtualSerialPort ) ;
2021-05-20 18:24:40 +00:00
}
2018-11-29 21:41:42 +00:00
2021-05-29 03:51:19 +00:00
ui - > statusBar - > showMessage ( QString ( " Connecting to rig using serial port " ) . append ( serialPortRig ) , 1000 ) ;
2021-03-01 05:41:27 +00:00
2021-05-20 04:36:34 +00:00
2021-05-29 03:51:19 +00:00
}
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : rigConnections ( )
{
2021-05-30 22:08:22 +00:00
connect ( this , SIGNAL ( setCIVAddr ( unsigned char ) ) , rig , SLOT ( setCIVAddr ( unsigned char ) ) ) ;
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +00:00
connect ( this , SIGNAL ( sendPowerOn ( ) ) , rig , SLOT ( powerOn ( ) ) ) ;
connect ( this , SIGNAL ( sendPowerOff ( ) ) , rig , SLOT ( powerOff ( ) ) ) ;
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +00:00
connect ( rig , SIGNAL ( haveFrequency ( freqt ) ) , this , SLOT ( receiveFreq ( freqt ) ) ) ;
connect ( this , SIGNAL ( getFrequency ( ) ) , rig , SLOT ( getFrequency ( ) ) ) ;
connect ( this , SIGNAL ( getMode ( ) ) , rig , SLOT ( getMode ( ) ) ) ;
connect ( this , SIGNAL ( getDataMode ( ) ) , rig , SLOT ( getDataMode ( ) ) ) ;
connect ( this , SIGNAL ( setDataMode ( bool , unsigned char ) ) , rig , SLOT ( setDataMode ( bool , unsigned char ) ) ) ;
connect ( this , SIGNAL ( getBandStackReg ( char , char ) ) , rig , SLOT ( getBandStackReg ( char , char ) ) ) ;
connect ( rig , SIGNAL ( havePTTStatus ( bool ) ) , this , SLOT ( receivePTTstatus ( bool ) ) ) ;
connect ( this , SIGNAL ( setPTT ( bool ) ) , rig , SLOT ( setPTT ( bool ) ) ) ;
connect ( this , SIGNAL ( getPTT ( ) ) , rig , SLOT ( getPTT ( ) ) ) ;
connect ( rig , SIGNAL ( haveBandStackReg ( freqt , char , char , bool ) ) , this , SLOT ( receiveBandStackReg ( freqt , char , char , bool ) ) ) ;
connect ( this , SIGNAL ( setRitEnable ( bool ) ) , rig , SLOT ( setRitEnable ( bool ) ) ) ;
connect ( this , SIGNAL ( setRitValue ( int ) ) , rig , SLOT ( setRitValue ( int ) ) ) ;
connect ( rig , SIGNAL ( haveRitEnabled ( bool ) ) , this , SLOT ( receiveRITStatus ( bool ) ) ) ;
connect ( rig , SIGNAL ( haveRitFrequency ( int ) ) , this , SLOT ( receiveRITValue ( int ) ) ) ;
connect ( this , SIGNAL ( getRitEnabled ( ) ) , rig , SLOT ( getRitEnabled ( ) ) ) ;
connect ( this , SIGNAL ( getRitValue ( ) ) , rig , SLOT ( getRitValue ( ) ) ) ;
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +00:00
connect ( this , SIGNAL ( getDebug ( ) ) , rig , SLOT ( getDebug ( ) ) ) ;
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +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 ( ) ) ) ;
connect ( rig , SIGNAL ( haveMode ( unsigned char , unsigned char ) ) , this , SLOT ( receiveMode ( unsigned char , unsigned char ) ) ) ;
connect ( rig , SIGNAL ( haveDataMode ( bool ) ) , this , SLOT ( receiveDataModeStatus ( bool ) ) ) ;
2021-05-16 12:34:04 +00:00
2021-05-29 03:51:19 +00:00
connect ( rpt , SIGNAL ( getDuplexMode ( ) ) , rig , SLOT ( getDuplexMode ( ) ) ) ;
connect ( rpt , SIGNAL ( setDuplexMode ( duplexMode ) ) , rig , SLOT ( setDuplexMode ( duplexMode ) ) ) ;
2021-03-31 07:14:20 +00:00
connect ( rig , SIGNAL ( haveDuplexMode ( duplexMode ) ) , rpt , SLOT ( receiveDuplexMode ( duplexMode ) ) ) ;
2021-04-04 07:36:21 +00:00
connect ( rpt , SIGNAL ( getTone ( ) ) , rig , SLOT ( getTone ( ) ) ) ;
connect ( rpt , SIGNAL ( getTSQL ( ) ) , rig , SLOT ( getTSQL ( ) ) ) ;
connect ( rpt , SIGNAL ( getDTCS ( ) ) , rig , SLOT ( getDTCS ( ) ) ) ;
2021-04-05 06:33:56 +00:00
connect ( rpt , SIGNAL ( setTone ( quint16 ) ) , rig , SLOT ( setTone ( quint16 ) ) ) ;
connect ( rpt , SIGNAL ( setTSQL ( quint16 ) ) , rig , SLOT ( setTSQL ( quint16 ) ) ) ;
connect ( rpt , SIGNAL ( setDTCS ( quint16 , bool , bool ) ) , rig , SLOT ( setDTCS ( quint16 , bool , bool ) ) ) ;
2021-04-04 07:36:21 +00:00
connect ( rpt , SIGNAL ( getRptAccessMode ( ) ) , rig , SLOT ( getRptAccessMode ( ) ) ) ;
connect ( rpt , SIGNAL ( setRptAccessMode ( rptAccessTxRx ) ) , rig , SLOT ( setRptAccessMode ( rptAccessTxRx ) ) ) ;
connect ( rig , SIGNAL ( haveTone ( quint16 ) ) , rpt , SLOT ( handleTone ( quint16 ) ) ) ;
connect ( rig , SIGNAL ( haveTSQL ( quint16 ) ) , rpt , SLOT ( handleTSQL ( quint16 ) ) ) ;
2021-04-08 06:43:18 +00:00
connect ( rig , SIGNAL ( haveDTCS ( quint16 , bool , bool ) ) , rpt , SLOT ( handleDTCS ( quint16 , bool , bool ) ) ) ;
2021-04-04 07:36:21 +00:00
connect ( rig , SIGNAL ( haveRptAccessMode ( rptAccessTxRx ) ) , rpt , SLOT ( handleRptAccessMode ( rptAccessTxRx ) ) ) ;
2021-03-31 07:14:20 +00:00
2021-03-31 07:29:22 +00:00
connect ( this , SIGNAL ( getDuplexMode ( ) ) , rig , SLOT ( getDuplexMode ( ) ) ) ;
2021-04-07 05:06:08 +00:00
connect ( this , SIGNAL ( getTone ( ) ) , rig , SLOT ( getTone ( ) ) ) ;
connect ( this , SIGNAL ( getTSQL ( ) ) , rig , SLOT ( getTSQL ( ) ) ) ;
connect ( this , SIGNAL ( getRptAccessMode ( ) ) , rig , SLOT ( getRptAccessMode ( ) ) ) ;
2021-03-31 07:14:20 +00:00
//connect(this, SIGNAL(setDuplexMode(duplexMode)), rig, SLOT(setDuplexMode(duplexMode)));
//connect(rig, SIGNAL(haveDuplexMode(duplexMode)), this, SLOT(receiveDuplexMode(duplexMode)));
2021-02-19 05:47:19 +00:00
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 ( ) ) ) ;
2021-03-22 07:11:43 +00:00
connect ( this , SIGNAL ( setFrequency ( freqt ) ) , rig , SLOT ( setFrequency ( freqt ) ) ) ;
2018-06-19 19:58:52 +00:00
connect ( this , SIGNAL ( setScopeEdge ( char ) ) , rig , SLOT ( setScopeEdge ( char ) ) ) ;
connect ( this , SIGNAL ( setScopeSpan ( char ) ) , rig , SLOT ( setScopeSpan ( char ) ) ) ;
2021-04-11 07:42:25 +00:00
//connect(this, SIGNAL(getScopeMode()), rig, SLOT(getScopeMode()));
2018-12-18 22:34:04 +00:00
connect ( this , SIGNAL ( getScopeEdge ( ) ) , rig , SLOT ( getScopeEdge ( ) ) ) ;
connect ( this , SIGNAL ( getScopeSpan ( ) ) , rig , SLOT ( getScopeSpan ( ) ) ) ;
2021-04-11 07:42:25 +00:00
connect ( rig , SIGNAL ( haveScopeSpan ( freqt , bool ) ) , this , SLOT ( receiveSpectrumSpan ( freqt , bool ) ) ) ;
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 ) ) ) ;
2021-04-08 06:35:24 +00:00
connect ( this , SIGNAL ( setAttenuator ( unsigned char ) ) , rig , SLOT ( setAttenuator ( unsigned char ) ) ) ;
2021-04-09 17:04:20 +00:00
connect ( this , SIGNAL ( setPreamp ( unsigned char ) ) , rig , SLOT ( setPreamp ( unsigned char ) ) ) ;
2021-04-09 22:57:16 +00:00
connect ( this , SIGNAL ( setAntenna ( unsigned char ) ) , rig , SLOT ( setAntenna ( unsigned char ) ) ) ;
2021-04-10 07:21:58 +00:00
connect ( this , SIGNAL ( getPreamp ( ) ) , rig , SLOT ( getPreamp ( ) ) ) ;
2021-04-11 05:48:32 +00:00
connect ( rig , SIGNAL ( havePreamp ( unsigned char ) ) , this , SLOT ( receivePreamp ( unsigned char ) ) ) ;
2021-04-10 07:21:58 +00:00
connect ( this , SIGNAL ( getAttenuator ( ) ) , rig , SLOT ( getAttenuator ( ) ) ) ;
2021-04-11 05:48:32 +00:00
connect ( rig , SIGNAL ( haveAttenuator ( unsigned char ) ) , this , SLOT ( receiveAttenuator ( unsigned char ) ) ) ;
2021-04-20 05:18:45 +00:00
connect ( this , SIGNAL ( getAntenna ( ) ) , rig , SLOT ( getAntenna ( ) ) ) ;
2021-04-11 05:48:32 +00:00
//connect(rig, SIGNAL(haveAntenna(unsigned char)), this, SLOT(receiveAntennaSel(unsigned char)));
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 ) ) ) ;
2021-05-29 03:51:19 +00:00
}
2021-02-11 08:33:25 +00:00
2021-05-29 03:51:19 +00:00
//void wfmain::removeRigConnections()
//{
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
//}
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : makeRig ( )
{
if ( rigThread = = Q_NULLPTR )
{
rig = new rigCommander ( ) ;
rigThread = new QThread ( this ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
// Thread:
rig - > moveToThread ( rigThread ) ;
connect ( rigThread , SIGNAL ( started ( ) ) , rig , SLOT ( process ( ) ) ) ;
connect ( rigThread , SIGNAL ( finished ( ) ) , rig , SLOT ( deleteLater ( ) ) ) ;
rigThread - > start ( ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
// Rig status and Errors:
connect ( rig , SIGNAL ( haveSerialPortError ( QString , QString ) ) , this , SLOT ( receiveSerialPortError ( QString , QString ) ) ) ;
connect ( rig , SIGNAL ( haveStatusUpdate ( QString ) ) , this , SLOT ( receiveStatusUpdate ( QString ) ) ) ;
2020-03-27 23:34:32 +00:00
2021-05-29 03:51:19 +00:00
// Rig comm setup:
2021-06-04 07:24:26 +00:00
connect ( this , SIGNAL ( sendCommSetup ( unsigned char , udpPreferences , audioSetup , audioSetup , QString ) ) , rig , SLOT ( commSetup ( unsigned char , udpPreferences , audioSetup , audioSetup , QString ) ) ) ;
2021-05-29 03:51:19 +00:00
connect ( this , SIGNAL ( sendCommSetup ( unsigned char , QString , quint32 , QString ) ) , rig , SLOT ( commSetup ( unsigned char , QString , quint32 , QString ) ) ) ;
2020-03-27 23:34:32 +00:00
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
connect ( rig , SIGNAL ( haveBaudRate ( quint32 ) ) , this , SLOT ( receiveBaudRate ( quint32 ) ) ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
connect ( this , SIGNAL ( sendCloseComm ( ) ) , rig , SLOT ( closeComm ( ) ) ) ;
connect ( this , SIGNAL ( sendChangeLatency ( quint16 ) ) , rig , SLOT ( changeLatency ( quint16 ) ) ) ;
connect ( this , SIGNAL ( getRigCIV ( ) ) , rig , SLOT ( findRigs ( ) ) ) ;
connect ( rig , SIGNAL ( discoveredRigID ( rigCapabilities ) ) , this , SLOT ( receiveFoundRigID ( rigCapabilities ) ) ) ;
connect ( rig , SIGNAL ( commReady ( ) ) , this , SLOT ( receiveCommReady ( ) ) ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
if ( rigCtl ! = Q_NULLPTR ) {
connect ( rig , SIGNAL ( stateInfo ( rigStateStruct * ) ) , rigCtl , SLOT ( receiveStateInfo ( rigStateStruct * ) ) ) ;
connect ( rigCtl , SIGNAL ( setFrequency ( freqt ) ) , rig , SLOT ( setFrequency ( freqt ) ) ) ;
connect ( rigCtl , SIGNAL ( setMode ( unsigned char , unsigned char ) ) , rig , SLOT ( setMode ( unsigned char , unsigned char ) ) ) ;
connect ( rigCtl , SIGNAL ( setPTT ( bool ) ) , rig , SLOT ( setPTT ( bool ) ) ) ;
2021-03-22 09:10:03 +00:00
}
2021-05-16 12:34:04 +00:00
}
2021-05-29 03:51:19 +00:00
}
2021-02-16 16:16:46 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : removeRig ( )
{
if ( rigThread ! = Q_NULLPTR )
2021-05-05 13:11:00 +00:00
{
2021-05-29 03:51:19 +00:00
if ( rigCtl ! = Q_NULLPTR ) {
rigCtl - > disconnect ( ) ;
}
rigThread - > disconnect ( ) ;
2021-02-24 08:18:19 +00:00
2021-05-29 03:51:19 +00:00
rig - > disconnect ( ) ;
2021-02-24 08:18:19 +00:00
2021-05-29 03:51:19 +00:00
delete rigThread ;
delete rig ;
2018-06-19 19:58:52 +00:00
2021-05-05 13:11:00 +00:00
}
2021-05-29 03:51:19 +00:00
}
2021-05-11 08:38:05 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : findSerialPort ( )
{
// Find the ICOM radio connected, or, if none, fall back to OS default.
// qInfo(logSystem()) << "Searching for serial port...";
QDirIterator it73 ( " /dev/serial/by-id " , 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 ) ;
QDirIterator it7610 ( " /dev/serial " , QStringList ( ) < < " *IC-7610*A " , QDir : : Files , QDirIterator : : Subdirectories ) ;
QDirIterator itR8600 ( " /dev/serial " , QStringList ( ) < < " *IC-R8600*A " , QDir : : Files , QDirIterator : : Subdirectories ) ;
QDirIterator itTest ( " /tmp/test " , QStringList ( ) < < " *radio* " , QDir : : NoFilter , QDirIterator : : Subdirectories ) ;
qDebug ( ) < < " test iterator isEmpty: " < < itTest . filePath ( ) . isEmpty ( ) ;
if ( ! it73 . filePath ( ) . isEmpty ( ) )
2021-05-05 13:11:00 +00:00
{
2021-05-29 03:51:19 +00:00
// IC-7300
serialPortRig = it73 . filePath ( ) ; // first
} else if ( ! it97 . filePath ( ) . isEmpty ( ) )
{
// IC-9700
serialPortRig = it97 . filePath ( ) ;
} else if ( ! it785x . filePath ( ) . isEmpty ( ) )
{
// IC-785x
serialPortRig = it785x . filePath ( ) ;
} else if ( ! it705 . filePath ( ) . isEmpty ( ) )
{
// IC-705
serialPortRig = it705 . filePath ( ) ;
} else if ( ! it7610 . filePath ( ) . isEmpty ( ) )
{
// IC-7610
serialPortRig = it7610 . filePath ( ) ;
} else if ( ! itR8600 . filePath ( ) . isEmpty ( ) )
{
// IC-R8600
serialPortRig = itR8600 . filePath ( ) ;
} else {
//fall back:
qInfo ( logSystem ( ) ) < < " Could not find Icom serial port. Falling back to OS default. Use --port to specify, or modify preferences. " ;
2021-05-17 16:05:19 +00:00
# ifdef Q_OS_MAC
2021-05-29 03:51:19 +00:00
serialPortRig = QString ( " /dev/tty.SLAB_USBtoUART " ) ;
2021-05-17 16:05:19 +00:00
# endif
2021-05-29 03:51:19 +00:00
# ifdef Q_OS_LINUX
serialPortRig = QString ( " /dev/ttyUSB0 " ) ;
# endif
# ifdef Q_OS_WIN
serialPortRig = QString ( " COM1 " ) ;
# endif
}
}
2021-05-11 08:38:05 +00:00
2021-02-07 09:03:02 +00:00
void wfmain : : receiveCommReady ( )
{
2021-05-15 17:53:16 +00:00
qInfo ( 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-05-15 17:53:16 +00:00
// qInfo(logSystem()) << "Beginning search from wfview for rigCIV (auto-detection broadcast)";
2021-05-18 07:29:06 +00:00
ui - > statusBar - > showMessage ( QString ( " Searching CI-V bus for connected radios. " ) , 1000 ) ;
2021-02-07 09:03:02 +00:00
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-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < " Skipping automatic CIV, using user-supplied value of " < < prefs . radioCIVAddr ;
2021-05-18 07:29:06 +00:00
showStatusBarText ( QString ( " Using user-supplied radio CI-V address of 0x%1 " ) . arg ( prefs . radioCIVAddr , 2 , 16 ) ) ;
2021-05-15 23:57:08 +00:00
emit getRigID ( ) ;
2021-02-07 09:03:02 +00:00
getInitialRigState ( ) ;
2021-05-11 08:38:05 +00:00
}
2021-02-07 09:03:02 +00:00
}
2021-05-05 13:11:00 +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-05-15 17:53:16 +00:00
//qInfo(logSystem()) << "In wfview, we now have a reply to our request for rig identity sent to CIV BROADCAST.";
2021-05-05 13:11:00 +00:00
2021-05-21 20:01:21 +00:00
// baud on the serial port reflects the actual rig connection,
// even if a client-server connection is being used.
// Computed time for a 10 byte message, with a safety factor of 2.
unsigned int usPerByte = 9600 * 1000 / prefs . serialPortBaud ;
unsigned int msMinTiming = usPerByte * 10 * 2 / 1000 ;
if ( msMinTiming < 35 )
msMinTiming = 35 ;
2021-05-20 18:24:40 +00:00
2021-05-21 20:01:21 +00:00
delayedCommand - > setInterval ( msMinTiming * 2 ) ; // 20 byte message
periodicPollingTimer - > setInterval ( msMinTiming ) ; // slower for s-meter poll
2021-05-22 06:46:15 +00:00
qInfo ( logSystem ( ) ) < < " Delay command interval timing: " < < msMinTiming * 2 < < " ms " ;
qInfo ( logSystem ( ) ) < < " Periodic polling timer: " < < msMinTiming < < " ms " ;
2021-05-21 20:01:21 +00:00
// Normal:
delayedCmdIntervalLAN_ms = msMinTiming * 2 ;
delayedCmdIntervalSerial_ms = msMinTiming * 2 ;
// startup initial state:
delayedCmdStartupInterval_ms = msMinTiming * 2 ;
2021-05-01 05:15:30 +00:00
if ( rig - > usingLAN ( ) )
{
usingLAN = true ;
2021-05-21 20:01:21 +00:00
//delayedCommand->setInterval(delayedCmdIntervalLAN_ms);
2021-05-01 05:15:30 +00:00
} else {
usingLAN = false ;
2021-05-20 18:24:40 +00:00
}
2018-11-29 21:41:42 +00:00
2021-01-30 06:09:09 +00:00
receiveRigID ( rigCaps ) ;
getInitialRigState ( ) ;
2021-03-01 05:41:27 +00:00
2021-01-30 06:09:09 +00:00
return ;
}
2021-02-16 16:16:46 +00:00
2021-02-02 09:05:59 +00:00
void wfmain : : receiveSerialPortError ( QString port , QString errorText )
{
2021-05-15 17:53:16 +00:00
qInfo ( 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 ) ;
2021-02-16 16:16:46 +00:00
2021-02-02 09:05:59 +00:00
// TODO: Dialog box, exit, etc
}
2021-02-16 16:16:46 +00:00
2021-02-05 20:26:18 +00:00
void wfmain : : receiveStatusUpdate ( QString text )
{
this - > rigStatus - > setText ( text ) ;
}
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : setupPlots ( )
{
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
// Line 290--
2021-05-31 06:26:36 +00:00
spectrumDrawLock = true ;
2021-05-29 03:51:19 +00:00
plot = ui - > plot ; // rename it waterfall.
wf = ui - > waterfall ;
freqIndicatorLine = new QCPItemLine ( plot ) ;
freqIndicatorLine - > setAntialiased ( true ) ;
freqIndicatorLine - > setPen ( QPen ( Qt : : blue ) ) ;
//
ui - > plot - > addGraph ( ) ; // primary
ui - > plot - > addGraph ( 0 , 0 ) ; // secondary, peaks, same axis as first?
ui - > waterfall - > addGraph ( ) ;
2021-02-16 16:16:46 +00:00
2021-05-29 03:51:19 +00:00
colorMap = new QCPColorMap ( wf - > xAxis , wf - > yAxis ) ;
colorMapData = NULL ;
2021-02-16 16:16:46 +00:00
2021-05-29 03:51:19 +00:00
# if QCUSTOMPLOT_VERSION < 0x020001
wf - > addPlottable ( colorMap ) ;
# endif
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
colorScale = new QCPColorScale ( wf ) ;
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2021-02-16 16:16:46 +00:00
2021-05-29 03:51:19 +00:00
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 ) ) ;
2021-02-28 20:10:07 +00:00
2021-05-29 03:51:19 +00:00
freqIndicatorLine - > start - > setCoords ( 0.5 , 0 ) ;
freqIndicatorLine - > end - > setCoords ( 0.5 , 160 ) ;
2021-02-28 20:10:07 +00:00
2021-05-29 04:27:06 +00:00
// Plot user interaction
connect ( plot , SIGNAL ( mouseDoubleClick ( QMouseEvent * ) ) , this , SLOT ( handlePlotDoubleClick ( QMouseEvent * ) ) ) ;
connect ( wf , SIGNAL ( mouseDoubleClick ( QMouseEvent * ) ) , this , SLOT ( handleWFDoubleClick ( QMouseEvent * ) ) ) ;
connect ( plot , SIGNAL ( mousePress ( QMouseEvent * ) ) , this , SLOT ( handlePlotClick ( QMouseEvent * ) ) ) ;
connect ( wf , SIGNAL ( mousePress ( QMouseEvent * ) ) , this , SLOT ( handleWFClick ( QMouseEvent * ) ) ) ;
connect ( wf , SIGNAL ( mouseWheel ( QWheelEvent * ) ) , this , SLOT ( handleWFScroll ( QWheelEvent * ) ) ) ;
connect ( plot , SIGNAL ( mouseWheel ( QWheelEvent * ) ) , this , SLOT ( handlePlotScroll ( QWheelEvent * ) ) ) ;
2021-05-31 06:26:36 +00:00
spectrumDrawLock = false ;
2021-05-29 03:51:19 +00:00
}
2018-11-29 21:41:42 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : setupMainUI ( )
{
ui - > bandStkLastUsedBtn - > setVisible ( false ) ;
ui - > bandStkVoiceBtn - > setVisible ( false ) ;
ui - > bandStkDataBtn - > setVisible ( false ) ;
ui - > bandStkCWBtn - > setVisible ( false ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
ui - > baudRateCombo - > insertItem ( 0 , QString ( " 115200 " ) , 115200 ) ;
ui - > baudRateCombo - > insertItem ( 1 , QString ( " 57600 " ) , 57600 ) ;
ui - > baudRateCombo - > insertItem ( 2 , QString ( " 38400 " ) , 38400 ) ;
ui - > baudRateCombo - > insertItem ( 3 , QString ( " 28800 " ) , 28800 ) ;
ui - > baudRateCombo - > insertItem ( 4 , QString ( " 19200 " ) , 19200 ) ;
ui - > baudRateCombo - > insertItem ( 5 , QString ( " 9600 " ) , 9600 ) ;
ui - > baudRateCombo - > insertItem ( 6 , QString ( " 4800 " ) , 4800 ) ;
ui - > baudRateCombo - > insertItem ( 7 , QString ( " 2400 " ) , 2400 ) ;
ui - > baudRateCombo - > insertItem ( 8 , QString ( " 1200 " ) , 1200 ) ;
ui - > baudRateCombo - > insertItem ( 9 , QString ( " 300 " ) , 300 ) ;
2021-04-10 22:34:35 +00:00
2021-05-29 03:51:19 +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 ) ;
2021-04-10 22:34:35 +00:00
2021-02-13 06:42:34 +00:00
ui - > modeSelectCombo - > addItem ( " LSB " , 0x00 ) ;
ui - > modeSelectCombo - > addItem ( " USB " , 0x01 ) ;
2021-04-27 08:08:28 +00:00
ui - > modeSelectCombo - > addItem ( " FM " , 0x05 ) ;
2021-02-13 06:42:34 +00:00
ui - > modeSelectCombo - > addItem ( " AM " , 0x02 ) ;
ui - > modeSelectCombo - > addItem ( " CW " , 0x03 ) ;
ui - > modeSelectCombo - > addItem ( " CW-R " , 0x07 ) ;
2021-04-27 08:08:28 +00:00
ui - > modeSelectCombo - > addItem ( " RTTY " , 0x04 ) ;
2021-02-13 06:42:34 +00:00
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-03-04 08:02:53 +00:00
ui - > tuningStepCombo - > blockSignals ( true ) ;
2021-03-22 07:11:43 +00:00
2021-04-12 16:54:09 +00:00
ui - > tuningStepCombo - > addItem ( " 1 Hz " , ( unsigned int ) 1 ) ;
ui - > tuningStepCombo - > addItem ( " 10 Hz " , ( unsigned int ) 10 ) ;
ui - > tuningStepCombo - > addItem ( " 100 Hz " , ( unsigned int ) 100 ) ;
ui - > tuningStepCombo - > addItem ( " 1 kHz " , ( unsigned int ) 1000 ) ;
ui - > tuningStepCombo - > addItem ( " 2.5 kHz " , ( unsigned int ) 2500 ) ;
ui - > tuningStepCombo - > addItem ( " 5 kHz " , ( unsigned int ) 5000 ) ;
2021-05-29 03:51:19 +00:00
ui - > tuningStepCombo - > addItem ( " 6.125 kHz " , ( unsigned int ) 6125 ) ; // PMR
2021-04-12 16:54:09 +00:00
ui - > tuningStepCombo - > addItem ( " 8.333 kHz " , ( unsigned int ) 8333 ) ; // airband stepsize
ui - > tuningStepCombo - > addItem ( " 9 kHz " , ( unsigned int ) 9000 ) ; // European medium wave stepsize
ui - > tuningStepCombo - > addItem ( " 10 kHz " , ( unsigned int ) 10000 ) ;
ui - > tuningStepCombo - > addItem ( " 12.5 kHz " , ( unsigned int ) 12500 ) ;
ui - > tuningStepCombo - > addItem ( " 100 kHz " , ( unsigned int ) 100000 ) ;
ui - > tuningStepCombo - > addItem ( " 250 kHz " , ( unsigned int ) 250000 ) ;
2021-05-29 03:51:19 +00:00
ui - > tuningStepCombo - > addItem ( " 1 MHz " , ( unsigned int ) 1000000 ) ; //for 23 cm and HF
2021-03-22 07:11:43 +00:00
2021-03-04 08:02:53 +00:00
ui - > tuningStepCombo - > setCurrentIndex ( 2 ) ;
ui - > tuningStepCombo - > blockSignals ( false ) ;
2021-02-11 17:21:17 +00:00
2021-04-10 06:38:36 +00:00
ui - > wfthemeCombo - > addItem ( " Jet " , QCPColorGradient : : gpJet ) ;
ui - > wfthemeCombo - > addItem ( " Cold " , QCPColorGradient : : gpCold ) ;
ui - > wfthemeCombo - > addItem ( " Hot " , QCPColorGradient : : gpHot ) ;
ui - > wfthemeCombo - > addItem ( " Thermal " , QCPColorGradient : : gpThermal ) ;
ui - > wfthemeCombo - > addItem ( " Night " , QCPColorGradient : : gpNight ) ;
ui - > wfthemeCombo - > addItem ( " Ion " , QCPColorGradient : : gpIon ) ;
ui - > wfthemeCombo - > addItem ( " Gray " , QCPColorGradient : : gpGrayscale ) ;
ui - > wfthemeCombo - > addItem ( " Geography " , QCPColorGradient : : gpGeography ) ;
ui - > wfthemeCombo - > addItem ( " Hues " , QCPColorGradient : : gpHues ) ;
ui - > wfthemeCombo - > addItem ( " Polar " , QCPColorGradient : : gpPolar ) ;
ui - > wfthemeCombo - > addItem ( " Spectrum " , QCPColorGradient : : gpSpectrum ) ;
ui - > wfthemeCombo - > addItem ( " Candy " , QCPColorGradient : : gpCandy ) ;
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-03-07 08:05:13 +00:00
edges < < " 1 " < < " 2 " < < " 3 " < < " 4 " ;
2021-02-22 00:24:48 +00:00
ui - > scopeEdgeCombo - > insertItems ( 0 , edges ) ;
2021-02-11 08:33:25 +00:00
2018-06-20 06:45:56 +00:00
ui - > splitter - > setHandleWidth ( 5 ) ;
2021-02-11 08:33:25 +00:00
2021-03-07 08:05:13 +00:00
// Set scroll wheel response (tick interval)
// and set arrow key response (single step)
2020-04-23 22:22:23 +00:00
ui - > rfGainSlider - > setTickInterval ( 100 ) ;
2021-03-07 08:05:13 +00:00
ui - > rfGainSlider - > setSingleStep ( 10 ) ;
2020-04-21 04:10:20 +00:00
2021-03-07 08:05:13 +00:00
ui - > afGainSlider - > setTickInterval ( 100 ) ;
ui - > afGainSlider - > setSingleStep ( 10 ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
ui - > sqlSlider - > setTickInterval ( 100 ) ;
ui - > sqlSlider - > setSingleStep ( 10 ) ;
2021-02-18 09:14:41 +00:00
2021-05-29 03:51:19 +00:00
ui - > txPowerSlider - > setTickInterval ( 100 ) ;
ui - > txPowerSlider - > setSingleStep ( 10 ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
ui - > micGainSlider - > setTickInterval ( 100 ) ;
ui - > micGainSlider - > setSingleStep ( 10 ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
ui - > scopeRefLevelSlider - > setTickInterval ( 50 ) ;
ui - > scopeRefLevelSlider - > setSingleStep ( 20 ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 03:51:19 +00:00
ui - > freqMhzLineEdit - > setValidator ( new QDoubleValidator ( 0 , 100 , 6 , this ) ) ;
ui - > controlPortTxt - > setValidator ( new QIntValidator ( this ) ) ;
2020-03-27 23:34:32 +00:00
2021-05-29 03:51:19 +00:00
qDebug ( logSystem ( ) ) < < " Running with debugging options enabled. " ;
# ifdef QT_DEBUG
ui - > debugBtn - > setVisible ( true ) ;
ui - > satOpsBtn - > setVisible ( true ) ;
# else
ui - > debugBtn - > setVisible ( false ) ;
ui - > satOpsBtn - > setVisible ( false ) ;
2020-03-27 23:34:32 +00:00
# endif
2021-05-29 04:01:29 +00:00
rigStatus = new QLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( rigStatus ) ;
ui - > statusBar - > showMessage ( " Connecting to rig... " , 1000 ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 04:01:29 +00:00
pttLed = new QLedLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( pttLed ) ;
pttLed - > setState ( QLedLabel : : State : : StateOk ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 04:01:29 +00:00
connectedLed = new QLedLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( connectedLed ) ;
2018-06-19 19:58:52 +00:00
2021-05-29 04:01:29 +00:00
rigName = new QLabel ( this ) ;
ui - > statusBar - > addPermanentWidget ( rigName ) ;
rigName - > setText ( " NONE " ) ;
rigName - > setFixedWidth ( 50 ) ;
2018-06-19 19:58:52 +00:00
2021-02-27 01:11:41 +00:00
SMeterReadings . fill ( 0 , 30 ) ;
powerMeterReadings . fill ( 0 , 30 ) ;
2021-02-24 08:18:19 +00:00
2021-05-29 04:27:06 +00:00
freq . MHzDouble = 0.0 ;
freq . Hz = 0 ;
oldFreqDialVal = ui - > freqDial - > value ( ) ;
2021-02-24 08:18:19 +00:00
2021-05-29 04:27:06 +00:00
ui - > tuneLockChk - > setChecked ( false ) ;
freqLock = false ;
}
void wfmain : : getSettingsFilePath ( QString settingsFile )
{
if ( settingsFile . isNull ( ) ) {
settings = new QSettings ( ) ;
}
else
{
QString file = settingsFile ;
QFile info ( settingsFile ) ;
QString path = " " ;
if ( ! QFileInfo ( info ) . isAbsolute ( ) )
{
path = QStandardPaths : : writableLocation ( QStandardPaths : : AppDataLocation ) ;
if ( path . isEmpty ( ) )
{
path = QDir : : homePath ( ) ;
}
path = path + " / " ;
file = info . fileName ( ) ;
}
qInfo ( logSystem ( ) ) < < " Loading settings from: " < < path + file ;
settings = new QSettings ( path + file , QSettings : : Format : : IniFormat ) ;
}
}
void wfmain : : setInitialTiming ( )
{
delayedCmdIntervalLAN_ms = 10 ; // interval for regular delayed commands, including initial rig/UI state queries
delayedCmdIntervalSerial_ms = 100 ; // interval for regular delayed commands, including initial rig/UI state queries
delayedCmdStartupInterval_ms = 250 ; // interval for rigID polling
delayedCommand = new QTimer ( this ) ;
delayedCommand - > setInterval ( delayedCmdStartupInterval_ms ) ; // 250ms until we find rig civ and id, then 100ms.
delayedCommand - > setSingleShot ( true ) ;
connect ( delayedCommand , SIGNAL ( timeout ( ) ) , this , SLOT ( runDelayedCommand ( ) ) ) ;
periodicPollingTimer = new QTimer ( this ) ;
periodicPollingTimer - > setInterval ( 10 ) ;
periodicPollingTimer - > setSingleShot ( false ) ;
connect ( periodicPollingTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( runPeriodicCommands ( ) ) ) ;
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-05-29 04:27:06 +00:00
}
void wfmain : : setServerToPrefs ( )
{
2021-05-31 08:56:05 +00:00
2021-05-29 04:27:06 +00:00
// Start server if enabled in config
if ( serverConfig . enabled ) {
serverConfig . lan = prefs . enableLAN ;
2021-02-27 01:32:06 +00:00
2021-06-04 13:25:07 +00:00
udp = new udpServer ( serverConfig , rxSetup , txSetup ) ;
2019-01-24 01:19:35 +00:00
2021-05-29 04:27:06 +00:00
serverThread = new QThread ( this ) ;
2019-01-28 23:36:17 +00:00
2021-05-29 04:27:06 +00:00
udp - > moveToThread ( serverThread ) ;
connect ( this , SIGNAL ( initServer ( ) ) , udp , SLOT ( init ( ) ) ) ;
connect ( serverThread , SIGNAL ( finished ( ) ) , udp , SLOT ( deleteLater ( ) ) ) ;
serverThread - > start ( ) ;
emit initServer ( ) ;
connect ( this , SIGNAL ( sendRigCaps ( rigCapabilities ) ) , udp , SLOT ( receiveRigCaps ( rigCapabilities ) ) ) ;
}
2021-05-29 03:51:19 +00:00
}
2019-01-28 23:36:17 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : setUIToPrefs ( )
{
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-06-19 19:58:52 +00:00
}
2021-05-29 04:01:29 +00:00
void wfmain : : setAudioDevicesUI ( )
2018-06-19 19:58:52 +00:00
{
2021-06-02 19:13:17 +00:00
2021-06-04 07:24:26 +00:00
# if defined(RTAUDIO)
2021-06-02 19:13:17 +00:00
# if defined(Q_OS_LINUX)
RtAudio * audio = new RtAudio ( RtAudio : : Api : : LINUX_ALSA ) ;
# elif defined(Q_OS_WIN)
RtAudio * audio = new RtAudio ( RtAudio : : Api : : WINDOWS_WASAPI ) ;
# elif defined(Q_OS_MACX)
RtAudio * audio = new RtAudio ( RtAudio : : Api : : MACOSX_CORE ) ;
# endif
2021-05-29 04:01:29 +00:00
// Enumerate audio devices, need to do before settings are loaded.
2021-05-31 08:56:05 +00:00
std : : map < int , std : : string > apiMap ;
apiMap [ RtAudio : : MACOSX_CORE ] = " OS-X Core Audio " ;
apiMap [ RtAudio : : WINDOWS_ASIO ] = " Windows ASIO " ;
apiMap [ RtAudio : : WINDOWS_DS ] = " Windows DirectSound " ;
apiMap [ RtAudio : : WINDOWS_WASAPI ] = " Windows WASAPI " ;
apiMap [ RtAudio : : UNIX_JACK ] = " Jack Client " ;
apiMap [ RtAudio : : LINUX_ALSA ] = " Linux ALSA " ;
apiMap [ RtAudio : : LINUX_PULSE ] = " Linux PulseAudio " ;
apiMap [ RtAudio : : LINUX_OSS ] = " Linux OSS " ;
apiMap [ RtAudio : : RTAUDIO_DUMMY ] = " RtAudio Dummy " ;
2018-06-19 19:58:52 +00:00
2021-05-31 08:56:05 +00:00
std : : vector < RtAudio : : Api > apis ;
RtAudio : : getCompiledApi ( apis ) ;
qInfo ( logAudio ( ) ) < < " RtAudio Version " < < QString : : fromStdString ( RtAudio : : getVersion ( ) ) ;
qInfo ( logAudio ( ) ) < < " Compiled APIs: " ;
for ( unsigned int i = 0 ; i < apis . size ( ) ; i + + ) {
qInfo ( logAudio ( ) ) < < " " < < QString : : fromStdString ( apiMap [ apis [ i ] ] ) ;
2021-04-19 16:26:26 +00:00
}
2018-06-19 19:58:52 +00:00
2021-05-31 08:56:05 +00:00
RtAudio : : DeviceInfo info ;
2021-01-30 06:09:09 +00:00
2021-06-02 19:13:17 +00:00
qInfo ( logAudio ( ) ) < < " Current API: " < < QString : : fromStdString ( apiMap [ audio - > getCurrentApi ( ) ] ) ;
unsigned int devices = audio - > getDeviceCount ( ) ;
2021-05-31 08:56:05 +00:00
qInfo ( logAudio ( ) ) < < " Found " < < devices < < " audio device(s) *=default " ;
2021-01-30 06:09:09 +00:00
2021-05-31 08:56:05 +00:00
for ( unsigned int i = 1 ; i < devices ; i + + ) {
2021-06-02 19:13:17 +00:00
info = audio - > getDeviceInfo ( i ) ;
2021-05-31 08:56:05 +00:00
if ( info . outputChannels > 0 ) {
qInfo ( logAudio ( ) ) < < ( info . isDefaultOutput ? " * " : " " ) < < " ( " < < i < < " ) Output Device : " < < QString : : fromStdString ( info . name ) ;
ui - > audioOutputCombo - > addItem ( QString : : fromStdString ( info . name ) , i ) ;
}
if ( info . inputChannels > 0 ) {
qInfo ( logAudio ( ) ) < < ( info . isDefaultInput ? " * " : " " ) < < " ( " < < i < < " ) Input Device : " < < QString : : fromStdString ( info . name ) ;
ui - > audioInputCombo - > addItem ( QString : : fromStdString ( info . name ) , i ) ;
}
2021-05-15 03:00:38 +00:00
}
2021-06-02 19:13:17 +00:00
delete audio ;
2021-06-04 07:24:26 +00:00
# elif defined(PORTAUDIO)
// Use PortAudio device enumeration
# else
// If no external library is configured, use QTMultimedia
// Enumerate audio devices, need to do before settings are loaded.
const auto audioOutputs = QAudioDeviceInfo : : availableDevices ( QAudio : : AudioOutput ) ;
for ( const QAudioDeviceInfo & deviceInfo : audioOutputs ) {
ui - > audioOutputCombo - > addItem ( deviceInfo . deviceName ( ) , QVariant : : fromValue ( deviceInfo ) ) ;
}
const auto audioInputs = QAudioDeviceInfo : : availableDevices ( QAudio : : AudioInput ) ;
for ( const QAudioDeviceInfo & deviceInfo : audioInputs ) {
ui - > audioInputCombo - > addItem ( deviceInfo . deviceName ( ) , QVariant : : fromValue ( deviceInfo ) ) ;
}
# endif
2021-05-15 03:00:38 +00:00
}
2021-05-29 04:01:29 +00:00
void wfmain : : setSerialDevicesUI ( )
2021-01-30 06:09:09 +00:00
{
2021-05-29 04:01:29 +00:00
ui - > serialDeviceListCombo - > blockSignals ( true ) ;
ui - > serialDeviceListCombo - > addItem ( " Auto " , 0 ) ;
int i = 0 ;
foreach ( const QSerialPortInfo & serialPortInfo , QSerialPortInfo : : availablePorts ( ) )
{
portList . append ( serialPortInfo . portName ( ) ) ;
# if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
ui - > serialDeviceListCombo - > addItem ( QString ( " /dev/ " ) + serialPortInfo . portName ( ) , i + + ) ;
# else
ui - > serialDeviceListCombo - > addItem ( serialPortInfo . portName ( ) , i + + ) ;
# endif
}
# if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
ui - > serialDeviceListCombo - > addItem ( " Manual... " , 256 ) ;
# endif
ui - > serialDeviceListCombo - > blockSignals ( false ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 04:01:29 +00:00
ui - > vspCombo - > blockSignals ( true ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 04:01:29 +00:00
# ifdef Q_OS_WIN
ui - > vspCombo - > addItem ( QString ( " None " ) , i + + ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 04:01:29 +00:00
foreach ( const QSerialPortInfo & serialPortInfo , QSerialPortInfo : : availablePorts ( ) )
2021-01-30 06:09:09 +00:00
{
2021-05-29 04:01:29 +00:00
ui - > vspCombo - > addItem ( serialPortInfo . portName ( ) ) ;
}
# else
// Provide reasonable names for the symbolic link to the pty device
# ifdef Q_OS_MAC
QString vspName = QStandardPaths : : standardLocations ( QStandardPaths : : DownloadLocation ) [ 0 ] + " /rig-pty " ;
# else
QString vspName = QDir : : homePath ( ) + " /rig-pty " ;
# endif
for ( i = 1 ; i < 8 ; i + + ) {
ui - > vspCombo - > addItem ( vspName + QString : : number ( i ) ) ;
2021-05-29 03:51:19 +00:00
2021-05-29 04:01:29 +00:00
if ( QFile : : exists ( vspName + QString : : number ( i ) ) ) {
auto * model = qobject_cast < QStandardItemModel * > ( ui - > vspCombo - > model ( ) ) ;
auto * item = model - > item ( ui - > vspCombo - > count ( ) - 1 ) ;
item - > setEnabled ( false ) ;
}
2021-02-02 09:05:59 +00:00
}
2021-05-29 04:01:29 +00:00
ui - > vspCombo - > addItem ( vspName + QString : : number ( i ) ) ;
ui - > vspCombo - > addItem ( QString ( " None " ) , i + + ) ;
# endif
ui - > vspCombo - > setEditable ( true ) ;
ui - > vspCombo - > blockSignals ( false ) ;
2021-05-29 03:51:19 +00:00
}
2021-02-02 09:05:59 +00:00
2021-05-29 03:51:19 +00:00
void wfmain : : setupKeyShortcuts ( )
{
keyF1 = new QShortcut ( this ) ;
keyF1 - > setKey ( Qt : : Key_F1 ) ;
connect ( keyF1 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF1 ( ) ) ) ;
2021-04-20 11:29:10 +00:00
2021-05-29 03:51:19 +00:00
keyF2 = new QShortcut ( this ) ;
keyF2 - > setKey ( Qt : : Key_F2 ) ;
connect ( keyF2 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF2 ( ) ) ) ;
2021-04-20 11:29:10 +00:00
2021-05-29 03:51:19 +00:00
keyF3 = new QShortcut ( this ) ;
keyF3 - > setKey ( Qt : : Key_F3 ) ;
connect ( keyF3 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF3 ( ) ) ) ;
2021-02-07 12:59:41 +00:00
2021-05-29 03:51:19 +00:00
keyF4 = new QShortcut ( this ) ;
keyF4 - > setKey ( Qt : : Key_F4 ) ;
connect ( keyF4 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF4 ( ) ) ) ;
2021-02-07 12:59:41 +00:00
2021-05-29 03:51:19 +00:00
keyF5 = new QShortcut ( this ) ;
keyF5 - > setKey ( Qt : : Key_F5 ) ;
connect ( keyF5 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF5 ( ) ) ) ;
2021-02-07 12:59:41 +00:00
2021-05-29 03:51:19 +00:00
keyF6 = new QShortcut ( this ) ;
keyF6 - > setKey ( Qt : : Key_F6 ) ;
connect ( keyF6 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF6 ( ) ) ) ;
2021-05-21 15:30:52 +00:00
2021-05-29 03:51:19 +00:00
keyF7 = new QShortcut ( this ) ;
keyF7 - > setKey ( Qt : : Key_F7 ) ;
connect ( keyF7 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF7 ( ) ) ) ;
2021-05-21 15:30:52 +00:00
2021-05-29 03:51:19 +00:00
keyF8 = new QShortcut ( this ) ;
keyF8 - > setKey ( Qt : : Key_F8 ) ;
connect ( keyF8 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF8 ( ) ) ) ;
2021-02-07 12:59:41 +00:00
2021-05-29 03:51:19 +00:00
keyF9 = new QShortcut ( this ) ;
keyF9 - > setKey ( Qt : : Key_F9 ) ;
connect ( keyF9 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF9 ( ) ) ) ;
2021-05-21 18:35:13 +00:00
2021-05-29 03:51:19 +00:00
keyF10 = new QShortcut ( this ) ;
keyF10 - > setKey ( Qt : : Key_F10 ) ;
connect ( keyF10 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF10 ( ) ) ) ;
2021-05-21 18:35:13 +00:00
2021-05-29 03:51:19 +00:00
keyF11 = new QShortcut ( this ) ;
keyF11 - > setKey ( Qt : : Key_F11 ) ;
connect ( keyF11 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF11 ( ) ) ) ;
2021-02-02 09:05:59 +00:00
2021-05-29 03:51:19 +00:00
keyF12 = new QShortcut ( this ) ;
keyF12 - > setKey ( Qt : : Key_F12 ) ;
connect ( keyF12 , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF12 ( ) ) ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 03:51:19 +00:00
keyControlT = new QShortcut ( this ) ;
keyControlT - > setKey ( Qt : : CTRL + Qt : : Key_T ) ;
connect ( keyControlT , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlT ( ) ) ) ;
2021-02-07 12:59:41 +00:00
2021-05-29 03:51:19 +00:00
keyControlR = new QShortcut ( this ) ;
keyControlR - > setKey ( Qt : : CTRL + Qt : : Key_R ) ;
connect ( keyControlR , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlR ( ) ) ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 03:51:19 +00:00
keyControlI = new QShortcut ( this ) ;
keyControlI - > setKey ( Qt : : CTRL + Qt : : Key_I ) ;
connect ( keyControlI , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlI ( ) ) ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 03:51:19 +00:00
keyControlU = new QShortcut ( this ) ;
keyControlU - > setKey ( Qt : : CTRL + Qt : : Key_U ) ;
connect ( keyControlU , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlU ( ) ) ) ;
2021-02-07 09:03:02 +00:00
2021-05-29 03:51:19 +00:00
keyStar = new QShortcut ( this ) ;
keyStar - > setKey ( Qt : : Key_Asterisk ) ;
connect ( keyStar , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutStar ( ) ) ) ;
2021-02-07 09:03:02 +00:00
2021-05-29 03:51:19 +00:00
keySlash = new QShortcut ( this ) ;
keySlash - > setKey ( Qt : : Key_Slash ) ;
connect ( keySlash , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutSlash ( ) ) ) ;
2021-02-11 17:09:45 +00:00
2021-05-29 03:51:19 +00:00
keyMinus = new QShortcut ( this ) ;
keyMinus - > setKey ( Qt : : Key_Minus ) ;
connect ( keyMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutMinus ( ) ) ) ;
2021-05-21 20:01:21 +00:00
2021-05-29 03:51:19 +00:00
keyPlus = new QShortcut ( this ) ;
keyPlus - > setKey ( Qt : : Key_Plus ) ;
connect ( keyPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPlus ( ) ) ) ;
2021-05-21 20:01:21 +00:00
2021-05-29 03:51:19 +00:00
keyShiftMinus = new QShortcut ( this ) ;
keyShiftMinus - > setKey ( Qt : : SHIFT + Qt : : Key_Minus ) ;
connect ( keyShiftMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutShiftMinus ( ) ) ) ;
2021-05-22 06:46:15 +00:00
2021-05-29 03:51:19 +00:00
keyShiftPlus = new QShortcut ( this ) ;
keyShiftPlus - > setKey ( Qt : : SHIFT + Qt : : Key_Plus ) ;
connect ( keyShiftPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutShiftPlus ( ) ) ) ;
2021-05-21 20:01:21 +00:00
2021-05-29 03:51:19 +00:00
keyControlMinus = new QShortcut ( this ) ;
keyControlMinus - > setKey ( Qt : : CTRL + Qt : : Key_Minus ) ;
connect ( keyControlMinus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlMinus ( ) ) ) ;
2021-05-21 20:01:21 +00:00
2021-05-29 03:51:19 +00:00
keyControlPlus = new QShortcut ( this ) ;
keyControlPlus - > setKey ( Qt : : CTRL + Qt : : Key_Plus ) ;
connect ( keyControlPlus , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutControlPlus ( ) ) ) ;
2021-05-21 20:01:21 +00:00
2021-05-29 03:51:19 +00:00
keyQuit = new QShortcut ( this ) ;
keyQuit - > setKey ( Qt : : CTRL + Qt : : Key_Q ) ;
connect ( keyQuit , SIGNAL ( activated ( ) ) , this , SLOT ( on_exitBtn_clicked ( ) ) ) ;
2021-02-02 09:05:59 +00:00
2021-05-29 03:51:19 +00:00
keyPageUp = new QShortcut ( this ) ;
keyPageUp - > setKey ( Qt : : Key_PageUp ) ;
connect ( keyPageUp , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPageUp ( ) ) ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 03:51:19 +00:00
keyPageDown = new QShortcut ( this ) ;
keyPageDown - > setKey ( Qt : : Key_PageDown ) ;
connect ( keyPageDown , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutPageDown ( ) ) ) ;
2021-02-02 09:05:59 +00:00
2021-05-29 03:51:19 +00:00
keyF = new QShortcut ( this ) ;
keyF - > setKey ( Qt : : Key_F ) ;
connect ( keyF , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutF ( ) ) ) ;
2021-01-30 06:09:09 +00:00
2021-05-29 03:51:19 +00:00
keyM = new QShortcut ( this ) ;
keyM - > setKey ( Qt : : Key_M ) ;
connect ( keyM , SIGNAL ( activated ( ) ) , this , SLOT ( shortcutM ( ) ) ) ;
2021-02-05 20:26:18 +00:00
}
2021-06-01 16:48:19 +00:00
void wfmain : : setupShuttleDevice ( )
{
2021-06-04 10:14:01 +00:00
shuttleDev = new shuttle ( ) ;
shuttleThread = new QThread ( this ) ;
shuttleDev - > moveToThread ( shuttleThread ) ;
connect ( shuttleThread , SIGNAL ( started ( ) ) , shuttleDev , SLOT ( run ( ) ) ) ;
connect ( shuttleThread , SIGNAL ( finished ( ) ) , shuttleDev , SLOT ( deleteLater ( ) ) ) ;
connect ( shuttleDev , SIGNAL ( hidDataArrived ( QByteArray ) ) , this , SLOT ( hidDataArrived ( QByteArray ) ) ) ;
shuttleThread - > start ( ) ;
}
void wfmain : : hidDataArrived ( QByteArray data )
{
2021-06-01 16:48:19 +00:00
}
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-04-19 16:26:26 +00:00
defPrefs . enableRigCtlD = false ;
defPrefs . rigCtlPort = 4533 ;
2021-05-05 13:11:00 +00:00
defPrefs . virtualSerialPort = QString ( " none " ) ;
2021-02-05 04:54:34 +00:00
2021-03-01 19:53:12 +00:00
udpDefPrefs . ipAddress = QString ( " " ) ;
udpDefPrefs . controlLANPort = 50001 ;
udpDefPrefs . serialLANPort = 50002 ;
udpDefPrefs . audioLANPort = 50003 ;
udpDefPrefs . username = QString ( " " ) ;
udpDefPrefs . password = QString ( " " ) ;
2021-05-23 15:09:41 +00:00
udpDefPrefs . audioOutput = 0 ;
udpDefPrefs . audioInput = 0 ;
2021-03-01 19:53:12 +00:00
udpDefPrefs . audioRXLatency = 150 ;
udpDefPrefs . audioTXLatency = 150 ;
udpDefPrefs . audioRXSampleRate = 48000 ;
udpDefPrefs . audioRXCodec = 4 ;
udpDefPrefs . audioTXSampleRate = 48000 ;
udpDefPrefs . audioTXCodec = 4 ;
2021-03-09 17:22:16 +00:00
udpDefPrefs . resampleQuality = 4 ;
2021-03-27 16:07:17 +00:00
udpDefPrefs . clientName = QHostInfo : : localHostName ( ) ;
2018-11-25 06:21:36 +00:00
}
2018-11-24 08:10:05 +00:00
void wfmain : : loadSettings ( )
{
2021-05-20 18:24:40 +00:00
qInfo ( 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)
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Interface " ) ;
prefs . useFullScreen = settings - > value ( " UseFullScreen " , defPrefs . useFullScreen ) . toBool ( ) ;
prefs . useDarkMode = settings - > value ( " UseDarkMode " , defPrefs . useDarkMode ) . toBool ( ) ;
prefs . useSystemTheme = settings - > value ( " UseSystemTheme " , defPrefs . useSystemTheme ) . toBool ( ) ;
prefs . drawPeaks = settings - > value ( " DrawPeaks " , defPrefs . drawPeaks ) . toBool ( ) ;
prefs . stylesheetPath = settings - > value ( " StylesheetPath " , defPrefs . stylesheetPath ) . toString ( ) ;
ui - > splitter - > restoreState ( settings - > value ( " splitter " ) . toByteArray ( ) ) ;
restoreGeometry ( settings - > value ( " windowGeometry " ) . toByteArray ( ) ) ;
restoreState ( settings - > value ( " windowState " ) . toByteArray ( ) ) ;
2020-04-04 23:51:46 +00:00
setWindowState ( Qt : : WindowActive ) ; // Works around QT bug to returns window+keyboard focus.
2021-05-20 18:24:40 +00:00
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
2021-04-27 06:40:08 +00:00
// Load color schemes:
// Per this bug: https://forum.qt.io/topic/24725/solved-qvariant-will-drop-alpha-value-when-save-qcolor/5
// the alpha channel is dropped when converting raw qvariant of QColor. Therefore, we are storing as unsigned int and converting back.
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " DarkColors " ) ;
prefs . colorScheme . Dark_PlotBackground = QColor : : fromRgba ( settings - > value ( " Dark_PlotBackground " , defaultColors . Dark_PlotBackground . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_PlotAxisPen = QColor : : fromRgba ( settings - > value ( " Dark_PlotAxisPen " , defaultColors . Dark_PlotAxisPen . rgba ( ) ) . toUInt ( ) ) ;
2021-04-27 06:40:08 +00:00
2021-05-20 18:24:40 +00:00
prefs . colorScheme . Dark_PlotLegendTextColor = QColor : : fromRgba ( settings - > value ( " Dark_PlotLegendTextColor " , defaultColors . Dark_PlotLegendTextColor . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_PlotLegendBorderPen = QColor : : fromRgba ( settings - > value ( " Dark_PlotLegendBorderPen " , defaultColors . Dark_PlotLegendBorderPen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_PlotLegendBrush = QColor : : fromRgba ( settings - > value ( " Dark_PlotLegendBrush " , defaultColors . Dark_PlotLegendBrush . rgba ( ) ) . toUInt ( ) ) ;
2021-04-27 06:40:08 +00:00
2021-05-20 18:24:40 +00:00
prefs . colorScheme . Dark_PlotTickLabel = QColor : : fromRgba ( settings - > value ( " Dark_PlotTickLabel " , defaultColors . Dark_PlotTickLabel . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_PlotBasePen = QColor : : fromRgba ( settings - > value ( " Dark_PlotBasePen " , defaultColors . Dark_PlotBasePen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_PlotTickPen = QColor : : fromRgba ( settings - > value ( " Dark_PlotTickPen " , defaultColors . Dark_PlotTickPen . rgba ( ) ) . toUInt ( ) ) ;
2021-04-27 06:40:08 +00:00
2021-05-20 18:24:40 +00:00
prefs . colorScheme . Dark_PeakPlotLine = QColor : : fromRgba ( settings - > value ( " Dark_PeakPlotLine " , defaultColors . Dark_PeakPlotLine . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Dark_TuningLine = QColor : : fromRgba ( settings - > value ( " Dark_TuningLine " , defaultColors . Dark_TuningLine . rgba ( ) ) . toUInt ( ) ) ;
settings - > endGroup ( ) ;
2021-04-27 06:40:08 +00:00
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " LightColors " ) ;
prefs . colorScheme . Light_PlotBackground = QColor : : fromRgba ( settings - > value ( " Light_PlotBackground " , defaultColors . Light_PlotBackground . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotAxisPen = QColor : : fromRgba ( settings - > value ( " Light_PlotAxisPen " , defaultColors . Light_PlotAxisPen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotLegendTextColor = QColor : : fromRgba ( settings - > value ( " Light_PlotLegendTextColo " , defaultColors . Light_PlotLegendTextColor . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotLegendBorderPen = QColor : : fromRgba ( settings - > value ( " Light_PlotLegendBorderPen " , defaultColors . Light_PlotLegendBorderPen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotLegendBrush = QColor : : fromRgba ( settings - > value ( " Light_PlotLegendBrush " , defaultColors . Light_PlotLegendBrush . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotTickLabel = QColor : : fromRgba ( settings - > value ( " Light_PlotTickLabel " , defaultColors . Light_PlotTickLabel . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotBasePen = QColor : : fromRgba ( settings - > value ( " Light_PlotBasePen " , defaultColors . Light_PlotBasePen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PlotTickPen = QColor : : fromRgba ( settings - > value ( " Light_PlotTickPen " , defaultColors . Light_PlotTickPen . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_PeakPlotLine = QColor : : fromRgba ( settings - > value ( " Light_PeakPlotLine " , defaultColors . Light_PeakPlotLine . rgba ( ) ) . toUInt ( ) ) ;
prefs . colorScheme . Light_TuningLine = QColor : : fromRgba ( settings - > value ( " Light_TuningLine " , defaultColors . Light_TuningLine . rgba ( ) ) . toUInt ( ) ) ;
settings - > endGroup ( ) ;
2021-04-27 06:40:08 +00:00
2018-11-24 08:10:05 +00:00
// Radio and Comms: C-IV addr, port to use
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Radio " ) ;
prefs . radioCIVAddr = ( unsigned char ) settings - > value ( " RigCIVuInt " , defPrefs . radioCIVAddr ) . toInt ( ) ;
2021-05-18 07:35:47 +00:00
if ( prefs . radioCIVAddr ! = 0 )
{
ui - > rigCIVManualAddrChk - > setChecked ( true ) ;
ui - > rigCIVaddrHexLine - > blockSignals ( true ) ;
ui - > rigCIVaddrHexLine - > setText ( QString ( " %1 " ) . arg ( prefs . radioCIVAddr , 2 , 16 ) ) ;
ui - > rigCIVaddrHexLine - > setEnabled ( true ) ;
ui - > rigCIVaddrHexLine - > blockSignals ( false ) ;
} else {
ui - > rigCIVManualAddrChk - > setChecked ( false ) ;
ui - > rigCIVaddrHexLine - > setEnabled ( false ) ;
}
2021-05-20 18:24:40 +00:00
prefs . serialPortRadio = settings - > value ( " SerialPortRadio " , defPrefs . serialPortRadio ) . toString ( ) ;
2021-05-07 08:28:01 +00:00
int serialIndex = ui - > serialDeviceListCombo - > findText ( prefs . serialPortRadio ) ;
if ( serialIndex ! = - 1 ) {
ui - > serialDeviceListCombo - > setCurrentIndex ( serialIndex ) ;
}
2021-05-20 18:24:40 +00:00
prefs . serialPortBaud = ( quint32 ) settings - > value ( " SerialPortBaud " , defPrefs . serialPortBaud ) . toInt ( ) ;
2021-05-20 04:36:34 +00:00
ui - > baudRateCombo - > blockSignals ( true ) ;
ui - > baudRateCombo - > setCurrentIndex ( ui - > baudRateCombo - > findData ( prefs . serialPortBaud ) ) ;
ui - > baudRateCombo - > blockSignals ( false ) ;
2021-05-20 18:24:40 +00:00
prefs . virtualSerialPort = settings - > value ( " VirtualSerialPort " , defPrefs . virtualSerialPort ) . toString ( ) ;
2021-05-05 13:11:00 +00:00
int vspIndex = ui - > vspCombo - > findText ( prefs . virtualSerialPort ) ;
if ( vspIndex ! = - 1 ) {
ui - > vspCombo - > setCurrentIndex ( vspIndex ) ;
}
2021-05-11 10:18:45 +00:00
else
{
ui - > vspCombo - > addItem ( prefs . virtualSerialPort ) ;
ui - > vspCombo - > setCurrentIndex ( ui - > vspCombo - > count ( ) - 1 ) ;
}
2021-05-20 18:24:40 +00:00
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Misc. user settings (enable PTT, draw peaks, etc)
2021-05-20 18:24:40 +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 ) ;
2021-05-20 18:24:40 +00:00
prefs . niceTS = settings - > value ( " NiceTS " , defPrefs . niceTS ) . toBool ( ) ;
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " LAN " ) ;
2021-03-01 19:53:12 +00:00
2021-05-20 18:24:40 +00:00
prefs . enableLAN = settings - > value ( " EnableLAN " , defPrefs . enableLAN ) . toBool ( ) ;
2021-05-20 04:36:34 +00:00
if ( prefs . enableLAN )
{
ui - > baudRateCombo - > setEnabled ( false ) ;
ui - > serialDeviceListCombo - > setEnabled ( false ) ;
2021-05-23 20:43:15 +00:00
//ui->udpServerSetupBtn->setEnabled(false);
2021-05-20 04:36:34 +00:00
} else {
ui - > baudRateCombo - > setEnabled ( true ) ;
ui - > serialDeviceListCombo - > setEnabled ( true ) ;
2021-05-23 20:43:15 +00:00
//ui->udpServerSetupBtn->setEnabled(true);
2021-05-20 04:36:34 +00:00
}
2021-03-03 05:55:33 +00:00
ui - > lanEnableBtn - > setChecked ( prefs . enableLAN ) ;
2021-05-31 06:26:36 +00:00
ui - > connectBtn - > setEnabled ( true ) ;
2021-04-19 16:26:26 +00:00
2021-05-20 18:24:40 +00:00
prefs . enableRigCtlD = settings - > value ( " EnableRigCtlD " , defPrefs . enableRigCtlD ) . toBool ( ) ;
prefs . rigCtlPort = settings - > value ( " RigCtlPort " , defPrefs . rigCtlPort ) . toInt ( ) ;
2021-04-19 16:26:26 +00:00
2021-05-20 18:24:40 +00:00
udpPrefs . ipAddress = settings - > value ( " IPAddress " , udpDefPrefs . ipAddress ) . toString ( ) ;
2021-03-03 05:55:33 +00:00
ui - > ipAddressTxt - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-03-01 19:53:12 +00:00
ui - > ipAddressTxt - > setText ( udpPrefs . ipAddress ) ;
2021-02-08 16:53:26 +00:00
2021-05-20 18:24:40 +00:00
udpPrefs . controlLANPort = settings - > value ( " ControlLANPort " , udpDefPrefs . controlLANPort ) . toInt ( ) ;
2021-03-03 05:55:33 +00:00
ui - > controlPortTxt - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-03-01 19:53:12 +00:00
ui - > controlPortTxt - > setText ( QString ( " %1 " ) . arg ( udpPrefs . controlLANPort ) ) ;
2021-02-08 16:53:26 +00:00
2021-05-20 18:24:40 +00:00
udpPrefs . username = settings - > value ( " Username " , udpDefPrefs . username ) . toString ( ) ;
2021-03-03 05:55:33 +00:00
ui - > usernameTxt - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-03-01 19:53:12 +00:00
ui - > usernameTxt - > setText ( QString ( " %1 " ) . arg ( udpPrefs . username ) ) ;
2021-02-08 16:53:26 +00:00
2021-05-20 18:24:40 +00:00
udpPrefs . password = settings - > value ( " Password " , udpDefPrefs . password ) . toString ( ) ;
2021-03-03 05:55:33 +00:00
ui - > passwordTxt - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-03-01 19:53:12 +00:00
ui - > passwordTxt - > setText ( QString ( " %1 " ) . arg ( udpPrefs . password ) ) ;
2021-02-04 10:27:30 +00:00
2021-06-04 07:24:26 +00:00
rxSetup . isinput = false ;
txSetup . isinput = true ;
2021-03-27 16:07:17 +00:00
2021-06-04 07:24:26 +00:00
rxSetup . latency = settings - > value ( " AudioRXLatency " , " 150 " ) . toInt ( ) ;
2021-03-03 05:55:33 +00:00
ui - > rxLatencySlider - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-06-04 07:24:26 +00:00
ui - > rxLatencySlider - > setValue ( rxSetup . latency ) ;
2021-02-27 00:37:00 +00:00
ui - > rxLatencySlider - > setTracking ( false ) ; // Stop it sending value on every change.
2021-06-04 07:24:26 +00:00
txSetup . latency = settings - > value ( " AudioTXLatency " , " 150 " ) . toInt ( ) ;
2021-03-03 05:55:33 +00:00
ui - > txLatencySlider - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-06-04 07:24:26 +00:00
ui - > txLatencySlider - > setValue ( rxSetup . latency ) ;
2021-02-27 09:34:56 +00:00
ui - > txLatencySlider - > setTracking ( false ) ; // Stop it sending value on every change.
2021-02-08 16:53:26 +00:00
2021-06-04 07:24:26 +00:00
ui - > audioSampleRateCombo - > blockSignals ( true ) ;
rxSetup . samplerate = settings - > value ( " AudioRXSampleRate " , " 48000 " ) . toInt ( ) ;
txSetup . samplerate = rxSetup . samplerate ;
2021-03-03 05:55:33 +00:00
ui - > audioSampleRateCombo - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-06-04 07:24:26 +00:00
int audioSampleRateIndex = ui - > audioSampleRateCombo - > findText ( QString : : number ( rxSetup . samplerate ) ) ;
2021-02-09 12:43:28 +00:00
if ( audioSampleRateIndex ! = - 1 ) {
2021-05-22 16:02:51 +00:00
ui - > audioSampleRateCombo - > setCurrentIndex ( audioSampleRateIndex ) ;
2021-02-09 12:43:28 +00:00
}
2021-06-04 07:24:26 +00:00
ui - > audioSampleRateCombo - > blockSignals ( false ) ;
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 ) ;
2021-06-04 07:24:26 +00:00
ui - > audioRXCodecCombo - > blockSignals ( true ) ;
rxSetup . codec = settings - > value ( " AudioRXCodec " , " 4 " ) . toInt ( ) ;
2021-03-03 05:55:33 +00:00
ui - > audioRXCodecCombo - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-02-09 12:43:28 +00:00
for ( int f = 0 ; f < ui - > audioRXCodecCombo - > count ( ) ; f + + )
2021-06-04 07:24:26 +00:00
if ( ui - > audioRXCodecCombo - > itemData ( f ) . toInt ( ) = = rxSetup . codec )
2021-02-09 12:43:28 +00:00
ui - > audioRXCodecCombo - > setCurrentIndex ( f ) ;
2021-06-04 07:24:26 +00:00
ui - > audioRXCodecCombo - > blockSignals ( false ) ;
2021-02-09 12:43:28 +00:00
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
2021-06-04 07:24:26 +00:00
ui - > audioRXCodecCombo - > blockSignals ( true ) ;
txSetup . codec = settings - > value ( " AudioTXCodec " , " 4 " ) . toInt ( ) ;
2021-03-03 05:55:33 +00:00
ui - > audioTXCodecCombo - > setEnabled ( ui - > lanEnableBtn - > isChecked ( ) ) ;
2021-02-09 12:43:28 +00:00
for ( int f = 0 ; f < ui - > audioTXCodecCombo - > count ( ) ; f + + )
2021-06-04 07:24:26 +00:00
if ( ui - > audioTXCodecCombo - > itemData ( f ) . toInt ( ) = = txSetup . codec )
2021-02-09 12:43:28 +00:00
ui - > audioTXCodecCombo - > setCurrentIndex ( f ) ;
2021-06-04 07:24:26 +00:00
ui - > audioRXCodecCombo - > blockSignals ( false ) ;
2021-02-08 16:53:26 +00:00
2021-06-04 07:24:26 +00:00
ui - > audioOutputCombo - > blockSignals ( true ) ;
rxSetup . name = settings - > value ( " AudioOutput " , udpDefPrefs . audioOutputName ) . toString ( ) ;
qInfo ( logGui ( ) ) < < " Got Audio Output: " < < rxSetup . name ;
int audioOutputIndex = ui - > audioOutputCombo - > findText ( rxSetup . name ) ;
2021-03-06 09:14:28 +00:00
if ( audioOutputIndex ! = - 1 ) {
2021-02-08 16:53:26 +00:00
ui - > audioOutputCombo - > setCurrentIndex ( audioOutputIndex ) ;
2021-06-04 07:24:26 +00:00
# if defined(RTAUDIO)
2021-06-04 12:47:32 +00:00
rxSetup . port = ui - > audioOutputCombo - > itemData ( audioOutputIndex ) . toInt ( ) ;
2021-06-04 07:24:26 +00:00
# elif defined(PORTAUDIO)
# else
QVariant v = ui - > audioOutputCombo - > currentData ( ) ;
rxSetup . port = v . value < QAudioDeviceInfo > ( ) ;
# endif
2021-03-06 09:14:28 +00:00
}
2021-06-04 07:24:26 +00:00
ui - > audioOutputCombo - > blockSignals ( false ) ;
2021-02-08 16:53:26 +00:00
2021-06-04 07:24:26 +00:00
ui - > audioInputCombo - > blockSignals ( true ) ;
txSetup . name = settings - > value ( " AudioInput " , udpDefPrefs . audioInputName ) . toString ( ) ;
qInfo ( logGui ( ) ) < < " Got Audio Input: " < < txSetup . name ;
int audioInputIndex = ui - > audioInputCombo - > findText ( txSetup . name ) ;
2021-03-06 09:14:28 +00:00
if ( audioInputIndex ! = - 1 ) {
ui - > audioInputCombo - > setCurrentIndex ( audioInputIndex ) ;
2021-06-04 07:24:26 +00:00
# if defined(RTAUDIO)
2021-06-04 12:47:32 +00:00
txSetup . port = ui - > audioInputCombo - > itemData ( audioInputIndex ) . toInt ( ) ;
2021-06-04 07:24:26 +00:00
# elif defined(PORTAUDIO)
# else
QVariant v = ui - > audioInputCombo - > currentData ( ) ;
txSetup . port = v . value < QAudioDeviceInfo > ( ) ;
# endif
2021-03-06 09:14:28 +00:00
}
2021-06-04 13:25:07 +00:00
ui - > audioInputCombo - > blockSignals ( false ) ;
2021-06-04 07:24:26 +00:00
rxSetup . resampleQuality = settings - > value ( " ResampleQuality " , udpDefPrefs . resampleQuality ) . toInt ( ) ;
txSetup . resampleQuality = rxSetup . resampleQuality ;
2021-02-04 10:27:30 +00:00
2021-05-20 18:24:40 +00:00
udpPrefs . clientName = settings - > value ( " ClientName " , udpDefPrefs . clientName ) . toString ( ) ;
2021-03-09 17:22:16 +00:00
2021-05-20 18:24:40 +00:00
settings - > endGroup ( ) ;
2021-02-16 16:16:46 +00:00
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Server " ) ;
2021-02-16 16:16:46 +00:00
2021-05-20 18:24:40 +00:00
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 ( ) ;
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-05-20 18:24:40 +00:00
user . username = settings - > value ( " ServerUsername_ " + QString : : number ( f ) , " " ) . toString ( ) ;
user . password = settings - > value ( " ServerPassword_ " + QString : : number ( f ) , " " ) . toString ( ) ;
user . userType = settings - > value ( " ServerUserType_ " + QString : : number ( f ) , 0 ) . toInt ( ) ;
2021-02-16 16:16:46 +00:00
serverConfig . users . append ( user ) ;
}
2021-05-20 18:24:40 +00:00
settings - > endGroup ( ) ;
2021-02-16 16:16:46 +00:00
2018-11-24 08:10:05 +00:00
// Memory channels
2018-11-25 06:21:36 +00:00
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Memory " ) ;
int size = settings - > beginReadArray ( " Channel " ) ;
2018-11-25 06:21:36 +00:00
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 + + )
{
2021-05-20 18:24:40 +00:00
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 ( ) ;
2018-11-25 06:21:36 +00:00
if ( isSet )
{
mem . setPreset ( chan , freq , ( mode_kind ) mode ) ;
}
}
2021-05-20 18:24:40 +00:00
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-05-20 18:24:40 +00:00
qInfo ( 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)
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Interface " ) ;
settings - > setValue ( " UseFullScreen " , prefs . useFullScreen ) ;
settings - > setValue ( " UseSystemTheme " , prefs . useSystemTheme ) ;
settings - > setValue ( " UseDarkMode " , prefs . useDarkMode ) ;
settings - > setValue ( " DrawPeaks " , prefs . drawPeaks ) ;
settings - > setValue ( " StylesheetPath " , prefs . stylesheetPath ) ;
settings - > setValue ( " splitter " , ui - > splitter - > saveState ( ) ) ;
settings - > setValue ( " windowGeometry " , saveGeometry ( ) ) ;
settings - > setValue ( " windowState " , saveState ( ) ) ;
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Radio and Comms: C-IV addr, port to use
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Radio " ) ;
settings - > setValue ( " RigCIVuInt " , prefs . radioCIVAddr ) ;
settings - > setValue ( " SerialPortRadio " , prefs . serialPortRadio ) ;
settings - > setValue ( " SerialPortBaud " , prefs . serialPortBaud ) ;
settings - > setValue ( " VirtualSerialPort " , prefs . virtualSerialPort ) ;
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
// Misc. user settings (enable PTT, draw peaks, etc)
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Controls " ) ;
settings - > setValue ( " EnablePTT " , prefs . enablePTT ) ;
settings - > setValue ( " NiceTS " , prefs . niceTS ) ;
settings - > endGroup ( ) ;
settings - > beginGroup ( " LAN " ) ;
settings - > setValue ( " EnableLAN " , prefs . enableLAN ) ;
settings - > setValue ( " EnableRigCtlD " , prefs . enableRigCtlD ) ;
settings - > setValue ( " RigCtlPort " , prefs . rigCtlPort ) ;
settings - > setValue ( " IPAddress " , udpPrefs . ipAddress ) ;
settings - > setValue ( " ControlLANPort " , udpPrefs . controlLANPort ) ;
settings - > setValue ( " SerialLANPort " , udpPrefs . serialLANPort ) ;
settings - > setValue ( " AudioLANPort " , udpPrefs . audioLANPort ) ;
settings - > setValue ( " Username " , udpPrefs . username ) ;
settings - > setValue ( " Password " , udpPrefs . password ) ;
2021-06-04 07:24:26 +00:00
settings - > setValue ( " AudioRXLatency " , rxSetup . latency ) ;
settings - > setValue ( " AudioTXLatency " , txSetup . latency ) ;
settings - > setValue ( " AudioRXSampleRate " , rxSetup . samplerate ) ;
settings - > setValue ( " AudioRXCodec " , rxSetup . codec ) ;
settings - > setValue ( " AudioTXSampleRate " , txSetup . samplerate ) ;
settings - > setValue ( " AudioTXCodec " , txSetup . codec ) ;
2021-06-04 12:47:32 +00:00
settings - > setValue ( " AudioOutput " , rxSetup . name ) ;
settings - > setValue ( " AudioInput " , txSetup . name ) ;
2021-06-04 07:24:26 +00:00
settings - > setValue ( " ResampleQuality " , rxSetup . resampleQuality ) ;
2021-05-20 18:24:40 +00:00
settings - > setValue ( " ClientName " , udpPrefs . clientName ) ;
settings - > endGroup ( ) ;
2021-02-03 19:36:35 +00:00
2018-11-24 08:10:05 +00:00
// Memory channels
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " Memory " ) ;
settings - > beginWriteArray ( " Channel " , ( int ) mem . getNumPresets ( ) ) ;
2018-11-24 08:10:05 +00:00
preset_kind temp ;
for ( int i = 0 ; i < ( int ) mem . getNumPresets ( ) ; i + + )
{
temp = mem . getPreset ( ( int ) i ) ;
2021-05-20 18:24:40 +00:00
settings - > setArrayIndex ( i ) ;
settings - > setValue ( " chan " , i ) ;
settings - > setValue ( " freq " , temp . frequency ) ;
settings - > setValue ( " mode " , temp . mode ) ;
settings - > setValue ( " isSet " , temp . isSet ) ;
2018-11-24 08:10:05 +00:00
}
2021-05-20 18:24:40 +00:00
settings - > endArray ( ) ;
settings - > endGroup ( ) ;
2018-11-24 08:10:05 +00:00
2018-11-25 06:21:36 +00:00
// Note: X and Y get the same colors. See setPlotTheme() function
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " DarkColors " ) ;
settings - > setValue ( " Dark_PlotBackground " , prefs . colorScheme . Dark_PlotBackground . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotAxisPen " , prefs . colorScheme . Dark_PlotAxisPen . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotLegendTextColor " , prefs . colorScheme . Dark_PlotLegendTextColor . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotLegendBorderPen " , prefs . colorScheme . Dark_PlotLegendBorderPen . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotLegendBrush " , prefs . colorScheme . Dark_PlotLegendBrush . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotTickLabel " , prefs . colorScheme . Dark_PlotTickLabel . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotBasePen " , prefs . colorScheme . Dark_PlotBasePen . rgba ( ) ) ;
settings - > setValue ( " Dark_PlotTickPen " , prefs . colorScheme . Dark_PlotTickPen . rgba ( ) ) ;
settings - > setValue ( " Dark_PeakPlotLine " , prefs . colorScheme . Dark_PeakPlotLine . rgba ( ) ) ;
settings - > setValue ( " Dark_TuningLine " , prefs . colorScheme . Dark_TuningLine . rgba ( ) ) ;
settings - > endGroup ( ) ;
settings - > beginGroup ( " LightColors " ) ;
settings - > setValue ( " Light_PlotBackground " , prefs . colorScheme . Light_PlotBackground . rgba ( ) ) ;
settings - > setValue ( " Light_PlotAxisPen " , prefs . colorScheme . Light_PlotAxisPen . rgba ( ) ) ;
settings - > setValue ( " Light_PlotLegendTextColor " , prefs . colorScheme . Light_PlotLegendTextColor . rgba ( ) ) ;
settings - > setValue ( " Light_PlotLegendBorderPen " , prefs . colorScheme . Light_PlotLegendBorderPen . rgba ( ) ) ;
settings - > setValue ( " Light_PlotLegendBrush " , prefs . colorScheme . Light_PlotLegendBrush . rgba ( ) ) ;
settings - > setValue ( " Light_PlotTickLabel " , prefs . colorScheme . Light_PlotTickLabel . rgba ( ) ) ;
settings - > setValue ( " Light_PlotBasePen " , prefs . colorScheme . Light_PlotBasePen . rgba ( ) ) ;
settings - > setValue ( " Light_PlotTickPen " , prefs . colorScheme . Light_PlotTickPen . rgba ( ) ) ;
settings - > setValue ( " Light_PeakPlotLine " , prefs . colorScheme . Light_PeakPlotLine . rgba ( ) ) ;
settings - > setValue ( " Light_TuningLine " , prefs . colorScheme . Light_TuningLine . rgba ( ) ) ;
settings - > endGroup ( ) ;
2018-11-25 06:21:36 +00:00
// This is a reference to see how the preference file is encoded.
2021-05-20 18:24:40 +00:00
settings - > beginGroup ( " StandardColors " ) ;
settings - > setValue ( " white " , QColor ( Qt : : white ) . rgba ( ) ) ;
settings - > setValue ( " black " , QColor ( Qt : : black ) . rgba ( ) ) ;
settings - > setValue ( " red_opaque " , QColor ( Qt : : red ) . rgba ( ) ) ;
settings - > setValue ( " red_translucent " , QColor ( 255 , 0 , 0 , 128 ) . rgba ( ) ) ;
settings - > setValue ( " green_opaque " , QColor ( Qt : : green ) . rgba ( ) ) ;
settings - > setValue ( " green_translucent " , QColor ( 0 , 255 , 0 , 128 ) . rgba ( ) ) ;
settings - > setValue ( " blue_opaque " , QColor ( Qt : : blue ) . rgba ( ) ) ;
settings - > setValue ( " blue_translucent " , QColor ( 0 , 0 , 255 , 128 ) . rgba ( ) ) ;
settings - > setValue ( " cyan " , QColor ( Qt : : cyan ) . rgba ( ) ) ;
settings - > setValue ( " magenta " , QColor ( Qt : : magenta ) . rgba ( ) ) ;
settings - > setValue ( " yellow " , QColor ( Qt : : yellow ) . rgba ( ) ) ;
settings - > endGroup ( ) ;
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 ( ) ) ;
2021-02-16 16:16:46 +00:00
for ( int f = 0 ; f < serverConfig . users . count ( ) ; f + + )
{
2021-05-20 18:24:40 +00:00
settings - > setValue ( " ServerUsername_ " + QString : : number ( f ) , serverConfig . users [ f ] . username ) ;
settings - > setValue ( " ServerPassword_ " + QString : : number ( f ) , serverConfig . users [ f ] . password ) ;
settings - > setValue ( " ServerUserType_ " + QString : : number ( f ) , serverConfig . users [ f ] . userType ) ;
2021-02-16 16:16:46 +00:00
}
2021-05-20 18:24:40 +00:00
settings - > endGroup ( ) ;
2021-02-16 16:16:46 +00:00
2018-11-25 06:21:36 +00:00
2021-05-20 18:24:40 +00:00
settings - > sync ( ) ; // Automatic, not needed (supposedly)
2018-11-24 08:10:05 +00:00
}
2021-05-31 06:26:36 +00:00
2021-01-25 00:16:38 +00:00
void wfmain : : prepareWf ( )
2021-05-31 06:26:36 +00:00
{
prepareWf ( 160 ) ;
}
void wfmain : : prepareWf ( unsigned int wfLength )
2021-01-25 00:16:38 +00:00
{
// All this code gets moved in from the constructor of wfmain.
if ( haveRigCaps )
{
2021-05-31 06:26:36 +00:00
// TODO: Lock the function that draws on the spectrum while we are updating.
spectrumDrawLock = true ;
spectWidth = rigCaps . spectLenMax ;
this - > wfLength = wfLength ; // 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 ' ) ;
2021-05-31 06:26:36 +00:00
if ( ( unsigned int ) wfimage . size ( ) < wfLength )
2021-01-25 00:16:38 +00:00
{
2021-05-31 06:26:36 +00:00
unsigned int i = 0 ;
unsigned int oldSize = wfimage . size ( ) ;
for ( i = oldSize ; i < ( wfLength ) ; i + + )
{
wfimage . append ( empty ) ;
}
} else {
wfimage . remove ( wfLength , wfimage . size ( ) - wfLength ) ;
2021-01-25 00:16:38 +00:00
}
2021-05-31 06:26:36 +00:00
wfimage . squeeze ( ) ;
2021-05-31 09:18:37 +00:00
//colorMap->clearData();
2021-05-31 06:26:36 +00:00
colorMap - > data ( ) - > clear ( ) ;
2021-01-25 00:16:38 +00:00
colorMap - > data ( ) - > setValueRange ( QCPRange ( 0 , wfLength - 1 ) ) ;
colorMap - > data ( ) - > setKeyRange ( QCPRange ( 0 , spectWidth - 1 ) ) ;
colorMap - > setDataRange ( QCPRange ( 0 , rigCaps . spectAmpMax ) ) ;
2021-05-31 06:42:45 +00:00
colorMap - > setGradient ( static_cast < QCPColorGradient : : GradientPreset > ( ui - > wfthemeCombo - > currentData ( ) . toInt ( ) ) ) ;
2021-05-31 06:26:36 +00:00
if ( colorMapData = = Q_NULLPTR )
{
colorMapData = new QCPColorMapData ( spectWidth , wfLength , QCPRange ( 0 , spectWidth - 1 ) , QCPRange ( 0 , wfLength - 1 ) ) ;
} else {
//delete colorMapData; // TODO: Figure out why it crashes if we delete first.
colorMapData = new QCPColorMapData ( spectWidth , wfLength , QCPRange ( 0 , spectWidth - 1 ) , QCPRange ( 0 , wfLength - 1 ) ) ;
}
2021-01-25 00:16:38 +00:00
colorMap - > setData ( colorMapData ) ;
2021-05-31 06:26:36 +00:00
2021-01-25 00:16:38 +00:00
wf - > yAxis - > setRangeReversed ( true ) ;
wf - > xAxis - > setVisible ( false ) ;
2021-03-01 16:26:59 +00:00
rigName - > setText ( rigCaps . modelName ) ;
2021-05-31 06:26:36 +00:00
spectrumDrawLock = false ;
2021-01-25 00:16:38 +00:00
} else {
2021-05-15 17:53:16 +00:00
qInfo ( 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-05-15 17:53:16 +00:00
qInfo ( 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-03-22 07:11:43 +00:00
tsWfScroll = 0.0001f ; // modified by tuning step selector
tsKnobMHz = 0.0001f ; // modified by tuning step selector
// Units are in Hz:
tsPlusControlHz = 10000 ;
tsPlusHz = 1000 ;
tsPlusShiftHz = 100 ;
tsPageHz = 1000000 ;
tsPageShiftHz = 500000 ; // TODO, unbind this keystroke from the dial
tsWfScrollHz = 100 ; // modified by tuning step selector
tsKnobHz = 100 ; // modified by tuning step selector
2021-03-04 08:02:53 +00:00
}
void wfmain : : on_tuningStepCombo_currentIndexChanged ( int index )
{
2021-03-22 07:11:43 +00:00
tsWfScroll = ( float ) ui - > tuningStepCombo - > itemData ( index ) . toUInt ( ) / 1000000.0 ;
tsKnobMHz = ( float ) ui - > tuningStepCombo - > itemData ( index ) . toUInt ( ) / 1000000.0 ;
tsWfScrollHz = ui - > tuningStepCombo - > itemData ( index ) . toUInt ( ) ;
tsKnobHz = ui - > tuningStepCombo - > itemData ( index ) . toUInt ( ) ;
}
quint64 wfmain : : roundFrequency ( quint64 frequency , unsigned int tsHz )
{
quint64 rounded = 0 ;
if ( ui - > tuningFloorZerosChk - > isChecked ( ) )
{
rounded = ( ( frequency % tsHz ) > tsHz / 2 ) ? frequency + tsHz - frequency % tsHz : frequency - frequency % tsHz ;
return rounded ;
} else {
return frequency ;
}
2021-02-22 07:58:23 +00:00
}
2021-03-22 07:11:43 +00:00
quint64 wfmain : : roundFrequencyWithStep ( quint64 frequency , int steps , unsigned int tsHz )
2021-02-22 07:58:23 +00:00
{
2021-03-22 07:11:43 +00:00
quint64 rounded = 0 ;
if ( steps > 0 )
{
frequency = frequency + ( quint64 ) ( steps * tsHz ) ;
} else {
frequency = frequency - ( quint64 ) ( abs ( steps ) * tsHz ) ;
}
if ( ui - > tuningFloorZerosChk - > isChecked ( ) )
{
rounded = ( ( frequency % tsHz ) > tsHz / 2 ) ? frequency + tsHz - frequency % tsHz : frequency - frequency % tsHz ;
return rounded ;
} else {
return frequency ;
}
2021-02-22 07:58:23 +00:00
}
2019-02-04 05:51:30 +00:00
void wfmain : : shortcutMinus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , - 1 , tsPlusHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
2019-02-04 05:51:30 +00:00
}
void wfmain : : shortcutPlus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , 1 , tsPlusHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , - 1 , tsPlusShiftHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
2019-02-04 18:32:16 +00:00
}
void wfmain : : shortcutShiftPlus ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , 1 , tsPlusShiftHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , - 1 , tsPlusControlHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = roundFrequencyWithStep ( freq . Hz , 1 , tsPlusControlHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = freq . Hz + tsPageHz ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
2020-03-17 22:15:01 +00:00
}
void wfmain : : shortcutPageDown ( )
{
2021-02-22 07:58:23 +00:00
if ( freqLock ) return ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = freq . Hz - tsPageHz ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
setUIFreq ( ) ;
emit setFrequency ( f ) ;
issueDelayedCommandUnique ( 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 ( ) ;
}
2021-03-22 07:11:43 +00:00
void wfmain : : setUIFreq ( double frequency )
{
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( frequency , 0 , ' f ' ) ) ;
}
void wfmain : : setUIFreq ( )
{
// Call this function, without arguments, if you know that the
// freqMhz variable is already set correctly.
setUIFreq ( freq . MHzDouble ) ;
}
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
2021-05-15 22:34:22 +00:00
if ( rigCaps . hasSpectrum )
{
cmdOutQue . append ( cmdDispEnable ) ;
cmdOutQue . append ( cmdSpecOn ) ;
}
2021-02-19 08:14:40 +00:00
cmdOutQue . append ( cmdGetModInput ) ;
cmdOutQue . append ( cmdGetModDataInput ) ;
2021-04-07 05:06:08 +00:00
if ( rigCaps . hasCTCSS )
{
cmdOutQue . append ( cmdGetTone ) ;
cmdOutQue . append ( cmdGetTSQL ) ;
}
if ( rigCaps . hasDTCS )
{
cmdOutQue . append ( cmdGetDTCS ) ;
}
cmdOutQue . append ( cmdGetRptAccessMode ) ;
2021-04-10 07:21:58 +00:00
if ( rigCaps . hasAntennaSel )
{
cmdOutQue . append ( cmdGetAntenna ) ;
}
if ( rigCaps . hasAttenuator )
{
cmdOutQue . append ( cmdGetAttenuator ) ;
}
if ( rigCaps . hasPreamp )
{
cmdOutQue . append ( cmdGetPreamp ) ;
}
2021-04-07 05:06:08 +00:00
2021-04-25 07:23:52 +00:00
cmdOutQue . append ( cmdGetRitEnabled ) ;
cmdOutQue . append ( cmdGetRitValue ) ;
2021-05-15 22:34:22 +00:00
if ( rigCaps . hasSpectrum )
{
cmdOutQue . append ( cmdGetSpectrumMode ) ;
cmdOutQue . append ( cmdGetSpectrumSpan ) ;
}
2021-04-11 07:42:25 +00:00
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-03-13 10:20:48 +00:00
# ifndef Q_OS_LINUX
2021-02-24 22:55:29 +00:00
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 ) ;
2021-04-27 06:40:08 +00:00
defaultColors . Dark_PeakPlotLine = QColor ( Qt : : yellow ) ;
2021-05-15 00:09:27 +00:00
defaultColors . Dark_TuningLine = QColor ( Qt : : cyan ) ;
2018-11-25 06:21:36 +00:00
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 ) ;
2021-04-27 06:40:08 +00:00
defaultColors . Light_PeakPlotLine = QColor ( Qt : : blue ) ;
defaultColors . Light_TuningLine = QColor ( Qt : : blue ) ;
2018-11-25 06:21:36 +00:00
}
2018-06-22 23:31:52 +00:00
void wfmain : : setPlotTheme ( QCustomPlot * plot , bool isDark )
{
if ( isDark )
{
2021-04-27 06:40:08 +00:00
plot - > setBackground ( prefs . colorScheme . Dark_PlotBackground ) ;
//plot->setBackground(QColor(0,0,0,255));
plot - > xAxis - > grid ( ) - > setPen ( prefs . colorScheme . Dark_PlotAxisPen ) ;
plot - > yAxis - > grid ( ) - > setPen ( prefs . colorScheme . Dark_PlotAxisPen ) ;
plot - > legend - > setTextColor ( prefs . colorScheme . Dark_PlotLegendTextColor ) ;
plot - > legend - > setBorderPen ( prefs . colorScheme . Dark_PlotLegendBorderPen ) ;
plot - > legend - > setBrush ( prefs . colorScheme . Dark_PlotLegendBrush ) ;
plot - > xAxis - > setTickLabelColor ( prefs . colorScheme . Dark_PlotTickLabel ) ;
plot - > xAxis - > setLabelColor ( prefs . colorScheme . Dark_PlotTickLabel ) ;
plot - > yAxis - > setTickLabelColor ( prefs . colorScheme . Dark_PlotTickLabel ) ;
plot - > yAxis - > setLabelColor ( prefs . colorScheme . Dark_PlotTickLabel ) ;
plot - > xAxis - > setBasePen ( prefs . colorScheme . Dark_PlotBasePen ) ;
plot - > xAxis - > setTickPen ( prefs . colorScheme . Dark_PlotTickPen ) ;
plot - > yAxis - > setBasePen ( prefs . colorScheme . Dark_PlotBasePen ) ;
plot - > yAxis - > setTickPen ( prefs . colorScheme . Dark_PlotTickPen ) ;
plot - > graph ( 0 ) - > setPen ( prefs . colorScheme . Dark_PeakPlotLine ) ;
freqIndicatorLine - > setPen ( prefs . colorScheme . Dark_TuningLine ) ;
2018-06-22 23:31:52 +00:00
} else {
2018-06-23 07:31:41 +00:00
//color = ui->groupBox->palette().color(QPalette::Button);
2021-04-27 06:40:08 +00:00
plot - > setBackground ( prefs . colorScheme . Light_PlotBackground ) ;
plot - > xAxis - > grid ( ) - > setPen ( prefs . colorScheme . Light_PlotAxisPen ) ;
plot - > yAxis - > grid ( ) - > setPen ( prefs . colorScheme . Light_PlotAxisPen ) ;
plot - > legend - > setTextColor ( prefs . colorScheme . Light_PlotLegendTextColor ) ;
plot - > legend - > setBorderPen ( prefs . colorScheme . Light_PlotLegendBorderPen ) ;
plot - > legend - > setBrush ( prefs . colorScheme . Light_PlotLegendBrush ) ;
plot - > xAxis - > setTickLabelColor ( prefs . colorScheme . Light_PlotTickLabel ) ;
plot - > xAxis - > setLabelColor ( prefs . colorScheme . Light_PlotTickLabel ) ;
plot - > yAxis - > setTickLabelColor ( prefs . colorScheme . Light_PlotTickLabel ) ;
plot - > yAxis - > setLabelColor ( prefs . colorScheme . Light_PlotTickLabel ) ;
plot - > xAxis - > setBasePen ( prefs . colorScheme . Light_PlotBasePen ) ;
plot - > xAxis - > setTickPen ( prefs . colorScheme . Light_PlotTickPen ) ;
plot - > yAxis - > setBasePen ( prefs . colorScheme . Light_PlotBasePen ) ;
plot - > yAxis - > setTickPen ( prefs . colorScheme . Light_PlotTickLabel ) ;
plot - > graph ( 0 ) - > setPen ( prefs . colorScheme . Light_PeakPlotLine ) ;
freqIndicatorLine - > setPen ( prefs . colorScheme . Light_TuningLine ) ;
2018-06-22 23:31:52 +00:00
}
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-05-15 17:53:16 +00:00
// qInfo(logSystem()) << "Sending query for data mode";
2021-02-21 04:41:19 +00:00
emit getDataMode ( ) ;
break ;
case cmdSetDataModeOff :
2021-05-09 06:46:44 +00:00
emit setDataMode ( false , ( unsigned char ) ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ) ;
2021-02-21 04:41:19 +00:00
break ;
case cmdSetDataModeOn :
2021-05-09 06:46:44 +00:00
emit setDataMode ( true , ( unsigned char ) ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ) ;
2021-02-21 04:41:19 +00:00
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-05-15 17:53:16 +00:00
//qInfo(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 :
2018-06-25 07:34:33 +00:00
emit getDataMode ( ) ;
2018-06-23 07:31:41 +00:00
break ;
2021-05-07 22:46:47 +00:00
case cmdSetModeFilter :
emit setMode ( setModeVal , setFilterVal ) ;
break ;
2018-11-07 23:54:03 +00:00
case cmdSetDataModeOff :
2021-05-09 06:46:44 +00:00
emit setDataMode ( false , ( unsigned char ) ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ) ;
2018-11-07 23:54:03 +00:00
break ;
case cmdSetDataModeOn :
2021-05-09 06:46:44 +00:00
emit setDataMode ( true , ( unsigned char ) ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ) ;
2018-11-07 23:54:03 +00:00
break ;
2021-04-25 07:23:52 +00:00
case cmdGetRitEnabled :
emit getRitEnabled ( ) ;
break ;
case cmdGetRitValue :
emit getRitValue ( ) ;
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 ;
2021-04-07 05:06:08 +00:00
case cmdGetTone :
emit getTone ( ) ;
break ;
case cmdGetTSQL :
emit getTSQL ( ) ;
break ;
2021-04-10 07:21:58 +00:00
case cmdGetDTCS :
emit getDTCS ( ) ;
break ;
2021-04-07 05:06:08 +00:00
case cmdGetRptAccessMode :
emit getRptAccessMode ( ) ;
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 ;
2021-04-11 07:42:25 +00:00
case cmdGetSpectrumSpan :
emit getScopeSpan ( ) ;
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-04-10 07:21:58 +00:00
case cmdGetAttenuator :
emit getAttenuator ( ) ;
break ;
case cmdGetPreamp :
emit getPreamp ( ) ;
break ;
case cmdGetAntenna :
emit getAntenna ( ) ;
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 ;
2021-04-24 06:11:54 +00:00
case cmdQueNormalSpeed :
2021-05-01 05:15:30 +00:00
if ( usingLAN )
{
delayedCommand - > setInterval ( delayedCmdIntervalLAN_ms ) ;
} else {
delayedCommand - > setInterval ( delayedCmdIntervalSerial_ms ) ;
}
2021-04-24 06:11:54 +00:00
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
2021-03-22 07:11:43 +00:00
void wfmain : : issueDelayedCommandUnique ( cmds cmd )
{
// Use this function to insert commands where
// multiple (redundant) commands don't make sense.
if ( ! cmdOutQue . contains ( cmd ) )
{
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-05-18 07:29:06 +00:00
showStatusBarText ( QString ( " Found radio at address 0x%1 of name %2 and model ID %3. " ) . arg ( rigCaps . civ , 2 , 16 ) . arg ( rigCaps . modelName ) . arg ( rigCaps . modelID ) ) ;
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-05-15 17:53:16 +00:00
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-04-07 05:26:08 +00:00
rpt - > setRig ( rigCaps ) ;
2021-02-13 06:42:34 +00:00
2021-05-22 06:46:15 +00:00
// Set the mode combo box up:
2021-02-13 06:42:34 +00:00
2021-05-22 06:46:15 +00:00
ui - > modeSelectCombo - > blockSignals ( true ) ;
ui - > modeSelectCombo - > clear ( ) ;
2021-02-13 06:42:34 +00:00
2021-05-22 06:46:15 +00:00
for ( unsigned int i = 0 ; i < rigCaps . modes . size ( ) ; i + + )
2021-05-01 07:54:42 +00:00
{
2021-05-22 06:46:15 +00:00
ui - > modeSelectCombo - > addItem ( rigCaps . modes . at ( i ) . name ,
rigCaps . modes . at ( i ) . reg ) ;
2021-05-01 18:54:43 +00:00
}
2021-05-01 07:54:42 +00:00
2021-05-22 06:46:15 +00:00
ui - > modeSelectCombo - > blockSignals ( false ) ;
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 ;
2021-03-06 09:07:23 +00:00
// Clear input combos before adding known inputs.
2021-03-06 09:14:28 +00:00
ui - > modInputCombo - > clear ( ) ;
ui - > modInputDataCombo - > clear ( ) ;
2021-03-06 09:07:23 +00:00
2021-02-19 08:14:40 +00:00
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-04-08 06:35:24 +00:00
ui - > attSelCombo - > clear ( ) ;
2021-04-09 22:57:16 +00:00
if ( rigCaps . hasAttenuator )
2021-04-08 06:35:24 +00:00
{
2021-04-09 22:57:16 +00:00
ui - > attSelCombo - > setDisabled ( false ) ;
for ( unsigned int i = 0 ; i < rigCaps . attenuators . size ( ) ; i + + )
{
inName = ( i = = 0 ) ? QString ( " 0dB " ) : QString ( " -%1 dB " ) . arg ( rigCaps . attenuators . at ( i ) , 0 , 16 ) ;
ui - > attSelCombo - > addItem ( inName , rigCaps . attenuators . at ( i ) ) ;
}
} else {
ui - > attSelCombo - > setDisabled ( true ) ;
2021-04-08 06:35:24 +00:00
}
2021-04-09 22:57:16 +00:00
ui - > preampSelCombo - > clear ( ) ;
if ( rigCaps . hasPreamp )
2021-04-09 17:04:20 +00:00
{
2021-04-09 22:57:16 +00:00
ui - > preampSelCombo - > setDisabled ( false ) ;
for ( unsigned int i = 0 ; i < rigCaps . preamps . size ( ) ; i + + )
{
inName = ( i = = 0 ) ? QString ( " Disabled " ) : QString ( " Pre #%1 " ) . arg ( rigCaps . preamps . at ( i ) , 0 , 16 ) ;
ui - > preampSelCombo - > addItem ( inName , rigCaps . preamps . at ( i ) ) ;
}
} else {
ui - > preampSelCombo - > setDisabled ( true ) ;
2021-04-09 17:04:20 +00:00
}
2021-04-09 22:57:16 +00:00
ui - > antennaSelCombo - > clear ( ) ;
if ( rigCaps . hasAntennaSel )
{
ui - > antennaSelCombo - > setDisabled ( false ) ;
for ( unsigned int i = 0 ; i < rigCaps . antennas . size ( ) ; i + + )
{
2021-05-04 17:00:28 +00:00
inName = QString ( " %1 " ) . arg ( rigCaps . antennas . at ( i ) + 1 , 0 , 16 ) ; // adding 1 to have the combobox start with ant 1 insted of 0
2021-04-09 22:57:16 +00:00
ui - > antennaSelCombo - > addItem ( inName , rigCaps . antennas . at ( i ) ) ;
}
} else {
ui - > antennaSelCombo - > setDisabled ( true ) ;
}
2021-04-09 17:04:20 +00:00
2021-04-27 01:24:28 +00:00
setBandButtons ( ) ;
2021-04-08 06:35:24 +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
}
}
2021-03-22 07:11:43 +00:00
void wfmain : : receiveFreq ( freqt freqStruct )
2018-06-19 19:58:52 +00:00
{
2021-03-22 07:11:43 +00:00
2021-05-15 17:53:16 +00:00
//qInfo(logSystem()) << "HEY WE GOT A Frequency: " << freqMhz;
2021-03-22 07:11:43 +00:00
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( freqStruct . MHzDouble , 0 , ' f ' ) ) ;
freq = freqStruct ;
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-05-15 17:53:16 +00:00
//qInfo(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-23 21:21:22 +00:00
qDebug ( logSystem ( ) ) < < " Spectrum received, but RigID incomplete. " ;
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-05-15 17:53:16 +00:00
//qInfo(logSystem()) << "start: " << startFreq << " end: " << endFreq;
2018-06-19 19:58:52 +00:00
quint16 specLen = spectrum . length ( ) ;
2021-05-15 17:53:16 +00:00
//qInfo(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-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. " ;
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;
2021-03-03 10:34:56 +00:00
y [ i ] = ( unsigned char ) spectrum . at ( i ) ;
2018-06-19 19:58:52 +00:00
if ( drawPeaks )
{
2021-03-03 10:36:43 +00:00
if ( ( unsigned char ) spectrum . at ( i ) > ( unsigned char ) spectrumPeaks . at ( i ) )
2018-06-19 19:58:52 +00:00
{
spectrumPeaks [ i ] = spectrum . at ( i ) ;
}
2021-03-03 10:36:43 +00:00
y2 [ i ] = ( unsigned char ) spectrumPeaks . at ( i ) ;
2018-06-19 19:58:52 +00:00
}
}
2021-05-31 06:26:36 +00:00
if ( ! spectrumDrawLock )
2018-06-19 19:58:52 +00:00
{
2021-05-31 06:26:36 +00:00
//ui->qcp->addGraph();
plot - > graph ( 0 ) - > setData ( x , y ) ;
if ( ( freq . MHzDouble < endFreq ) & & ( freq . MHzDouble > startFreq ) )
2018-06-19 19:58:52 +00:00
{
2021-05-31 06:26:36 +00:00
freqIndicatorLine - > start - > setCoords ( freq . MHzDouble , 0 ) ;
freqIndicatorLine - > end - > setCoords ( freq . MHzDouble , 160 ) ;
2018-06-19 19:58:52 +00:00
}
2021-05-31 06:26:36 +00:00
if ( drawPeaks )
2018-06-19 19:58:52 +00:00
{
2021-05-31 06:26:36 +00:00
plot - > graph ( 1 ) - > setData ( x , y2 ) ; // peaks
2018-06-19 19:58:52 +00:00
}
2021-05-31 06:26:36 +00:00
plot - > yAxis - > setRange ( 0 , rigCaps . spectAmpMax + 1 ) ;
plot - > xAxis - > setRange ( startFreq , endFreq ) ;
plot - > replot ( ) ;
2018-06-19 19:58:52 +00:00
2021-05-31 06:26:36 +00:00
if ( specLen = = spectWidth )
2018-06-19 19:58:52 +00:00
{
2021-05-31 06:26:36 +00:00
wfimage . prepend ( spectrum ) ;
if ( wfimage . length ( ) > wfLength )
2018-06-19 19:58:52 +00:00
{
2021-05-31 06:26:36 +00:00
wfimage . remove ( wfLength ) ;
2018-06-19 19:58:52 +00:00
}
2021-05-31 06:26:36 +00:00
// Waterfall:
for ( int row = 0 ; row < wfLength ; row + + )
{
for ( int col = 0 ; col < spectWidth ; col + + )
{
colorMap - > data ( ) - > setCell ( col , row , wfimage . at ( row ) . at ( col ) ) ;
}
2018-06-19 19:58:52 +00:00
}
2021-05-31 06:26:36 +00:00
wf - > yAxis - > setRange ( 0 , wfLength - 1 ) ;
wf - > xAxis - > setRange ( 0 , spectWidth - 1 ) ;
wf - > replot ( ) ;
}
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 ;
2021-03-22 07:11:43 +00:00
freqt freq ;
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 ( ) ) ;
2021-03-22 07:11:43 +00:00
freq . Hz = x * 1E6 ;
2021-05-02 05:30:45 +00:00
freq . Hz = roundFrequency ( freq . Hz , tsWfScrollHz ) ;
2021-03-22 07:11:43 +00:00
emit setFrequency ( freq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt freq ;
2018-06-19 19:58:52 +00:00
//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 ( ) ) ;
2021-03-22 07:11:43 +00:00
freq . Hz = x * 1E6 ;
2021-05-02 05:30:45 +00:00
freq . Hz = roundFrequency ( freq . Hz , tsWfScrollHz ) ;
2021-03-22 07:11:43 +00:00
emit setFrequency ( freq ) ;
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 ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = 0 ;
f . MHzDouble = 0 ;
2021-02-27 01:32:06 +00:00
int clicks = we - > angleDelta ( ) . y ( ) / 120 ;
2021-03-22 07:11:43 +00:00
if ( ! clicks )
return ;
unsigned int stepsHz = tsWfScrollHz ;
2021-02-02 09:05:59 +00:00
2020-04-21 04:23:34 +00:00
Qt : : KeyboardModifiers key = we - > modifiers ( ) ;
2021-03-22 07:11:43 +00:00
if ( ( key = = Qt : : ShiftModifier ) & & ( stepsHz ! = 1 ) )
2020-04-21 04:23:34 +00:00
{
2021-03-22 07:11:43 +00:00
stepsHz / = 10 ;
2020-04-21 04:23:34 +00:00
} else if ( key = = Qt : : ControlModifier )
{
2021-03-22 07:11:43 +00:00
stepsHz * = 10 ;
2020-04-21 04:23:34 +00:00
}
2021-03-22 07:11:43 +00:00
f . Hz = roundFrequencyWithStep ( freq . Hz , clicks , stepsHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
freq = f ;
emit setFrequency ( f ) ;
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( f . MHzDouble , 0 , ' f ' ) ) ;
issueDelayedCommandUnique ( cmdGetFreq ) ;
2020-04-21 04:10:20 +00:00
}
void wfmain : : handlePlotScroll ( QWheelEvent * we )
{
2021-03-22 07:11:43 +00:00
handleWFScroll ( we ) ;
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-05-15 17:53:16 +00:00
//qInfo(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-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < __func__ < < " Invalid mode " < < mode < < " received. " ;
2021-02-13 07:35:17 +00:00
}
if ( ! found )
{
2021-05-15 17:53:16 +00:00
qInfo ( 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 ( )
{
2021-03-22 07:11:43 +00:00
freqt f ;
2018-06-19 19:58:52 +00:00
bool ok = false ;
2021-04-07 04:00:47 +00:00
double freq = 0 ;
int KHz = 0 ;
if ( ui - > freqMhzLineEdit - > text ( ) . contains ( " . " ) )
2018-06-19 19:58:52 +00:00
{
2021-04-07 04:00:47 +00:00
freq = ui - > freqMhzLineEdit - > text ( ) . toDouble ( & ok ) ;
if ( ok )
{
f . Hz = freq * 1E6 ;
emit setFrequency ( f ) ;
issueDelayedCommand ( cmdGetFreq ) ;
}
} else {
KHz = ui - > freqMhzLineEdit - > text ( ) . toInt ( & ok ) ;
if ( ok )
{
f . Hz = KHz * 1E3 ;
emit setFrequency ( f ) ;
issueDelayedCommand ( cmdGetFreq ) ;
}
2018-06-19 19:58:52 +00:00
}
2021-04-07 04:00:47 +00:00
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.
2021-05-20 18:24:40 +00:00
// 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 ( ) ;
2021-05-09 06:46:44 +00:00
emit setMode ( ( unsigned char ) mode , ( unsigned char ) filter ) ;
2021-04-27 01:24:28 +00:00
currentMode = mode ;
2021-02-17 06:32:05 +00:00
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-05-15 17:53:16 +00:00
//qInfo(logSystem()) << __func__ << " at index " << index << " has newMode: " << newMode;
2021-04-27 01:24:28 +00:00
currentMode = ( mode_kind ) 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 ( ) ;
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = 0 ;
f . MHzDouble = 0 ;
2018-07-04 00:20:03 +00:00
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 ;
}
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 ;
2021-03-13 07:15:31 +00:00
// now calculate the direction:
2018-07-04 00:20:03 +00:00
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 ;
}
2021-03-22 07:11:43 +00:00
// With the number of steps and direction of steps established,
// we can now adjust the frequeny:
2018-07-04 00:20:03 +00:00
2021-03-22 07:11:43 +00:00
f . Hz = roundFrequencyWithStep ( freq . Hz , delta , tsKnobHz ) ;
f . MHzDouble = f . Hz / ( double ) 1E6 ;
2021-05-02 06:02:27 +00:00
if ( f . Hz > 0 )
{
freq = f ;
2018-07-04 00:20:03 +00:00
2021-05-02 06:02:27 +00:00
oldFreqDialVal = value ;
2018-07-04 00:20:03 +00:00
2021-05-02 06:02:27 +00:00
ui - > freqLabel - > setText ( QString ( " %1 " ) . arg ( f . MHzDouble , 0 , ' f ' ) ) ;
2018-07-04 00:20:03 +00:00
2021-05-02 06:02:27 +00:00
emit setFrequency ( f ) ;
} else {
ui - > freqDial - > blockSignals ( true ) ;
ui - > freqDial - > setValue ( oldFreqDialVal ) ;
ui - > freqDial - > blockSignals ( false ) ;
return ;
}
2018-06-25 07:34:33 +00:00
}
2018-11-16 22:08:21 +00:00
2021-05-07 21:52:19 +00:00
void wfmain : : receiveBandStackReg ( freqt freq , char mode , char filter , bool dataOn )
2018-11-16 22:08:21 +00:00
{
// read the band stack and apply by sending out commands
2021-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < __func__ < < " BSR received into main: Freq: " < < freq . Hz < < " , mode: " < < ( unsigned int ) mode < < " , filter: " < < ( unsigned int ) filter < < " , data mode: " < < dataOn ;
2021-05-07 22:46:47 +00:00
emit setFrequency ( freq ) ;
setModeVal = ( unsigned char ) mode ;
setFilterVal = ( unsigned char ) filter ;
issueDelayedCommand ( cmdSetModeFilter ) ;
2018-11-16 22:08:21 +00:00
if ( dataOn )
{
2021-05-07 22:46:47 +00:00
issueDelayedCommand ( cmdSetDataModeOn ) ;
2018-11-16 22:08:21 +00:00
} else {
2021-05-07 22:46:47 +00:00
issueDelayedCommand ( cmdSetDataModeOff ) ;
2018-11-16 22:08:21 +00:00
}
2021-05-07 22:46:47 +00:00
issueDelayedCommand ( cmdGetFreq ) ;
issueDelayedCommand ( cmdGetMode ) ;
2018-11-16 22:08:21 +00:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2021-05-07 22:46:47 +00:00
receiveMode ( ( unsigned char ) mode , ( unsigned char ) filter ) ; // update UI
2018-11-16 22:08:21 +00:00
}
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 ) ;
}
2021-04-27 01:24:28 +00:00
void wfmain : : on_band23cmbtn_clicked ( )
{
bandStkBand = rigCaps . bsr [ band23cm ] ; // 23cm
bandStackBtnClick ( ) ;
}
void wfmain : : on_band70cmbtn_clicked ( )
{
bandStkBand = rigCaps . bsr [ band70cm ] ; // 70cm
bandStackBtnClick ( ) ;
}
void wfmain : : on_band2mbtn_clicked ( )
{
bandStkBand = rigCaps . bsr [ band2m ] ; // 2m
bandStackBtnClick ( ) ;
}
2021-04-28 03:18:17 +00:00
void wfmain : : on_bandAirbtn_clicked ( )
{
bandStkBand = rigCaps . bsr [ bandAir ] ; // VHF Aircraft
bandStackBtnClick ( ) ;
}
void wfmain : : on_bandWFMbtn_clicked ( )
{
bandStkBand = rigCaps . bsr [ bandWFM ] ; // Broadcast FM
bandStackBtnClick ( ) ;
}
2021-04-27 01:24:28 +00:00
void wfmain : : on_band4mbtn_clicked ( )
{
// There isn't a BSR for this one:
freqt f ;
if ( ( currentMode = = modeAM ) | | ( currentMode = = modeFM ) )
{
f . Hz = ( 70.260 ) * 1E6 ;
} else {
f . Hz = ( 70.200 ) * 1E6 ;
}
2021-04-27 15:04:33 +00:00
emit setFrequency ( f ) ;
2021-04-27 18:16:50 +00:00
issueDelayedCommandUnique ( cmdGetFreq ) ;
2021-04-27 19:49:31 +00:00
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2021-04-27 01:24:28 +00:00
}
2018-11-16 22:08:21 +00:00
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...
2021-03-22 07:11:43 +00:00
freqt f ;
f . Hz = ( 5.3305 ) * 1E6 ;
2021-04-27 15:04:33 +00:00
emit setFrequency ( f ) ;
2021-04-28 03:48:05 +00:00
issueDelayedCommandUnique ( cmdGetFreq ) ;
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2018-11-16 22:08:21 +00:00
}
void wfmain : : on_band80mbtn_clicked ( )
{
bandStkBand = 0x02 ; // 80 meters
bandStackBtnClick ( ) ;
}
void wfmain : : on_band160mbtn_clicked ( )
{
bandStkBand = 0x01 ; // 160 meters
bandStackBtnClick ( ) ;
}
2021-04-27 01:24:28 +00:00
void wfmain : : on_band630mbtn_clicked ( )
{
freqt f ;
f . Hz = 475 * 1E3 ;
2021-04-27 15:04:33 +00:00
emit setFrequency ( f ) ;
2021-04-28 03:48:05 +00:00
issueDelayedCommandUnique ( cmdGetFreq ) ;
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2021-04-27 01:24:28 +00:00
}
void wfmain : : on_band2200mbtn_clicked ( )
{
freqt f ;
f . Hz = 136 * 1E3 ;
2021-04-27 15:04:33 +00:00
emit setFrequency ( f ) ;
2021-04-28 03:48:05 +00:00
issueDelayedCommandUnique ( cmdGetFreq ) ;
ui - > tabWidget - > setCurrentIndex ( 0 ) ;
2021-04-27 01:24:28 +00:00
}
2018-11-16 22:08:21 +00:00
void wfmain : : on_bandGenbtn_clicked ( )
{
// "GENE" general coverage frequency outside the ham bands
// which does probably include any 60 meter frequencies used.
2021-04-27 01:24:28 +00:00
bandStkBand = rigCaps . bsr [ bandGen ] ; // GEN
2018-11-16 22:08:21 +00:00
bandStackBtnClick ( ) ;
}
void wfmain : : on_aboutBtn_clicked ( )
{
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 " ) ;
2021-05-20 04:09:08 +00:00
QString doctest = QString ( " <br/><br/>Testing, documentation, bug fixes, and development mentorship from<br/>Roeland Jansen, PA3MET, and Jim Nijkamp, PA8E. " ) ;
QString ssCredit = QString ( " <br/><br/>Stylesheet <a href= \" https://github.com/ColinDuquesnoy/QDarkStyleSheet/tree/master/qdarkstyle \" style= \" color: cyan; \" >qdarkstyle</a> used under MIT license, stored in /usr/share/wfview/stylesheets/. " ) ;
QString rsCredit = QString ( " <br/><br/><a href= \" https://www.speex.org/ \" style= \" color: cyan; \" >Speex</a> Resample library Copyright 2003-2008 Jean-Marc Valin " ) ;
QString website = QString ( " <br/><br/>Please visit <a href= \" https://wfview.org/ \" style= \" color: cyan; \" >https://wfview.org/</a> for the latest information. " ) ;
QString docs = QString ( " <br/><br/>Be sure to check the <a href= \" https://wfview.org/wfview-user-manual/ \" style= \" color: cyan; \" >User Manual</a> and <a href= \" https://forum.wfview.org/ \" style= \" color: cyan; \" >the Forum</a> if you have any questions. " ) ;
QString gitcodelink = QString ( " <a href= \" https://gitlab.com/eliggett/wfview/-/tree/%1 \" style= \" color: cyan; \" > " ) . arg ( GITSHORT ) ;
2021-02-14 07:42:51 +00:00
QString contact = QString ( " <br/>email the author: kilocharlie8@gmail.com or W6EL on the air! " ) ;
2021-05-20 04:09:08 +00:00
QString buildInfo = QString ( " <br/><br/>Build " + gitcodelink + QString ( GITSHORT ) + " </a> 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-05-20 04:09:08 +00:00
QString aboutText = head + copyright + " \n " + nacode + " \n " + doctest + " \n " + ssCredit + " \n " + rsCredit + " \n " ;
2021-02-14 07:42:51 +00:00
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
2021-05-20 04:09:56 +00:00
volatile QString sxcreditcopyright = QString ( " Speex copyright notice: \
2021-05-20 04:09:08 +00:00
Copyright ( C ) 2003 Jean - Marc Valin \ n \
Redistribution and use in source and binary forms , with or without \
modification , are permitted provided that the following conditions \
are met : \ n \
- Redistributions of source code must retain the above copyright \
notice , this list of conditions and the following disclaimer . \ n \
- Redistributions in binary form must reproduce the above copyright \
notice , this list of conditions and the following disclaimer in the \
documentation and / or other materials provided with the distribution . \ n \
- Neither the name of the Xiph . org Foundation nor the names of its \
contributors may be used to endorse or promote products derived from \
this software without specific prior written permission . \ n \
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \
` ` AS IS ' ' AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT \
LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \
A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE FOUNDATION OR \
CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , \
EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , \
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR \
PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF \
LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING \
NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS \
SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE . " );
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 ;
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
2021-05-08 05:37:28 +00:00
mem . setPreset ( preset_number , freq . MHzDouble , ( mode_kind ) ui - > modeSelectCombo - > currentData ( ) . toInt ( ) ) ;
2021-03-22 07:11:43 +00:00
showStatusBarText ( QString ( " Storing frequency %1 to memory location %2 " ) . arg ( freq . MHzDouble ) . 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 ) ;
2021-05-08 05:37:28 +00:00
// TODO: change to int hz
// TODO: store filter setting as well.
2018-11-24 08:10:05 +00:00
freqString = QString ( " %1 " ) . arg ( temp . frequency ) ;
ui - > freqMhzLineEdit - > setText ( freqString ) ;
ui - > goFreqBtn - > click ( ) ;
2021-05-08 05:37:28 +00:00
setModeVal = temp . mode ;
setFilterVal = ui - > modeFilterCombo - > currentIndex ( ) + 1 ; // TODO, add to memory
issueDelayedCommand ( cmdSetModeFilter ) ;
issueDelayedCommand ( cmdGetFreq ) ;
issueDelayedCommand ( cmdGetMode ) ;
2018-11-24 08:10:05 +00:00
} else {
2021-05-15 17:53:16 +00:00
qInfo ( 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-05-15 17:53:16 +00:00
// qInfo(logSystem()) << "Setting AF gain to " << value;
2021-03-22 18:53:34 +00:00
emit setAfGain ( ( unsigned char ) value ) ;
2018-11-17 06:19:44 +00:00
}
void wfmain : : receiveRfGain ( unsigned char level )
{
2021-05-15 17:53:16 +00:00
// qInfo(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-05-15 17:53:16 +00:00
// qInfo(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_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-05-15 17:53:16 +00:00
// qInfo(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-05-15 17:53:16 +00:00
// qInfo(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-05-15 17:53:16 +00:00
qInfo ( 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-03-03 05:55:33 +00:00
void wfmain : : on_serialEnableBtn_clicked ( bool checked )
{
prefs . enableLAN = ! checked ;
ui - > serialDeviceListCombo - > setEnabled ( checked ) ;
2021-05-31 06:26:36 +00:00
ui - > connectBtn - > setEnabled ( true ) ;
2021-03-03 05:55:33 +00:00
ui - > ipAddressTxt - > setEnabled ( ! checked ) ;
ui - > controlPortTxt - > setEnabled ( ! checked ) ;
ui - > usernameTxt - > setEnabled ( ! checked ) ;
ui - > passwordTxt - > setEnabled ( ! checked ) ;
2021-03-22 09:10:03 +00:00
ui - > audioRXCodecCombo - > setEnabled ( ! checked ) ;
ui - > audioTXCodecCombo - > setEnabled ( ! checked ) ;
ui - > audioSampleRateCombo - > setEnabled ( ! checked ) ;
ui - > rxLatencySlider - > setEnabled ( ! checked ) ;
ui - > txLatencySlider - > setEnabled ( ! checked ) ;
ui - > rxLatencyValue - > setEnabled ( ! checked ) ;
ui - > txLatencyValue - > setEnabled ( ! checked ) ;
2021-05-20 04:36:34 +00:00
ui - > baudRateCombo - > setEnabled ( checked ) ;
ui - > serialDeviceListCombo - > setEnabled ( checked ) ;
2021-05-23 20:43:15 +00:00
//ui->udpServerSetupBtn->setEnabled(true);
2021-03-03 05:55:33 +00:00
}
void wfmain : : on_lanEnableBtn_clicked ( bool checked )
2021-02-03 19:36:35 +00:00
{
prefs . enableLAN = checked ;
2021-05-31 06:26:36 +00:00
ui - > connectBtn - > setEnabled ( true ) ;
2021-02-05 04:54:34 +00:00
ui - > ipAddressTxt - > setEnabled ( checked ) ;
ui - > controlPortTxt - > setEnabled ( checked ) ;
ui - > usernameTxt - > setEnabled ( checked ) ;
ui - > passwordTxt - > setEnabled ( checked ) ;
2021-05-20 04:36:34 +00:00
ui - > baudRateCombo - > setEnabled ( ! checked ) ;
ui - > serialDeviceListCombo - > setEnabled ( ! checked ) ;
2021-05-23 20:43:15 +00:00
//ui->udpServerSetupBtn->setEnabled(false);
2021-02-05 04:54:34 +00:00
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 )
{
2021-03-01 19:53:12 +00:00
udpPrefs . ipAddress = text ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_controlPortTxt_textChanged ( QString text )
{
2021-03-01 19:53:12 +00:00
udpPrefs . controlLANPort = text . toUInt ( ) ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_usernameTxt_textChanged ( QString text )
{
2021-03-01 19:53:12 +00:00
udpPrefs . username = text ;
2021-02-03 19:36:35 +00:00
}
void wfmain : : on_passwordTxt_textChanged ( QString text )
{
2021-03-01 19:53:12 +00:00
udpPrefs . password = text ;
2021-02-03 19:36:35 +00:00
}
2021-05-16 20:16:59 +00:00
void wfmain : : on_audioOutputCombo_currentIndexChanged ( int value )
2021-02-04 10:27:30 +00:00
{
2021-06-04 12:47:32 +00:00
# if defined(RTAUDIO)
rxSetup . port = ui - > audioOutputCombo - > itemData ( value ) . toInt ( ) ;
# elif defined(PORTAUDIO)
# else
QVariant v = ui - > audioOutputCombo - > itemData ( value ) ;
rxSetup . port = v . value < QAudioDeviceInfo > ( ) ;
# endif
rxSetup . name = ui - > audioOutputCombo - > itemText ( value ) ;
2021-06-04 13:25:07 +00:00
qDebug ( logGui ( ) ) < < " Changed default audio output to: " < < rxSetup . name ;
2021-02-04 10:27:30 +00:00
}
2021-05-16 20:16:59 +00:00
void wfmain : : on_audioInputCombo_currentIndexChanged ( int value )
2021-02-08 16:53:26 +00:00
{
2021-06-04 12:47:32 +00:00
# if defined(RTAUDIO)
txSetup . port = ui - > audioInputCombo - > itemData ( value ) . toInt ( ) ;
# elif defined(PORTAUDIO)
# else
QVariant v = ui - > audioInputCombo - > itemData ( value ) ;
txSetup . port = v . value < QAudioDeviceInfo > ( ) ;
# endif
txSetup . name = ui - > audioInputCombo - > itemText ( value ) ;
2021-06-04 13:25:07 +00:00
qDebug ( logGui ( ) ) < < " Changed default audio input to: " < < txSetup . name ;
2021-02-08 16:53:26 +00:00
}
void wfmain : : on_audioSampleRateCombo_currentIndexChanged ( QString text )
{
2021-03-01 19:53:12 +00:00
udpPrefs . audioRXSampleRate = text . toInt ( ) ;
udpPrefs . audioTXSampleRate = text . toInt ( ) ;
2021-06-04 07:24:26 +00:00
rxSetup . samplerate = text . toInt ( ) ;
txSetup . samplerate = text . toInt ( ) ;
2021-02-09 12:43:28 +00:00
}
void wfmain : : on_audioRXCodecCombo_currentIndexChanged ( int value )
{
2021-06-04 07:24:26 +00:00
rxSetup . codec = 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-06-04 07:24:26 +00:00
txSetup . codec = 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 )
{
2021-06-04 07:24:26 +00:00
rxSetup . latency = value ;
2021-02-27 00:37:00 +00:00
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-06-04 07:24:26 +00:00
txSetup . latency = value ;
2021-02-27 00:37:00 +00:00
ui - > txLatencyValue - > setText ( QString : : number ( value ) ) ;
2021-02-08 16:53:26 +00:00
}
2021-05-05 13:11:00 +00:00
void wfmain : : on_vspCombo_currentIndexChanged ( int value )
{
Q_UNUSED ( value ) ;
prefs . virtualSerialPort = ui - > vspCombo - > currentText ( ) ;
}
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
2021-05-15 02:49:37 +00:00
if ( ui - > dataModeBtn - > isChecked ( ) )
{
emit setDataMode ( true , ( unsigned char ) filterSelection ) ;
} else {
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 )
{
2021-05-09 06:46:44 +00:00
emit setDataMode ( checked , ( unsigned char ) ui - > modeFilterCombo - > currentData ( ) . toInt ( ) ) ;
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-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < " Could not find modulation input: " < < ( int ) input ;
2021-02-18 07:47:34 +00:00
}
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-05-15 17:53:16 +00:00
qInfo ( 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 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-05-15 17:53:16 +00:00
//qInfo(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-03-07 07:35:46 +00:00
void wfmain : : on_serialDeviceListCombo_activated ( const QString & arg1 )
{
QString manualPort ;
bool ok ;
if ( arg1 = = QString ( " Manual... " ) )
{
manualPort = QInputDialog : : getText ( this , tr ( " Manual port assignment " ) ,
tr ( " Enter serial port assignment: " ) ,
QLineEdit : : Normal ,
tr ( " /dev/device " ) , & ok ) ;
if ( manualPort . isEmpty ( ) | | ! ok )
{
ui - > serialDeviceListCombo - > blockSignals ( true ) ;
ui - > serialDeviceListCombo - > setCurrentIndex ( 0 ) ;
ui - > serialDeviceListCombo - > blockSignals ( false ) ;
return ;
} else {
prefs . serialPortRadio = manualPort ;
showStatusBarText ( " Setting preferences to use manually-assigned serial port: " + manualPort ) ;
ui - > serialEnableBtn - > setChecked ( true ) ;
return ;
}
}
if ( arg1 = = QString ( " Auto " ) )
{
2021-05-08 06:15:24 +00:00
prefs . serialPortRadio = " auto " ;
2021-03-07 07:35:46 +00:00
showStatusBarText ( " Setting preferences to automatically find rig serial port. " ) ;
ui - > serialEnableBtn - > setChecked ( true ) ;
return ;
}
prefs . serialPortRadio = arg1 ;
showStatusBarText ( " Setting preferences to use manually-assigned serial port: " + arg1 ) ;
ui - > serialEnableBtn - > setChecked ( true ) ;
}
2021-03-04 08:02:53 +00:00
2021-03-31 06:37:35 +00:00
void wfmain : : on_rptSetupBtn_clicked ( )
{
rpt - > show ( ) ;
}
2021-04-08 06:35:24 +00:00
void wfmain : : on_attSelCombo_activated ( int index )
{
unsigned char att = ( unsigned char ) ui - > attSelCombo - > itemData ( index ) . toInt ( ) ;
emit setAttenuator ( att ) ;
2021-04-11 05:48:32 +00:00
issueDelayedCommand ( cmdGetPreamp ) ;
2021-04-08 06:35:24 +00:00
}
2021-04-09 17:04:20 +00:00
void wfmain : : on_preampSelCombo_activated ( int index )
{
unsigned char pre = ( unsigned char ) ui - > preampSelCombo - > itemData ( index ) . toInt ( ) ;
emit setPreamp ( pre ) ;
2021-04-11 05:48:32 +00:00
issueDelayedCommand ( cmdGetAttenuator ) ;
2021-04-09 17:04:20 +00:00
}
2021-04-09 22:57:16 +00:00
void wfmain : : on_antennaSelCombo_activated ( int index )
{
unsigned char ant = ( unsigned char ) ui - > antennaSelCombo - > itemData ( index ) . toInt ( ) ;
emit setAntenna ( ant ) ;
}
2021-04-10 06:38:36 +00:00
void wfmain : : on_wfthemeCombo_activated ( int index )
{
colorMap - > setGradient ( static_cast < QCPColorGradient : : GradientPreset > ( ui - > wfthemeCombo - > itemData ( index ) . toInt ( ) ) ) ;
}
2021-04-11 05:48:32 +00:00
void wfmain : : receivePreamp ( unsigned char pre )
{
int preindex = ui - > preampSelCombo - > findData ( pre ) ;
ui - > preampSelCombo - > setCurrentIndex ( preindex ) ;
}
void wfmain : : receiveAttenuator ( unsigned char att )
{
int attindex = ui - > attSelCombo - > findData ( att ) ;
ui - > attSelCombo - > setCurrentIndex ( attindex ) ;
}
2021-04-11 07:42:25 +00:00
void wfmain : : receiveSpectrumSpan ( freqt freqspan , bool isSub )
{
if ( ! isSub )
{
switch ( ( int ) ( freqspan . MHzDouble * 1000000.0 ) )
{
case ( 2500 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 0 ) ;
break ;
case ( 5000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 1 ) ;
break ;
case ( 10000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 2 ) ;
break ;
case ( 25000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 3 ) ;
break ;
case ( 50000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 4 ) ;
break ;
case ( 100000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 5 ) ;
break ;
case ( 250000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 6 ) ;
break ;
case ( 500000 ) :
ui - > scopeBWCombo - > setCurrentIndex ( 7 ) ;
break ;
default :
2021-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < __func__ < < " Could not match: " < < freqspan . MHzDouble < < " to anything like: " < < ( int ) ( freqspan . MHzDouble * 1E6 ) ;
2021-04-11 07:42:25 +00:00
break ;
}
}
}
2021-05-21 15:30:52 +00:00
void wfmain : : receiveBaudRate ( quint32 baud )
{
qInfo ( ) < < " Received serial port baud rate from remote server: " < < baud ;
prefs . serialPortBaud = baud ;
}
2021-04-20 05:55:39 +00:00
void wfmain : : on_rigPowerOnBtn_clicked ( )
{
2021-04-24 06:11:54 +00:00
powerRigOn ( ) ;
2021-04-20 05:55:39 +00:00
}
void wfmain : : on_rigPowerOffBtn_clicked ( )
{
QMessageBox : : StandardButton reply ;
reply = QMessageBox : : question ( this , " Power " , " Power down the radio? " ,
QMessageBox : : Yes | QMessageBox : : No ) ;
if ( reply = = QMessageBox : : Yes ) {
2021-04-24 06:11:54 +00:00
powerRigOff ( ) ;
}
}
void wfmain : : powerRigOn ( )
{
emit sendPowerOn ( ) ;
delayedCommand - > setInterval ( 3000 ) ; // 3 seconds
if ( ui - > scopeEnableWFBtn - > isChecked ( ) )
{
issueDelayedCommand ( cmdDispEnable ) ;
issueDelayedCommand ( cmdQueNormalSpeed ) ;
issueDelayedCommand ( cmdSpecOn ) ;
issueDelayedCommand ( cmdStartRegularPolling ) ; // s-meter, etc
} else {
issueDelayedCommand ( cmdQueNormalSpeed ) ;
2021-04-20 05:55:39 +00:00
}
2021-04-24 06:11:54 +00:00
delayedCommand - > start ( ) ;
}
void wfmain : : powerRigOff ( )
{
periodicPollingTimer - > stop ( ) ;
delayedCommand - > stop ( ) ;
cmdOutQue . clear ( ) ;
emit sendPowerOff ( ) ;
2021-04-20 05:55:39 +00:00
}
2021-04-24 07:31:51 +00:00
void wfmain : : on_ritTuneDial_valueChanged ( int value )
{
emit setRitValue ( value ) ;
}
void wfmain : : on_ritEnableChk_clicked ( bool checked )
{
emit setRitEnable ( checked ) ;
}
2021-04-25 07:23:52 +00:00
void wfmain : : receiveRITStatus ( bool ritEnabled )
{
ui - > ritEnableChk - > blockSignals ( true ) ;
ui - > ritEnableChk - > setChecked ( ritEnabled ) ;
ui - > ritEnableChk - > blockSignals ( false ) ;
}
void wfmain : : receiveRITValue ( int ritValHz )
{
2021-04-27 01:24:28 +00:00
if ( ( ritValHz > - 500 ) & & ( ritValHz < 500 ) )
2021-04-25 07:23:52 +00:00
{
ui - > ritTuneDial - > blockSignals ( true ) ;
ui - > ritTuneDial - > setValue ( ritValHz ) ;
ui - > ritTuneDial - > blockSignals ( false ) ;
} else {
2021-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < " Warning: out of range RIT value received: " < < ritValHz < < " Hz " ;
2021-04-25 07:23:52 +00:00
}
}
2021-04-27 01:24:28 +00:00
void wfmain : : showButton ( QPushButton * btn )
{
btn - > setHidden ( false ) ;
}
void wfmain : : hideButton ( QPushButton * btn )
{
btn - > setHidden ( true ) ;
}
void wfmain : : setBandButtons ( )
{
// Turn off each button first:
hideButton ( ui - > band23cmbtn ) ;
hideButton ( ui - > band70cmbtn ) ;
hideButton ( ui - > band2mbtn ) ;
2021-04-28 03:18:17 +00:00
hideButton ( ui - > bandAirbtn ) ;
hideButton ( ui - > bandWFMbtn ) ;
2021-04-27 01:24:28 +00:00
hideButton ( ui - > band4mbtn ) ;
hideButton ( ui - > band6mbtn ) ;
hideButton ( ui - > band10mbtn ) ;
hideButton ( ui - > band12mbtn ) ;
hideButton ( ui - > band15mbtn ) ;
hideButton ( ui - > band17mbtn ) ;
hideButton ( ui - > band20mbtn ) ;
hideButton ( ui - > band30mbtn ) ;
hideButton ( ui - > band40mbtn ) ;
hideButton ( ui - > band60mbtn ) ;
hideButton ( ui - > band80mbtn ) ;
hideButton ( ui - > band160mbtn ) ;
hideButton ( ui - > band630mbtn ) ;
hideButton ( ui - > band2200mbtn ) ;
hideButton ( ui - > bandGenbtn ) ;
bandType bandSel ;
//for (auto band = rigCaps.bands.begin(); band != rigCaps.bands.end(); ++band) // no worky
for ( unsigned int i = 0 ; i < rigCaps . bands . size ( ) ; i + + )
{
bandSel = rigCaps . bands . at ( i ) ;
switch ( bandSel )
{
case ( band23cm ) :
showButton ( ui - > band23cmbtn ) ;
break ;
case ( band70cm ) :
showButton ( ui - > band70cmbtn ) ;
break ;
case ( band2m ) :
showButton ( ui - > band2mbtn ) ;
break ;
2021-04-28 03:18:17 +00:00
case ( bandAir ) :
showButton ( ui - > bandAirbtn ) ;
break ;
case ( bandWFM ) :
showButton ( ui - > bandWFMbtn ) ;
break ;
2021-04-27 01:24:28 +00:00
case ( band4m ) :
showButton ( ui - > band4mbtn ) ;
break ;
case ( band6m ) :
showButton ( ui - > band6mbtn ) ;
break ;
case ( band10m ) :
showButton ( ui - > band10mbtn ) ;
break ;
case ( band12m ) :
showButton ( ui - > band12mbtn ) ;
break ;
case ( band15m ) :
showButton ( ui - > band15mbtn ) ;
break ;
case ( band17m ) :
showButton ( ui - > band17mbtn ) ;
break ;
case ( band20m ) :
showButton ( ui - > band20mbtn ) ;
break ;
case ( band30m ) :
showButton ( ui - > band30mbtn ) ;
break ;
case ( band40m ) :
showButton ( ui - > band40mbtn ) ;
break ;
case ( band60m ) :
showButton ( ui - > band60mbtn ) ;
break ;
case ( band80m ) :
showButton ( ui - > band80mbtn ) ;
break ;
case ( band160m ) :
showButton ( ui - > band160mbtn ) ;
break ;
case ( band630m ) :
showButton ( ui - > band630mbtn ) ;
break ;
case ( band2200m ) :
showButton ( ui - > band2200mbtn ) ;
break ;
case ( bandGen ) :
showButton ( ui - > bandGenbtn ) ;
break ;
default :
break ;
}
}
}
2021-05-18 07:29:06 +00:00
void wfmain : : on_rigCIVManualAddrChk_clicked ( bool checked )
{
if ( checked )
{
ui - > rigCIVaddrHexLine - > setEnabled ( true ) ;
ui - > rigCIVaddrHexLine - > setText ( QString ( " %1 " ) . arg ( prefs . radioCIVAddr , 2 , 16 ) ) ;
} else {
ui - > rigCIVaddrHexLine - > setText ( " auto " ) ;
ui - > rigCIVaddrHexLine - > setEnabled ( false ) ;
prefs . radioCIVAddr = 0 ; // auto
showStatusBarText ( " Setting radio CI-V address to: 'auto'. Make sure CI-V Transceive is enabled on the radio. " ) ;
}
}
void wfmain : : on_rigCIVaddrHexLine_editingFinished ( )
{
bool okconvert = false ;
unsigned char propCIVAddr = ( unsigned char ) ui - > rigCIVaddrHexLine - > text ( ) . toUInt ( & okconvert , 16 ) ;
2021-05-21 14:56:19 +00:00
if ( okconvert & & ( propCIVAddr < 0xe0 ) & & ( propCIVAddr ! = 0 ) )
2021-05-18 07:29:06 +00:00
{
prefs . radioCIVAddr = propCIVAddr ;
2021-05-30 22:08:22 +00:00
emit setCIVAddr ( propCIVAddr ) ;
2021-05-18 07:29:06 +00:00
showStatusBarText ( QString ( " Setting radio CI-V address to: 0x%1. Press Save Settings to retain. " ) . arg ( propCIVAddr , 2 , 16 ) ) ;
} else {
2021-05-21 22:03:24 +00:00
showStatusBarText ( QString ( " Could not use provided CI-V address. Address must be < 0xE0 " ) ) ;
2021-05-18 07:29:06 +00:00
}
}
2021-05-20 22:17:10 +00:00
void wfmain : : on_baudRateCombo_activated ( int index )
2021-05-20 04:36:34 +00:00
{
bool ok = false ;
quint32 baud = ui - > baudRateCombo - > currentData ( ) . toUInt ( & ok ) ;
if ( ok )
{
prefs . serialPortBaud = baud ;
showStatusBarText ( QString ( " Changed baud rate to %1 bps. Press Save Settings to retain. " ) . arg ( baud ) ) ;
}
2021-05-20 22:17:10 +00:00
( void ) index ;
2021-05-20 04:36:34 +00:00
}
2021-05-18 07:29:06 +00:00
2021-05-31 06:26:36 +00:00
void wfmain : : on_wfLengthSlider_valueChanged ( int value )
{
prepareWf ( value ) ;
}
2021-02-19 08:14:40 +00:00
// --- DEBUG FUNCTION ---
void wfmain : : on_debugBtn_clicked ( )
{
2021-05-15 17:53:16 +00:00
qInfo ( logSystem ( ) ) < < " Debug button pressed. " ;
2021-05-31 06:26:36 +00:00
prepareWf ( 160 ) ;
2021-02-19 08:14:40 +00:00
}