diff --git a/USER_MANUAL.md b/USER_MANUAL.md index 15e44f238..37c64989e 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -935,6 +935,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes * *NOTE: Requires 'Enable Experimental Features' to be turned on, see below.* * Adds configuration item allowing optional use of experimental features. (PR #497) * This option is called "Enable Experimental Features" in Tools->Options->Debugging. + * Add FreeDV Reporter option to have the band filter track the current frequency. (PR #534) 3. Build system: * Upgrade wxWidgets on binary builds to 3.2.2.1. (PR #531) * Fix issue preventing proper generation of unsigned Windows installers. (PR #528) diff --git a/src/config/ReportingConfiguration.cpp b/src/config/ReportingConfiguration.cpp index 7332fa5e4..f1926c392 100644 --- a/src/config/ReportingConfiguration.cpp +++ b/src/config/ReportingConfiguration.cpp @@ -41,6 +41,7 @@ ReportingConfiguration::ReportingConfiguration() , freedvReporterHostname("/Reporting/FreeDV/Hostname", wxT(FREEDV_REPORTER_DEFAULT_HOSTNAME)) , freedvReporterBandFilter("/Reporting/FreeDV/CurrentBandFilter", 0) , useMetricDistances("/Reporting/FreeDV/UseMetricDistances", true) + , freedvReporterBandFilterTracksFrequency("/Reporting/FreeDV/BandFilterTracksFrequency", false) , useUTCForReporting("/CallsignList/UseUTCTime", false) @@ -88,6 +89,7 @@ void ReportingConfiguration::load(wxConfigBase* config) load_(config, freedvReporterHostname); load_(config, freedvReporterBandFilter); load_(config, useMetricDistances); + load_(config, freedvReporterBandFilterTracksFrequency); load_(config, useUTCForReporting); @@ -114,6 +116,7 @@ void ReportingConfiguration::save(wxConfigBase* config) save_(config, freedvReporterHostname); save_(config, freedvReporterBandFilter); save_(config, useMetricDistances); + save_(config, freedvReporterBandFilterTracksFrequency); save_(config, useUTCForReporting); diff --git a/src/config/ReportingConfiguration.h b/src/config/ReportingConfiguration.h index c6b665b23..760c9a0bf 100644 --- a/src/config/ReportingConfiguration.h +++ b/src/config/ReportingConfiguration.h @@ -50,6 +50,7 @@ class ReportingConfiguration : public WxWidgetsConfigStore ConfigurationDataElement freedvReporterHostname; ConfigurationDataElement freedvReporterBandFilter; ConfigurationDataElement useMetricDistances; + ConfigurationDataElement freedvReporterBandFilterTracksFrequency; ConfigurationDataElement useUTCForReporting; diff --git a/src/freedv_reporter.cpp b/src/freedv_reporter.cpp index f7fe3b693..136c435e3 100644 --- a/src/freedv_reporter.cpp +++ b/src/freedv_reporter.cpp @@ -118,6 +118,10 @@ FreeDVReporterDialog::FreeDVReporterDialog(wxWindow* parent, wxWindowID id, cons buttonSizer->Add(m_bandFilter, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2); + m_trackFrequency = new wxCheckBox(this, wxID_ANY, _("Track current frequency"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + buttonSizer->Add(m_trackFrequency, 0, wxALL | wxALIGN_LEFT, 5); + m_trackFrequency->SetValue(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency); + m_buttonOK = new wxButton(this, wxID_OK, _("Close")); buttonSizer->Add(m_buttonOK, 0, wxALL, 2); @@ -167,15 +171,28 @@ FreeDVReporterDialog::FreeDVReporterDialog(wxWindow* parent, wxWindowID id, cons m_buttonDisplayWebpage->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FreeDVReporterDialog::OnOpenWebsite), NULL, this); m_bandFilter->Connect(wxEVT_TEXT, wxCommandEventHandler(FreeDVReporterDialog::OnBandFilterChange), NULL, this); - + m_trackFrequency->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this); + // Trigger sorting on last sorted column sortColumn_(wxGetApp().appConfiguration.reporterWindowCurrentSort, wxGetApp().appConfiguration.reporterWindowCurrentSortDirection); + + // Trigger filter update if we're starting with tracking enabled + if (wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency) + { + m_bandFilter->Enable(false); + + FilterFrequency freq = + getFilterForFrequency_(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency); + setBandFilter(freq); + } } FreeDVReporterDialog::~FreeDVReporterDialog() { m_highlightClearTimer->Stop(); + m_trackFrequency->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this); + this->Disconnect(wxEVT_TIMER, wxTimerEventHandler(FreeDVReporterDialog::OnTimer), NULL, this); this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(FreeDVReporterDialog::OnSize)); this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(FreeDVReporterDialog::OnInitDialog)); @@ -360,8 +377,38 @@ void FreeDVReporterDialog::OnTimer(wxTimerEvent& event) } } +void FreeDVReporterDialog::OnFilterTrackingEnable(wxCommandEvent& event) +{ + wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency + = m_trackFrequency->GetValue(); + m_bandFilter->Enable( + !wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency); + + FilterFrequency freq; + if (wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency) + { + freq = + getFilterForFrequency_(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency); + } + else + { + freq = + (FilterFrequency)wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilter.get(); + } + + setBandFilter(freq); +} + void FreeDVReporterDialog::refreshQSYButtonState() { + // Update filter if the frequency's changed. + if (wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency) + { + FilterFrequency freq = + getFilterForFrequency_(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency); + setBandFilter(freq); + } + bool enabled = false; auto selectedIndex = m_listSpots->GetFirstSelected(); if (selectedIndex >= 0) @@ -989,7 +1036,7 @@ bool FreeDVReporterDialog::setColumnForRow_(int row, int col, wxString val) return result; } -bool FreeDVReporterDialog::isFiltered_(uint64_t freq) +FreeDVReporterDialog::FilterFrequency FreeDVReporterDialog::getFilterForFrequency_(uint64_t freq) { auto bandForFreq = FilterFrequency::BAND_OTHER; @@ -1038,6 +1085,13 @@ bool FreeDVReporterDialog::isFiltered_(uint64_t freq) bandForFreq = FilterFrequency::BAND_VHF_UHF; } + return bandForFreq; +} + +bool FreeDVReporterDialog::isFiltered_(uint64_t freq) +{ + auto bandForFreq = getFilterForFrequency_(freq); + if (currentBandFilter_ == FilterFrequency::BAND_ALL) { return false; diff --git a/src/freedv_reporter.h b/src/freedv_reporter.h index 5d459198d..9c2c12418 100644 --- a/src/freedv_reporter.h +++ b/src/freedv_reporter.h @@ -84,6 +84,7 @@ class FreeDVReporterDialog : public wxDialog void OnItemDeselected(wxListEvent& event); void OnSortColumn(wxListEvent& event); void OnTimer(wxTimerEvent& event); + void OnFilterTrackingEnable(wxCommandEvent& event); // Main list box that shows spots wxListView* m_listSpots; @@ -96,6 +97,7 @@ class FreeDVReporterDialog : public wxDialog // Band filter wxComboBox* m_bandFilter; + wxCheckBox* m_trackFrequency; // Step 4: test/save/cancel setup wxButton* m_buttonOK; @@ -148,6 +150,7 @@ class FreeDVReporterDialog : public wxDialog wxString makeValidTime_(std::string timeStr, wxDateTime& timeObj); void addOrUpdateListIfNotFiltered_(ReporterData* data); + FilterFrequency getFilterForFrequency_(uint64_t freq); bool isFiltered_(uint64_t freq); bool setColumnForRow_(int row, int col, wxString val);