From d1f4ae5d08f6a5e4d7301c41c34593d96954f6a4 Mon Sep 17 00:00:00 2001 From: Marc CAPDEVILLE Date: Sun, 16 Oct 2022 19:03:27 +0200 Subject: [PATCH] mainWindow : Implementing dockRTTY --- src/applications/gqrx/mainwindow.cpp | 105 +++++++++++++++++++++++++++ src/applications/gqrx/mainwindow.h | 17 ++++- src/receivers/nbrx.h | 2 +- 3 files changed, 122 insertions(+), 2 deletions(-) diff --git a/src/applications/gqrx/mainwindow.cpp b/src/applications/gqrx/mainwindow.cpp index cb48bd24e0..c07bc16504 100644 --- a/src/applications/gqrx/mainwindow.cpp +++ b/src/applications/gqrx/mainwindow.cpp @@ -135,6 +135,7 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) uiDockRxOpt = new DockRxOpt(); uiDockRDS = new DockRDS(); uiDockFAX = new DockFAX(); + uiDockRTTY = new DockRTTY(); uiDockAudio = new DockAudio(); uiDockInputCtl = new DockInputCtl(); uiDockFft = new DockFft(); @@ -175,9 +176,11 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) addDockWidget(Qt::RightDockWidgetArea, uiDockAudio); addDockWidget(Qt::RightDockWidgetArea, uiDockRDS); addDockWidget(Qt::RightDockWidgetArea, uiDockFAX); + addDockWidget(Qt::RightDockWidgetArea, uiDockRTTY); tabifyDockWidget(uiDockAudio, uiDockRDS); tabifyDockWidget(uiDockRDS, uiDockFAX); + tabifyDockWidget(uiDockFAX, uiDockRTTY); uiDockAudio->raise(); addDockWidget(Qt::BottomDockWidgetArea, uiDockBookmarks); @@ -186,6 +189,7 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) uiDockBookmarks->hide(); uiDockRDS->hide(); uiDockFAX->hide(); + uiDockRTTY->hide(); /* Add dock widget actions to View menu. By doing it this way all signal/slot connections will be established automagially. @@ -194,6 +198,7 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) ui->menu_View->addAction(uiDockRxOpt->toggleViewAction()); ui->menu_View->addAction(uiDockRDS->toggleViewAction()); ui->menu_View->addAction(uiDockFAX->toggleViewAction()); + ui->menu_View->addAction(uiDockRTTY->toggleViewAction()); ui->menu_View->addAction(uiDockAudio->toggleViewAction()); ui->menu_View->addAction(uiDockFft->toggleViewAction()); ui->menu_View->addAction(uiDockBookmarks->toggleViewAction()); @@ -290,6 +295,15 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) connect(uiDockFAX, SIGNAL(fax_sync_Clicked()), this, SLOT(force_fax_sync())); connect(uiDockFAX, SIGNAL(fax_start_Clicked()), this, SLOT(force_fax_start())); connect(uiDockFAX, SIGNAL(fax_save_Clicked()), this, SLOT(save_fax())); + connect(uiDockRTTY, SIGNAL(rtty_start_decoder()), this, SLOT(start_rtty_decoder())); + connect(uiDockRTTY, SIGNAL(rtty_stop_decoder()), this, SLOT(stop_rtty_decoder())); + connect(uiDockRTTY, SIGNAL(rtty_reset_clicked()), this, SLOT(reset_rtty_decoder())); + connect(uiDockRTTY, SIGNAL(rtty_baud_rate_Changed(float)), this, SLOT(set_rtty_baud_rate(float))); + connect(uiDockRTTY, SIGNAL(rtty_mark_freq_Changed(float)), this, SLOT(set_rtty_mark_freq(float))); + connect(uiDockRTTY, SIGNAL(rtty_space_freq_Changed(float)), this, SLOT(set_rtty_space_freq(float))); + connect(uiDockRTTY, SIGNAL(rtty_mode_Changed(int)), this, SLOT(set_rtty_mode(int))); + connect(uiDockRTTY, SIGNAL(rtty_parity_Changed(int)), this, SLOT(set_rtty_parity(int))); + connect(uiDockRTTY, SIGNAL(rtty_save_clicked(QString)), this, SLOT(save_rtty(QString))); // Bookmarks connect(uiDockBookmarks, SIGNAL(newBookmarkActivated(qint64, QString, int)), this, SLOT(onBookmarkActivated(qint64, QString, int))); @@ -331,6 +345,9 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent) fax_timer = new QTimer(this); connect(fax_timer, SIGNAL(timeout()), this, SLOT(faxTimeout())); + rtty_timer = new QTimer(this); + connect(rtty_timer, SIGNAL(timeout()), this, SLOT(rttyTimeout())); + // enable frequency tooltips on FFT plot ui->plotter->setTooltipsEnabled(true); @@ -424,6 +441,7 @@ MainWindow::~MainWindow() delete uiDockInputCtl; delete uiDockRDS; delete uiDockFAX; + delete uiDockRTTY; delete rx; delete remote; delete [] d_fftData; @@ -1078,6 +1096,7 @@ void MainWindow::selectDemod(int mode_idx) int flo=0, fhi=0, click_res=100; bool rds_decoder_enabled; bool fax_decoder_enabled; + bool rtty_decoder_enabled; // validate mode_idx if (mode_idx < DockRxOpt::MODE_OFF || mode_idx >= DockRxOpt::MODE_LAST) @@ -1100,6 +1119,11 @@ void MainWindow::selectDemod(int mode_idx) stop_fax_decoder(); uiDockFAX->set_Disabled(); + rtty_decoder_enabled = rx->is_decoder_active(receiver_base_cf::RX_DECODER_RTTY); + if (rtty_decoder_enabled) + stop_rtty_decoder(); + uiDockRTTY->set_Disabled(); + switch (mode_idx) { case DockRxOpt::MODE_OFF: @@ -1213,6 +1237,10 @@ void MainWindow::selectDemod(int mode_idx) uiDockFAX->set_Enabled(); if (fax_decoder_enabled) start_fax_decoder(); + + uiDockRTTY->set_Enabled(); + if (rtty_decoder_enabled) + start_rtty_decoder(); } qDebug() << "Filter preset for mode" << mode_idx << "LO:" << flo << "HI:" << fhi; @@ -1872,6 +1900,7 @@ void MainWindow::on_actionDSP_triggered(bool checked) audio_fft_timer->stop(); rds_timer->stop(); fax_timer->stop(); + rtty_timer->stop(); /* stop receiver */ rx->stop(); @@ -2609,3 +2638,79 @@ void MainWindow::save_fax() { msg.exec(); } + +/** RTTY message display timeout. */ +void MainWindow::rttyTimeout() { + std::string data; + int num; + + while (rx->get_decoder_data(receiver_base_cf::RX_DECODER_RTTY,(void*)&data, num)!=-1) { + uiDockRTTY->update_text(QString::fromStdString(data)); + } +} + +void MainWindow::start_rtty_decoder() { + qDebug() << "Starting RTTY decoder."; + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"baud_rate",std::to_string(uiDockRTTY->get_baud_rate())); + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"mark_freq",std::to_string(uiDockRTTY->get_mark_freq())); + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"space_freq",std::to_string(uiDockRTTY->get_space_freq())); + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"mode",std::to_string(uiDockRTTY->get_mode())); + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"parity",std::to_string(uiDockRTTY->get_parity())); + uiDockRTTY->show_Enabled(); + rx->start_decoder(receiver_base_cf::RX_DECODER_RTTY); + rx->reset_decoder(receiver_base_cf::RX_DECODER_RTTY); + rtty_timer->start(250); +} + +void MainWindow::stop_rtty_decoder() { + qDebug() << "Stopping RTTY decoder."; + uiDockRTTY->show_Disabled(); + rx->stop_decoder(receiver_base_cf::RX_DECODER_RTTY); + rtty_timer->stop(); +} + +void MainWindow::reset_rtty_decoder() { + rx->reset_decoder(receiver_base_cf::RX_DECODER_RTTY); +} + +void MainWindow::set_rtty_baud_rate(float baud_rate) { + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"baud_rate",std::to_string(baud_rate)); +} + +void MainWindow::set_rtty_mark_freq(float mark_freq) { + std::string Val; + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"mark_freq",std::to_string(mark_freq)); +} + +void MainWindow::set_rtty_space_freq(float space_freq) { + std::string Val; + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"space_freq",std::to_string(space_freq)); +} + +void MainWindow::set_rtty_mode(int mode) { + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"mode",std::to_string(mode)); +} + +void MainWindow::set_rtty_parity(int parity) { + rx->set_decoder_param(receiver_base_cf::RX_DECODER_RTTY,"parity",std::to_string(parity)); +} + +void MainWindow::save_rtty(QString text) { + QString name = QFileDialog::getSaveFileName(this, "Save rtty", "", "All Files (*)"); + QMessageBox msg; + QFile file(name); + + if (name.isEmpty()) + return; + + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&file); + + out << text; + msg.setText("Saved."); + } + else + msg.setText("Not saved."); + + msg.exec(); +} diff --git a/src/applications/gqrx/mainwindow.h b/src/applications/gqrx/mainwindow.h index 9dfdb72096..108fe06fa8 100644 --- a/src/applications/gqrx/mainwindow.h +++ b/src/applications/gqrx/mainwindow.h @@ -40,6 +40,7 @@ #include "qtgui/dockbookmarks.h" #include "qtgui/dockrds.h" #include "qtgui/dockfax.h" +#include "qtgui/dockrtty.h" #include "qtgui/afsk1200win.h" #include "qtgui/iq_tool.h" #include "qtgui/dxc_options.h" @@ -101,7 +102,8 @@ public slots: DockFft *uiDockFft; DockBookmarks *uiDockBookmarks; DockRDS *uiDockRDS; - DockFAX *uiDockFAX; + DockFAX *uiDockFAX; + DockRTTY *uiDockRTTY; CIqTool *iq_tool; DXCOptions *dxc_options; @@ -117,6 +119,7 @@ public slots: QTimer *audio_fft_timer; QTimer *rds_timer; QTimer *fax_timer; + QTimer *rtty_timer; receiver *rx; @@ -226,6 +229,17 @@ private slots: int save_fax(QString name); void save_fax(); + /* RTTY */ + void start_rtty_decoder(); + void stop_rtty_decoder(); + void reset_rtty_decoder(); + void set_rtty_baud_rate(float); + void set_rtty_mark_freq(float); + void set_rtty_space_freq(float); + void set_rtty_mode(int); + void set_rtty_parity(int); + void save_rtty(QString text); + /* Bookmarks */ void onBookmarkActivated(qint64 freq, const QString& demod, int bandwidth); @@ -264,6 +278,7 @@ private slots: void audioFftTimeout(); void rdsTimeout(); void faxTimeout(); + void rttyTimeout(); }; #endif // MAINWINDOW_H diff --git a/src/receivers/nbrx.h b/src/receivers/nbrx.h index 08c87584ff..5e8c7c4177 100644 --- a/src/receivers/nbrx.h +++ b/src/receivers/nbrx.h @@ -149,7 +149,7 @@ class nbrx : public receiver_base_cf resampler_ff_sptr audio_rr1; /*!< Audio resampler. */ gr::fax::fax_demod::sptr fax_decoder; bool fax_decoder_enable; - gr::rtty::rtty_demod::sptr d_rtty; // RTTY decoder + gr::rtty::rtty_demod::sptr d_rtty; // RTTY decoder bool d_rtty_enable;