Skip to content

Commit

Permalink
Merge pull request #596 from drowe67/ms-filter-exact-freq
Browse files Browse the repository at this point in the history
FreeDV Reporter: Add support for filtering the exact frequency.
  • Loading branch information
tmiw authored Nov 4, 2023
2 parents c65e091 + 35f8133 commit 0c276d6
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 14 deletions.
1 change: 1 addition & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Add entitlements to work around macOS Sonoma permissions bug. (PR #598)
* Fix bug preventing FreeDV Reporter window from closing after resetting configuration to defaults. (PR #593)
2. Enhancements:
* FreeDV Reporter: Add support for filtering the exact frequency. (PR #596)
* Add confirmation dialog box before actually resetting configuration to defaults. (PR #593)
* Add ability to double-click FreeDV Reporter entries to change the radio's frequency. (PR #592)

Expand Down
6 changes: 6 additions & 0 deletions src/config/ReportingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ReportingConfiguration::ReportingConfiguration()
, freedvReporterBandFilter("/Reporting/FreeDV/CurrentBandFilter", 0)
, useMetricDistances("/Reporting/FreeDV/UseMetricDistances", true)
, freedvReporterBandFilterTracksFrequency("/Reporting/FreeDV/BandFilterTracksFrequency", false)
, freedvReporterBandFilterTracksFreqBand("/Reporting/FreeDV/BandFilterTracking/TracksFreqBand", true)
, freedvReporterBandFilterTracksExactFreq("/Reporting/FreeDV/BandFilterTracking/TracksExactFreq", false)

, useUTCForReporting("/CallsignList/UseUTCTime", false)

Expand Down Expand Up @@ -147,6 +149,8 @@ void ReportingConfiguration::load(wxConfigBase* config)
load_(config, freedvReporterBandFilter);
load_(config, useMetricDistances);
load_(config, freedvReporterBandFilterTracksFrequency);
load_(config, freedvReporterBandFilterTracksFreqBand);
load_(config, freedvReporterBandFilterTracksExactFreq);

load_(config, useUTCForReporting);

Expand Down Expand Up @@ -179,6 +183,8 @@ void ReportingConfiguration::save(wxConfigBase* config)
save_(config, freedvReporterBandFilter);
save_(config, useMetricDistances);
save_(config, freedvReporterBandFilterTracksFrequency);
save_(config, freedvReporterBandFilterTracksFreqBand);
save_(config, freedvReporterBandFilterTracksExactFreq);

save_(config, useUTCForReporting);

Expand Down
2 changes: 2 additions & 0 deletions src/config/ReportingConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class ReportingConfiguration : public WxWidgetsConfigStore
ConfigurationDataElement<int> freedvReporterBandFilter;
ConfigurationDataElement<bool> useMetricDistances;
ConfigurationDataElement<bool> freedvReporterBandFilterTracksFrequency;
ConfigurationDataElement<bool> freedvReporterBandFilterTracksFreqBand;
ConfigurationDataElement<bool> freedvReporterBandFilterTracksExactFreq;

ConfigurationDataElement<bool> useUTCForReporting;

Expand Down
35 changes: 32 additions & 3 deletions src/freedv_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,17 @@ 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);
m_trackFrequency = new wxCheckBox(this, wxID_ANY, _("Track current:"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
buttonSizer->Add(m_trackFrequency, 0, wxALL | wxALIGN_LEFT, 5);

m_trackFreqBand = new wxRadioButton(this, wxID_ANY, _("band"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
buttonSizer->Add(m_trackFreqBand, 0, wxALL | wxALIGN_LEFT, 5);
m_trackFreqBand->Enable(false);

m_trackExactFreq = new wxRadioButton(this, wxID_ANY, _("frequency"), wxDefaultPosition, wxDefaultSize, 0);
buttonSizer->Add(m_trackExactFreq, 0, wxALL | wxALIGN_LEFT, 5);
m_trackExactFreq->Enable(false);

m_trackFrequency->SetValue(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency);

m_buttonOK = new wxButton(this, wxID_OK, _("Close"));
Expand Down Expand Up @@ -175,14 +184,20 @@ FreeDVReporterDialog::FreeDVReporterDialog(wxWindow* parent, wxWindowID id, cons

m_bandFilter->Connect(wxEVT_TEXT, wxCommandEventHandler(FreeDVReporterDialog::OnBandFilterChange), NULL, this);
m_trackFrequency->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this);
m_trackFreqBand->Connect(wxEVT_RADIOBUTTON, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this);
m_trackExactFreq->Connect(wxEVT_RADIOBUTTON, 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
m_trackFreqBand->SetValue(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFreqBand);
m_trackExactFreq->SetValue(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksExactFreq);
if (wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency)
{
m_bandFilter->Enable(false);
m_trackFreqBand->Enable(true);
m_trackExactFreq->Enable(true);

FilterFrequency freq =
getFilterForFrequency_(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);
Expand All @@ -195,6 +210,8 @@ FreeDVReporterDialog::~FreeDVReporterDialog()
m_highlightClearTimer->Stop();

m_trackFrequency->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this);
m_trackFreqBand->Disconnect(wxEVT_RADIOBUTTON, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this);
m_trackExactFreq->Disconnect(wxEVT_RADIOBUTTON, wxCommandEventHandler(FreeDVReporterDialog::OnFilterTrackingEnable), NULL, this);

this->Disconnect(wxEVT_TIMER, wxTimerEventHandler(FreeDVReporterDialog::OnTimer), NULL, this);
this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(FreeDVReporterDialog::OnSize));
Expand Down Expand Up @@ -388,6 +405,14 @@ void FreeDVReporterDialog::OnFilterTrackingEnable(wxCommandEvent& event)
m_bandFilter->Enable(
!wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency);

m_trackFreqBand->Enable(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency);
m_trackExactFreq->Enable(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency);

wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFreqBand =
m_trackFreqBand->GetValue();
wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksExactFreq =
m_trackExactFreq->GetValue();

FilterFrequency freq;
if (wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency)
{
Expand Down Expand Up @@ -423,7 +448,7 @@ void FreeDVReporterDialog::refreshQSYButtonState()
FilterFrequency freq =
getFilterForFrequency_(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);

if (currentBandFilter_ != freq)
if (currentBandFilter_ != freq || wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksExactFreq)
{
setBandFilter(freq);
}
Expand Down Expand Up @@ -1136,6 +1161,10 @@ bool FreeDVReporterDialog::isFiltered_(uint64_t freq)
}
else
{
return bandForFreq != currentBandFilter_;
return
(bandForFreq != currentBandFilter_) ||
(wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksFrequency &&
wxGetApp().appConfiguration.reportingConfiguration.freedvReporterBandFilterTracksExactFreq &&
freq != wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);
}
}
2 changes: 2 additions & 0 deletions src/freedv_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class FreeDVReporterDialog : public wxDialog
// Band filter
wxComboBox* m_bandFilter;
wxCheckBox* m_trackFrequency;
wxRadioButton* m_trackFreqBand;
wxRadioButton* m_trackExactFreq;

// Step 4: test/save/cancel setup
wxButton* m_buttonOK;
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ class MainFrame : public TopFrame
float vk_rx_time;
float vk_rx_sync_time;
bool suppressFreqModeUpdates_;
bool firstFreqUpdateOnConnect_;

std::string vkFileName_;

Expand Down
32 changes: 21 additions & 11 deletions src/ongui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ bool MainFrame::OpenHamlibRig() {
wxGetApp().appConfiguration.rigControlConfiguration.hamlibEnableFreqModeChanges);

// Hamlib also controls PTT.
firstFreqUpdateOnConnect_ = false;
wxGetApp().rigFrequencyController = tmp;
wxGetApp().rigPttController = tmp;

Expand All @@ -343,6 +344,11 @@ bool MainFrame::OpenHamlibRig() {
wxGetApp().appConfiguration.rigControlConfiguration.hamlibEnableFreqModeChanges &&
wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency > 0)
{
// Suppress the frequency update message that will occur immediately after
// connect; this will prevent overwriting of whatever's in the text box.
firstFreqUpdateOnConnect_ = true;

// Set frequency/mode to the one pre-selected by the user before start.
wxGetApp().rigFrequencyController->setFrequency(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);
wxGetApp().rigFrequencyController->setMode(getCurrentMode_());
}
Expand All @@ -358,6 +364,12 @@ bool MainFrame::OpenHamlibRig() {
wxGetApp().rigFrequencyController->onFreqModeChange += [&](IRigFrequencyController*, uint64_t freq, IRigFrequencyController::Mode mode)
{
CallAfter([&, mode, freq]() {
if (firstFreqUpdateOnConnect_)
{
firstFreqUpdateOnConnect_ = false;
return;
}

// Update string value.
switch(mode)
{
Expand Down Expand Up @@ -422,8 +434,6 @@ bool MainFrame::OpenHamlibRig() {
});
};

// Temporarily suppress frequency updates until we're fully connected.
suppressFreqModeUpdates_ = true;
wxGetApp().rigFrequencyController->connect();
return true;
}
Expand Down Expand Up @@ -1027,15 +1037,15 @@ void MainFrame::OnChangeReportFrequency( wxCommandEvent& event )
wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency = 0;
m_cboReportFrequency->SetForegroundColour(wxColor(*wxRED));
}

// Report current frequency to reporters
for (auto& ptr : wxGetApp().m_reporters)
{
ptr->freqChange(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);
}

if (oldFreq != wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency)
{
// Report current frequency to reporters
for (auto& ptr : wxGetApp().m_reporters)
{
ptr->freqChange(wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency);
}

{
if (wxGetApp().rigFrequencyController != nullptr &&
wxGetApp().appConfiguration.reportingConfiguration.reportingFrequency > 0 &&
wxGetApp().appConfiguration.rigControlConfiguration.hamlibEnableFreqModeChanges)
Expand All @@ -1060,11 +1070,11 @@ void MainFrame::OnReportFrequencySetFocus(wxFocusEvent& event)

void MainFrame::OnReportFrequencyKillFocus(wxFocusEvent& event)
{
suppressFreqModeUpdates_ = false;

// Handle any frequency changes as appropriate.
wxCommandEvent tmpEvent;
OnChangeReportFrequency(tmpEvent);

suppressFreqModeUpdates_ = false;

TopFrame::OnReportFrequencyKillFocus(event);
}
Expand Down

0 comments on commit 0c276d6

Please sign in to comment.