diff --git a/src/dialogs/fl_digi.cxx b/src/dialogs/fl_digi.cxx index fe72d03d..b73be43b 100644 --- a/src/dialogs/fl_digi.cxx +++ b/src/dialogs/fl_digi.cxx @@ -9033,13 +9033,15 @@ void set_ip_to_default(int which_io) } } -void set_CSV(int how) +void set_CSV(int start) { if (! (active_modem->get_mode() == MODE_ANALYSIS || active_modem->get_mode() == MODE_FFTSCAN) ) return; - if (how == 0) active_modem->stop_csv(); - else if (how == 1) active_modem->start_csv(); - else if (active_modem->is_csv() == true) + if (start == 1) + active_modem->start_csv(); + else if (start == 0) + active_modem->stop_csv(); + else if (active_modem->write_to_csv == true) active_modem->stop_csv(); else active_modem->start_csv(); diff --git a/src/include/analysis.h b/src/include/analysis.h index d27fb668..9c18708c 100644 --- a/src/include/analysis.h +++ b/src/include/analysis.h @@ -25,6 +25,7 @@ #include #include +#include #include "complex.h" #include "filters.h" @@ -42,7 +43,6 @@ private: double phaseacc; - C_FIR_filter *hilbert; fftfilt *bpfilt; Cmovavg *ffilt; Cmovavg *favg; @@ -78,6 +78,8 @@ public: void tx_init(SoundBase *sc); void restart(); void start_csv(); + void stop_csv(); + int rx_process(const double *buf, int len); int tx_process(); diff --git a/src/include/modem.h b/src/include/modem.h index 7cb592ea..97d77768 100644 --- a/src/include/modem.h +++ b/src/include/modem.h @@ -246,10 +246,9 @@ public: int ovhd_samples; // analysis mode + int write_to_csv; virtual void start_csv() {} virtual void stop_csv() {} - virtual int is_csv() { return true;} - virtual double track_freq() { return 0;} // fsq mode bool fsq_tx_image; diff --git a/src/waterfall/waterfall.cxx b/src/waterfall/waterfall.cxx index 0d97c920..aa12dcd1 100644 --- a/src/waterfall/waterfall.cxx +++ b/src/waterfall/waterfall.cxx @@ -664,7 +664,7 @@ update_freq: if (testmode.find("CW") != string::npos) afreq = 0;//-progdefaults.CWsweetspot; if (mode == MODE_ANALYSIS) { - dfreq = active_modem->track_freq(); + dfreq = 0; } else { if (usb) dfreq = rfc + afreq + offset; diff --git a/src/wwv/analysis.cxx b/src/wwv/analysis.cxx index a6b114a1..badfad5e 100644 --- a/src/wwv/analysis.cxx +++ b/src/wwv/analysis.cxx @@ -62,7 +62,6 @@ void anal::init() anal::~anal() { - delete hilbert; delete bpfilt; delete ffilt; delete favg; @@ -94,6 +93,8 @@ void anal::restart() dspcnt = DSP_CNT; for (int i = 0; i < PIPE_LEN; i++) pipe[i] = 0; + if (write_to_csv) stop_csv(); + start_csv(); } @@ -105,14 +106,14 @@ anal::anal() samplerate = ANAL_SAMPLERATE; bpfilt = (fftfilt *)0; - hilbert = new C_FIR_filter(); - hilbert->init_hilbert(37, 1); ffilt = new Cmovavg(FILT_LEN * samplerate); - analysisFilename = HomeDir; - analysisFilename.append("freqanalysis.csv"); + analysisFilename = TempDir; + analysisFilename.append("analysis.csv"); cap &= ~CAP_TX; + write_to_csv = false; + restart(); } @@ -140,10 +141,22 @@ void anal::start_csv() } fprintf(out, "Clock,Elapsed Time,Freq Error,RF\n"); fclose(out); + + put_status("Writing csv file"); + + write_to_csv = true; +} + +void anal::stop_csv() +{ + write_to_csv = false; + put_status(""); } void anal::writeFile() { + if (!write_to_csv) return; + struct timespec now; struct tm tm; @@ -163,6 +176,9 @@ void anal::writeFile() tm.tm_hour, tm.tm_min, tm.tm_sec, elapsed, fout, (wf->rfcarrier() + (wf->USB() ? 1.0 : -1.0) * (frequency + fout))); fclose(out); + + put_status("Writing csv file"); + } int anal::rx_process(const double *buf, int len) @@ -180,7 +196,6 @@ int anal::rx_process(const double *buf, int len) // create analytic signal from sound card input samples z = cmplx( *buf, *buf ); buf++; -// hilbert->run(z, z); // mix it with the audio carrier frequency to create a baseband signal z = mixer(z); // low pass filter using Windowed Sinc - Overlap-Add convolution filter @@ -216,7 +231,7 @@ int anal::rx_process(const double *buf, int len) snprintf(msg1, sizeof(msg1), "%12.2f", wf->rfcarrier() + frequency + fout ); else snprintf(msg1, sizeof(msg1), "%12.2f", wf->rfcarrier() - frequency - fout ); - put_status(msg1, 2.0); + put_Status2(msg1, 2.0); writeFile(); } // reset the display counter & the pipe pointer