Skip to content

Commit

Permalink
Merge pull request #534 from drowe67/ms-reporter-track-freq
Browse files Browse the repository at this point in the history
Add FreeDV Reporter option to have the band filter track the current frequency.
  • Loading branch information
tmiw authored Sep 12, 2023
2 parents 6e9e344 + b156047 commit f71a976
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/config/ReportingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -88,6 +89,7 @@ void ReportingConfiguration::load(wxConfigBase* config)
load_(config, freedvReporterHostname);
load_(config, freedvReporterBandFilter);
load_(config, useMetricDistances);
load_(config, freedvReporterBandFilterTracksFrequency);

load_(config, useUTCForReporting);

Expand All @@ -114,6 +116,7 @@ void ReportingConfiguration::save(wxConfigBase* config)
save_(config, freedvReporterHostname);
save_(config, freedvReporterBandFilter);
save_(config, useMetricDistances);
save_(config, freedvReporterBandFilterTracksFrequency);

save_(config, useUTCForReporting);

Expand Down
1 change: 1 addition & 0 deletions src/config/ReportingConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ReportingConfiguration : public WxWidgetsConfigStore
ConfigurationDataElement<wxString> freedvReporterHostname;
ConfigurationDataElement<int> freedvReporterBandFilter;
ConfigurationDataElement<bool> useMetricDistances;
ConfigurationDataElement<bool> freedvReporterBandFilterTracksFrequency;

ConfigurationDataElement<bool> useUTCForReporting;

Expand Down
58 changes: 56 additions & 2 deletions src/freedv_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/freedv_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f71a976

Please sign in to comment.