From 5307e65ae7365aadba6c7f702423e27af901a17b Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 20 May 2013 18:33:06 +0000 Subject: [PATCH] Revert to ComboBox for selecting PTT Port. (Straightened out the bizarre ordering of items on the drop-down list.) git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3285 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- devsetup.cpp | 53 ++++++++++++++++++++++++++++++++++++++++---------- devsetup.h | 9 ++++++--- devsetup.ui | 14 +++++++++---- getfile.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++--- getfile.h | 2 +- mainwindow.cpp | 6 +++--- mainwindow.h | 2 +- plotter.cpp | 5 +++-- 8 files changed, 117 insertions(+), 27 deletions(-) diff --git a/devsetup.cpp b/devsetup.cpp index 3aa245ecc..d3901743f 100644 --- a/devsetup.cpp +++ b/devsetup.cpp @@ -36,6 +36,19 @@ void DevSetup::initDlg() char pa_device_name[128]; char pa_device_hostapi[128]; + /* + if(m_firstCall) { + QString t; + for(int i=14; i<100; i++) { + t.sprintf("COM%d",i); + ui.pttComboBox->addItem(t); + } + for(int i=0; i<10; i++) { + m_macro.append(""); + } + m_firstCall=false; + } +*/ k=0; for(id=0; idsetValue(m_idInt); ui.pttMethodComboBox->setCurrentIndex(m_pttMethodIndex); - ui.pttPortEntry->setText(m_pttPort); ui.saveDirEntry->setText(m_saveDir); ui.comboBoxSndIn->setCurrentIndex(m_nDevIn); ui.comboBoxSndOut->setCurrentIndex(m_nDevOut); @@ -148,7 +160,9 @@ void DevSetup::initDlg() ui.rbData->setEnabled(m_catEnabled); ui.rbMic->setEnabled(m_catEnabled); ui.pollSpinBox->setEnabled(m_catEnabled); - bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2 or m_catEnabled; + bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2; + ui.pttComboBox->setEnabled(b); + b=b or m_catEnabled; ui.testPTTButton->setEnabled(b); ui.rigComboBox->setCurrentIndex(m_rigIndex); ui.catPortComboBox->setCurrentIndex(m_catPortIndex); @@ -160,12 +174,17 @@ void DevSetup::initDlg() ui.pollSpinBox->setValue(m_poll); // PY2SDR -- Per OS serial port names + m_tmp=m_pttPort; + ui.pttComboBox->clear(); ui.catPortComboBox->clear(); + ui.pttComboBox->addItem("None"); ui.catPortComboBox->addItem("None"); #ifdef WIN32 for ( int i = 1; i < 100; i++ ) { + ui.pttComboBox->addItem("COM" + QString::number(i)); ui.catPortComboBox->addItem("COM" + QString::number(i)); } + ui.pttComboBox->addItem("USB"); ui.catPortComboBox->addItem("USB"); #else ui.catPortComboBox->addItem("/dev/ttyS0"); @@ -176,9 +195,18 @@ void DevSetup::initDlg() ui.catPortComboBox->addItem("/dev/ttyUSB1"); ui.catPortComboBox->addItem("/dev/ttyUSB2"); ui.catPortComboBox->addItem("/dev/ttyUSB3"); -#endif - ui.catPortComboBox->setCurrentIndex(m_catPortIndex); + ui.pttComboBox->addItem("/dev/ttyS0"); + ui.pttComboBox->addItem("/dev/ttyS1"); + ui.pttComboBox->addItem("/dev/ttyS2"); + ui.pttComboBox->addItem("/dev/ttyS3"); + ui.pttComboBox->addItem("/dev/ttyUSB0"); + ui.pttComboBox->addItem("/dev/ttyUSB1"); + ui.pttComboBox->addItem("/dev/ttyUSB2"); + ui.pttComboBox->addItem("/dev/ttyUSB3"); +#endif + ui.pttComboBox->setCurrentIndex(m_tmp); + ui.catPortComboBox->setCurrentIndex(m_catPortIndex); ui.macro1->setText(m_macro[0].toUpper()); ui.macro2->setText(m_macro[1].toUpper()); @@ -226,7 +254,7 @@ void DevSetup::accept() m_myGrid=ui.myGridEntry->text(); m_idInt=ui.idIntSpinBox->value(); m_pttMethodIndex=ui.pttMethodComboBox->currentIndex(); - m_pttPort=ui.pttPortEntry->text(); + m_pttPort=ui.pttComboBox->currentIndex(); m_saveDir=ui.saveDirEntry->text(); m_nDevIn=ui.comboBoxSndIn->currentIndex(); m_paInDevice=m_inDevList[m_nDevIn]; @@ -334,9 +362,7 @@ void DevSetup::on_cbPSKReporter_clicked(bool b) void DevSetup::on_pttMethodComboBox_activated(int index) { m_pttMethodIndex=index; - bool b=(m_pttMethodIndex==1 or m_pttMethodIndex==2); - ui.pttPortEntry->setEnabled(b); - b=m_pttMethodIndex==1 or m_pttMethodIndex==2 or + bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2 or (m_catEnabled and m_pttMethodIndex==0); ui.testPTTButton->setEnabled(b); } @@ -493,7 +519,14 @@ void DevSetup::on_pollSpinBox_valueChanged(int n) m_poll=n; } -void DevSetup::on_pttPortEntry_editingFinished() +void DevSetup::on_pttComboBox_currentIndexChanged(int index) { - m_pttPort=ui.pttPortEntry->text(); + m_pttPort=index; +} + +void DevSetup::on_pttMethodComboBox_currentIndexChanged(int index) +{ + m_pttMethodIndex=index; + bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2; + ui.pttComboBox->setEnabled(b); } diff --git a/devsetup.h b/devsetup.h index 8b3c93cdb..6d7009669 100644 --- a/devsetup.h +++ b/devsetup.h @@ -18,6 +18,7 @@ public: qint32 m_idInt; qint32 m_pttMethodIndex; + qint32 m_pttPort; qint32 m_nDevIn; qint32 m_nDevOut; qint32 m_inDevList[100]; @@ -38,6 +39,7 @@ public: qint32 m_test; qint32 m_COMportOpen; qint32 m_poll; + qint32 m_tmp; bool m_restartSoundIn; bool m_restartSoundOut; @@ -55,7 +57,6 @@ public: QString m_azelDir; QString m_catPort; QString m_handshake; - QString m_pttPort; QStringList m_macro; QStringList m_dFreq; @@ -88,7 +89,9 @@ private slots: void on_cbDTRoff_toggled(bool checked); void on_rbData_toggled(bool checked); void on_pollSpinBox_valueChanged(int n); - void on_pttPortEntry_editingFinished(); + void on_pttComboBox_currentIndexChanged(int index); + + void on_pttMethodComboBox_currentIndexChanged(int index); private: Rig* rig; @@ -96,6 +99,6 @@ private: Ui::DialogSndCard ui; }; -extern int ptt(QString pttPort, int ntx, int* iptt, int* nopen); +extern int ptt(int nport, int ntx, int* iptt, int* nopen); #endif // DEVSETUP_H diff --git a/devsetup.ui b/devsetup.ui index 65f4be342..fca51c9cd 100644 --- a/devsetup.ui +++ b/devsetup.ui @@ -7,7 +7,7 @@ 0 0 548 - 521 + 465 @@ -148,7 +148,7 @@ - 80 + 60 16777215 @@ -273,7 +273,7 @@ - + 0 @@ -288,10 +288,15 @@ - 80 + 60 16777215 + + + None + + @@ -2373,6 +2378,7 @@ myCallEntry myGridEntry pttMethodComboBox + pttComboBox idIntSpinBox cbID73 cbPSKReporter diff --git a/getfile.cpp b/getfile.cpp index 737f09a0a..59a1729ac 100644 --- a/getfile.cpp +++ b/getfile.cpp @@ -121,15 +121,57 @@ float gran() return v2*fac; } -int ptt(QString pttPort, int ntx, int* iptt, int* nopen) +/* +int ptt(int nport, int ntx, int *iptt) +{ +#ifdef WIN32 + static HANDLE hFile; + static int open=0; + char s[10]; + int i3=1,i4=1,i5=1,i6=1,i9=1,i00=1; + + if(nport==0) { + *iptt=ntx; + return(0); + } + + if(ntx && (!open)) { + sprintf(s,"\\\\.\\COM%d",nport); + hFile=CreateFile(TEXT(s),GENERIC_WRITE,0,NULL,OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL,NULL); + if(hFile==INVALID_HANDLE_VALUE) { + // printf("PTT: Cannot open COM port %d.\n",nport); + return 1; + } + open=1; + } + + if(ntx && open) { + i3=EscapeCommFunction(hFile,SETRTS); + i5=EscapeCommFunction(hFile,SETDTR); + *iptt=1; + } + + else { + i4=EscapeCommFunction(hFile,CLRRTS); + i6=EscapeCommFunction(hFile,CLRDTR); + i9=EscapeCommFunction(hFile,CLRBREAK); + i00=CloseHandle(hFile); + *iptt=0; + open=0; + } + return 0; +#endif +} +*/ + +int ptt(int nport, int ntx, int* iptt, int* nopen) { #ifdef WIN32 - int nport; static HANDLE hFile; char s[10]; int i3=1,i4=1,i5=1,i6=1,i9=1,i00=1; - nport=pttPort.mid(3).toInt(); if(nport==0) { *iptt=ntx; return(0); @@ -164,3 +206,8 @@ int ptt(QString pttPort, int ntx, int* iptt, int* nopen) return 0; #endif } + +int hamlibError(int retcode) +{ + qDebug() << "Hamlib error" << retcode; +} diff --git a/getfile.h b/getfile.h index 0a2923a74..2d4ffed07 100644 --- a/getfile.h +++ b/getfile.h @@ -8,7 +8,7 @@ void getfile(QString fname, int ntrperiod); float gran(); //int ptt(int* nport, int* ntx, int* iptt); -int ptt(QString pttPort, int ntx, int* iptt, int* nopen); +int ptt(int nport, int ntx, int* iptt, int* nopen); #endif // GETFILE_H diff --git a/mainwindow.cpp b/mainwindow.cpp index ad3eba10e..810591526 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -182,7 +182,6 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) : m_dontReadFreq=false; ui->readFreq->setEnabled(false); m_QSOmsg=""; - m_pttPort="None"; decodeBusy(false); ui->xThermo->setFillBrush(Qt::green); @@ -440,7 +439,7 @@ void MainWindow::readSettings() m_myGrid=settings.value("MyGrid","").toString(); m_idInt=settings.value("IDint",0).toInt(); m_pttMethodIndex=settings.value("PTTmethod",1).toInt(); - m_pttPort=settings.value("PTTport","None").toString(); + m_pttPort=settings.value("PTTport",0).toInt(); m_saveDir=settings.value("SaveDir",m_appDir + "/save").toString(); m_nDevIn = settings.value("SoundInIndex", 0).toInt(); m_paInDevice = settings.value("paInDevice",0).toInt(); @@ -884,6 +883,7 @@ void MainWindow::statusChanged() QTextStream out(&f); out << m_dialFreq << ";" << m_mode << ";" << m_hisCall << ";" << ui->rptSpinBox->value() << endl; +// out << m_dialFreq << ";" << m_mode << ";" << m_hisCall << endl; f.close(); } else { msgBox("Cannot open file \"wsjtx_status.txt\"."); @@ -1243,7 +1243,7 @@ void MainWindow::decode() //decode() char *from = (char*) jt9com_.ss; int size=sizeof(jt9com_); if(jt9com_.newdat==0) { - int noffset = 4*184*NSMAX + 4*NSMAX + 4*2*NTMAX*1500 + 2*NTMAX*12000; + int noffset = 4*184*22000 + 4*22000 + 4*2*1800*1500 + 2*1800*12000; to += noffset; from += noffset; size -= noffset; diff --git a/mainwindow.h b/mainwindow.h index 984d260e7..2680262db 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -171,6 +171,7 @@ private: qint32 m_pttMethodIndex; qint32 m_QSOfreq0; qint32 m_ntx; + qint32 m_pttPort; qint32 m_timeout; qint32 m_txFreq; qint32 m_setftx; @@ -314,7 +315,6 @@ private: QString m_msgSent0; QString m_fileToSave; QString m_QSOmsg; - QString m_pttPort; QStringList m_macro; QStringList m_dFreq; diff --git a/plotter.cpp b/plotter.cpp index 77e7248c3..7467828c6 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -104,7 +104,8 @@ void CPlotter::draw(float swide[], float red[], int i0) //draw() j=0; int iz=XfromFreq(2000.0); - for(int i=0; iiz) swide[i]=0; y=0.0; if(swide[i]>0.0) y = 10.0*log10(swide[i]); @@ -125,7 +126,7 @@ void CPlotter::draw(float swide[], float red[], int i0) //draw() y2=gain*6.0*log10(sum/m_binsPerPixel) - 10.0; } if(m_bJT9Sync) y2=3.0*gain*red[i] - 15; - if(i==m_w-2) painter2D.drawPolyline(LineBuf,j); + if(i==iz-1) painter2D.drawPolyline(LineBuf,j); LineBuf[j].setX(i); LineBuf[j].setY(m_h-(y2+0.8*m_h)); j++;