Skip to content

Commit

Permalink
mainWindow : Implementing dockRTTY
Browse files Browse the repository at this point in the history
  • Loading branch information
mcapdeville committed Oct 18, 2022
1 parent 169eae2 commit 104f934
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
105 changes: 105 additions & 0 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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());
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -424,6 +441,7 @@ MainWindow::~MainWindow()
delete uiDockInputCtl;
delete uiDockRDS;
delete uiDockFAX;
delete uiDockRTTY;
delete rx;
delete remote;
delete [] d_fftData;
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
17 changes: 16 additions & 1 deletion src/applications/gqrx/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -101,7 +102,8 @@ public slots:
DockFft *uiDockFft;
DockBookmarks *uiDockBookmarks;
DockRDS *uiDockRDS;
DockFAX *uiDockFAX;
DockFAX *uiDockFAX;
DockRTTY *uiDockRTTY;

CIqTool *iq_tool;
DXCOptions *dxc_options;
Expand All @@ -117,6 +119,7 @@ public slots:
QTimer *audio_fft_timer;
QTimer *rds_timer;
QTimer *fax_timer;
QTimer *rtty_timer;

receiver *rx;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -264,6 +278,7 @@ private slots:
void audioFftTimeout();
void rdsTimeout();
void faxTimeout();
void rttyTimeout();
};

#endif // MAINWINDOW_H
2 changes: 1 addition & 1 deletion src/receivers/nbrx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down

0 comments on commit 104f934

Please sign in to comment.