From 33629b77e281424617d42affb536559c96321fba Mon Sep 17 00:00:00 2001 From: srcejon Date: Fri, 29 Sep 2023 14:35:52 +0100 Subject: [PATCH] Center channels when possible. Fix channel setting initial display. Add clear active count button. --- plugins/channelrx/freqscanner/freqscanner.cpp | 10 ++++++++++ .../channelrx/freqscanner/freqscannergui.cpp | 19 +++++++++++++++++++ .../channelrx/freqscanner/freqscannergui.h | 1 + .../channelrx/freqscanner/freqscannergui.ui | 14 ++++++++++++++ plugins/channelrx/freqscanner/readme.md | 8 +++++++- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/freqscanner/freqscanner.cpp b/plugins/channelrx/freqscanner/freqscanner.cpp index 8c85f5587..0858dcbe0 100644 --- a/plugins/channelrx/freqscanner/freqscanner.cpp +++ b/plugins/channelrx/freqscanner/freqscanner.cpp @@ -337,6 +337,16 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< m_stepStartFrequency = frequencies.front() + m_scannerSampleRate / 2 - m_settings.m_channelBandwidth + m_settings.m_channelBandwidth / 2; m_stepStopFrequency = frequencies.back(); + // If all frequencies fit within bandwidth, we can have the first frequency more central + int totalBW = frequencies.back() - frequencies.front() + 2 * m_settings.m_channelBandwidth; + if (totalBW < m_scannerSampleRate) + { + int spareBWEachSide = (m_scannerSampleRate - totalBW) / 2; + int spareChannelsEachSide = spareBWEachSide / m_settings.m_channelBandwidth; + int offset = spareChannelsEachSide * m_settings.m_channelBandwidth; + m_stepStartFrequency -= offset; + } + initScan(); } } diff --git a/plugins/channelrx/freqscanner/freqscannergui.cpp b/plugins/channelrx/freqscanner/freqscannergui.cpp index 9e033df26..4fa3b914c 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.cpp +++ b/plugins/channelrx/freqscanner/freqscannergui.cpp @@ -505,6 +505,10 @@ void FreqScannerGUI::displaySettings() blockApplySettings(true); + int channelIndex = ui->channels->findText(m_settings.m_channel); + if (channelIndex >= 0) { + ui->channels->setCurrentIndex(channelIndex); + } ui->deltaFrequency->setValue(m_settings.m_channelFrequencyOffset); ui->channelBandwidth->setValue(m_settings.m_channelBandwidth); ui->scanTime->setValue(m_settings.m_scanTime * 10.0); @@ -641,7 +645,14 @@ void FreqScannerGUI::on_remove_clicked() ui->table->removeRow(row); m_settings.m_frequencies.removeAt(row); // table_cellChanged isn't called for removeRow m_settings.m_enabled.removeAt(row); + m_settings.m_notes.removeAt(row); } + QList settingsKeys({ + "frequencies", + "enabled", + "notes" + }); + applySettings(settingsKeys); } static QList takeRow(QTableWidget* table, int row) @@ -695,6 +706,13 @@ void FreqScannerGUI::on_down_clicked() } } +void FreqScannerGUI::on_clearActiveCount_clicked() +{ + for (int i = 0; i < ui->table->rowCount(); i++) { + ui->table->item(i, COL_ACTIVE_COUNT)->setData(Qt::DisplayRole, 0); + } +} + void FreqScannerGUI::on_table_cellChanged(int row, int column) { QTableWidgetItem* item = ui->table->item(row, column); @@ -911,6 +929,7 @@ void FreqScannerGUI::makeUIConnections() QObject::connect(ui->remove, &QToolButton::clicked, this, &FreqScannerGUI::on_remove_clicked); QObject::connect(ui->up, &QToolButton::clicked, this, &FreqScannerGUI::on_up_clicked); QObject::connect(ui->down, &QToolButton::clicked, this, &FreqScannerGUI::on_down_clicked); + QObject::connect(ui->clearActiveCount, &QToolButton::clicked, this, &FreqScannerGUI::on_clearActiveCount_clicked); } void FreqScannerGUI::updateAbsoluteCenterFrequency() diff --git a/plugins/channelrx/freqscanner/freqscannergui.h b/plugins/channelrx/freqscanner/freqscannergui.h index ef95ee212..35be2e571 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.h +++ b/plugins/channelrx/freqscanner/freqscannergui.h @@ -134,6 +134,7 @@ private slots: void on_remove_clicked(); void on_up_clicked(); void on_down_clicked(); + void on_clearActiveCount_clicked(); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDialogCalled(const QPoint& p); void handleInputMessages(); diff --git a/plugins/channelrx/freqscanner/freqscannergui.ui b/plugins/channelrx/freqscanner/freqscannergui.ui index d00ed10e7..cd887b094 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.ui +++ b/plugins/channelrx/freqscanner/freqscannergui.ui @@ -740,6 +740,20 @@ + + + + Clear Active Count in all rows + + + + + + + :/bin.png:/bin.png + + + diff --git a/plugins/channelrx/freqscanner/readme.md b/plugins/channelrx/freqscanner/readme.md index 9cef14bcd..a6a71263a 100644 --- a/plugins/channelrx/freqscanner/readme.md +++ b/plugins/channelrx/freqscanner/readme.md @@ -16,7 +16,9 @@ Specifies the channel (such as an AM, NFM or DSD Demod), by device set and chann

2: Minimum frequency shift from center frequency of reception for channel

-Use the wheels of keyboard to adjust the minimim frequency shift in Hz from the center frequency of reception for the channel (1). Left click on a digit sets the cursor position at this digit. Right click on a digit sets all digits on the right to zero. This effectively floors value at the digit position. Wheels are moved with the mousewheel while pointing at the wheel or by selecting the wheel with the left mouse click and using the keyboard arrows. Pressing shift simultaneously moves digit by 5 and pressing control moves it by 2. +Use the wheels of keyboard to adjust the minimim frequency shift in Hz from the center frequency of reception for the channel (1). + +This setting is typically used to avoid having the channel (1) centered at DC, which can be problematic for some demodulators used with SDRs with a DC spike.

3: Active frequency power

@@ -119,3 +121,7 @@ Moves the selected rows up the frequency table (14).

19: Down

Moves the selected rows the the frequency table (14). + +

20: Clear Active Count

+ +Press to reset the value in the Active Count column to 0 for all rows.