diff --git a/CMakeLists.txt b/CMakeLists.txt index 965af97ca..00a1fc325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,6 +363,7 @@ set (wsjt_FSRCS lib/foldspec9f.f90 lib/four2a.f90 lib/fqso_first.f90 + lib/freqcal.f90 lib/gen4.f90 lib/gen65.f90 lib/gen9.f90 diff --git a/lib/freqcal.f90 b/lib/freqcal.f90 new file mode 100644 index 000000000..1e74794d1 --- /dev/null +++ b/lib/freqcal.f90 @@ -0,0 +1,51 @@ +subroutine freqcal(id2,k,nfreq,ntol,line) + + parameter (NZ=30*12000,NFFT=55296,NH=NFFT/2) + integer*2 id2(0:NZ-1) + real x(0:NFFT-1) + real s(NH) + character line*27 + complex cx(0:NH) + equivalence (x,cx) + data n/0/,k0/9999999/ + save n,k0 + + if(k.lt.k0) n=0 + k0=k + + x=0.001*id2(k-NFFT:k-1) + call four2a(x,NFFT,1,-1,0) !Compute spectrum, r2c + df=12000.0/NFFT + ia=nint((nfreq-ntol)/df) + ib=nint((nfreq+ntol)/df) + smax=0. + s=0. + do i=ia,ib + s(i)=real(cx(i))**2 + aimag(cx(i))**2 + if(s(i).gt.smax) then + smax=s(i) + ipk=i + endif + enddo + + call peakup(s(ipk-1),s(ipk),s(ipk+1),dx) + fpeak=df * (ipk+dx) + sum=0. + nsum=0 + do i=ia,ib + if(abs(i-ipk).gt.10) then + sum=sum+s(i) + nsum=nsum+1 + endif + enddo + ave=sum/nsum + pave=db(ave) + 8.0 + snr=db(smax/ave) +! if(snr.lt.20.0) cflag='*' + n=n+1 + write(line,1100) fpeak,snr +1100 format(2f8.1) + line(27:27)=char(0) + + return +end subroutine freqcal diff --git a/mainwindow.cpp b/mainwindow.cpp index 6fe590e82..80a9f16ef 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -102,6 +102,7 @@ extern "C" { int ptt_(int nport, int ntx, int* iptt, int* nopen); void wspr_downsample_(short int d2[], int* k); + int savec2_(char* fname, int* TR_seconds, double* dial_freq, int len1); void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1, @@ -112,9 +113,13 @@ extern "C" { char msg[], char mycall[], char hiscall[], int len1, int len2, int len3); void degrade_snr_(short d2[], int* n, float* db, float* bandwidth); + void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2); + void refspectrum_(short int d2[], bool* bclearrefspec, bool* brefspec, bool* buseref, const char* c_fname, int len); + + void freqcal_(short d2[], int* k, int* nfreq, int* ntol, char line[], int len); } int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols @@ -1090,6 +1095,7 @@ void MainWindow::fixStop() void MainWindow::dataSink(qint64 frames) { static float s[NSMAX]; + char line[27]; int k (frames); QString fname {QDir::toNativeSeparators(m_dataDir.absoluteFilePath ("refspec.dat"))}; @@ -1133,6 +1139,18 @@ void MainWindow::dataSink(qint64 frames) } fixStop(); + if(m_mode=="FreqCal" and m_ihsym>=16 and m_ihsym%8==0) { + m_RxFreq=ui->RxFreqSpinBox->value (); + freqcal_(&dec_data.d2[0],&k,&m_RxFreq,&m_Ftol,&line[0],27); + QString t=QString::fromLatin1(line); + + DecodedText decodedtext; + decodedtext=t; + ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), + m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), + m_config.color_NewCall()); + } + if(m_ihsym==3*m_hsymStop/4) { m_dialFreqRxWSPR=m_freqNominal; } @@ -1166,7 +1184,6 @@ void MainWindow::dataSink(qint64 frames) return; } if(m_mode=="FreqCal") { - qDebug() << "A" << m_ihsym; return; } if( m_dialFreqRxWSPR==0) m_dialFreqRxWSPR=m_freqNominal; @@ -1971,12 +1988,14 @@ void MainWindow::on_actionHide_Controls_triggered() minimumSize().setWidth(770); } ui->menuBar->setVisible(!m_bHideControls); - ui->label_6->setVisible(!m_bHideControls); + if(m_mode!="FreqCal") { + ui->label_6->setVisible(!m_bHideControls); + ui->label_7->setVisible(!m_bHideControls); + ui->decodedTextLabel2->setVisible(!m_bHideControls); + ui->line_2->setVisible(!m_bHideControls); + } ui->line->setVisible(!m_bHideControls); - ui->line_2->setVisible(!m_bHideControls); - ui->label_7->setVisible(!m_bHideControls); ui->decodedTextLabel->setVisible(!m_bHideControls); - ui->decodedTextLabel2->setVisible(!m_bHideControls); ui->gridLayout_5->layout()->setSpacing(spacing); ui->horizontalLayout->layout()->setSpacing(spacing); ui->horizontalLayout_2->layout()->setSpacing(spacing); @@ -4508,14 +4527,13 @@ void MainWindow::on_actionEcho_triggered() void MainWindow::on_actionFreqCal_triggered() { - on_actionEcho_triggered(); - if(m_echoGraph->isVisible()) m_echoGraph->hide(); - if(ui->actionAstronomical_data->isChecked()) { - ui->actionAstronomical_data->setChecked (false); - } + on_actionJT9_triggered(); + displayWidgets(nWidgets("001100000000000000000000")); m_mode="FreqCal"; - displayWidgets(nWidgets("000000000000000000000000")); ui->actionFreqCal->setChecked(true); + switch_mode(Modes::FreqCal); + m_wideGraph->setMode(m_mode); + statusChanged(); m_TRperiod=30; m_modulator->setPeriod(m_TRperiod); // TODO - not thread safe m_detector->setPeriod(m_TRperiod); // TODO - not thread safe @@ -4523,15 +4541,8 @@ void MainWindow::on_actionFreqCal_triggered() m_FFTSize = m_nsps / 2; Q_EMIT FFTSize (m_FFTSize); m_hsymStop=100; - switch_mode(Modes::FreqCal); setup_status_bar (true); - m_wideGraph->setMode(m_mode); - m_bFastMode=true; - m_bFast9=false; - fast_config(false); -// WSPR_config(true); - ui->decodedTextLabel->setText(" UTC N Level Sig DF Width Q"); - statusChanged(); + ui->decodedTextLabel->setText(" Freq S/N"); } void MainWindow::switch_mode (Mode mode) @@ -4558,6 +4569,15 @@ void MainWindow::switch_mode (Mode mode) ui->RxFreqSpinBox->setSingleStep(1); } m_bVHFwarned=false; + bool b=m_mode=="FreqCal"; + ui->tabWidget->setVisible(!b); + if(b) { + ui->DX_controls_widget->setVisible(false); + ui->decodedTextBrowser2->setVisible(false); + ui->decodedTextLabel2->setVisible(false); + ui->label_6->setVisible(false); + ui->label_7->setVisible(false); + } } void MainWindow::WSPR_config(bool b) diff --git a/mainwindow.ui b/mainwindow.ui index 0abddc089..5eee0e14a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -624,6 +624,12 @@ QLabel[oob="true"] { + + + 120 + 16777215 + + Frequency tolerance (Hz) @@ -773,6 +779,12 @@ QLabel[oob="true"] { + + + 120 + 16777215 + + Audio Rx frequency diff --git a/plotter.cpp b/plotter.cpp index 18ad1bb95..b25478ce4 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -422,6 +422,15 @@ void CPlotter::DrawOverlay() //DrawOverlay() x2=XfromFreq(1600); painter0.drawLine(x1,29,x2,29); } + + if(m_mode=="FreqCal") { //FreqCal + x1=XfromFreq(m_rxFreq-m_tol); + x2=XfromFreq(m_rxFreq+m_tol); + painter0.drawLine(x1,29,x2,29); + x1=XfromFreq(m_rxFreq); + painter0.drawLine(x1,24,x1,30); + } + if(m_mode=="JT9" or m_mode=="JT65" or m_mode=="JT9+JT65" or m_mode=="QRA64") { if(m_mode=="QRA64" or (m_mode=="JT65" and m_bVHF)) {