Skip to content

Commit

Permalink
Merge pull request #460 from drowe67/ms-frequency-list
Browse files Browse the repository at this point in the history
Add support for modifying the drop down frequency list.
  • Loading branch information
tmiw authored Jul 9, 2023
2 parents 86d8869 + 10d90bb commit 450c8a4
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 38 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Minimum OS X deployment version")

set(PROJECT_NAME FreeDV)
set(PROJECT_VERSION 1.8.11)
set(PROJECT_VERSION 1.8.12)
set(PROJECT_DESCRIPTION "HF Digital Voice for Radio Amateurs")
set(PROJECT_HOMEPAGE_URL "https://freedv.org")

Expand All @@ -42,7 +42,7 @@ endif(APPLE)

# Adds a tag to the end of the version string. Leave empty
# for official release builds.
set(FREEDV_VERSION_TAG "")
set(FREEDV_VERSION_TAG "devel")

# Prevent in-source builds to protect automake/autoconf config.
# If an in-source build is attempted, you will still need to clean up a few
Expand Down
1 change: 1 addition & 0 deletions USER_MANUAL.html
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ <h2 data-number="17.1" id="v1.8.12-tbd-2023"><span class="header-section-number"
<li>Set minimum size for Mode box to 250px. (PR #446)</li>
<li>Notify FreeDV Reporter if only capable of RX. (PR #449)</li>
<li>Hamlib: allow frequency and mode changes during TX. (PR #455)</li>
<li>Add support for modifying the drop down frequency list. (PR #460)</li>
</ul></li>
<li>Build system:
<ul>
Expand Down
1 change: 1 addition & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Set minimum size for Mode box to 250px. (PR #446)
* Notify FreeDV Reporter if only capable of RX. (PR #449)
* Hamlib: allow frequency and mode changes during TX. (PR #455)
* Add support for modifying the drop down frequency list. (PR #460)
3. Build system:
* Bump Codec2 version to v1.1.1. (PR #437)
4. Cleanup:
Expand Down
Binary file modified USER_MANUAL.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions src/config/ReportingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ ReportingConfiguration::ReportingConfiguration()
, freedvReporterHostname("/Reporting/FreeDV/Hostname", wxT(FREEDV_REPORTER_DEFAULT_HOSTNAME))

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

, reportingFrequencyList("/Reporting/FrequencyList", {
_("3.6250"),
_("3.6430"),
_("3.6930"),
_("3.6970"),
_("5.4035"),
_("5.3665"),
_("7.1770"),
_("14.2360"),
_("14.2400"),
_("18.1180"),
_("21.3130"),
_("24.9330"),
_("28.3300"),
_("28.7200"),
_("10489.6400"),
})
{
// empty
}
Expand Down Expand Up @@ -67,6 +85,8 @@ void ReportingConfiguration::load(wxConfigBase* config)

load_(config, useUTCForReporting);

load_(config, reportingFrequencyList);

// Special load handling for reporting below.
wxString freqStr = config->Read(reportingFrequency.getElementName(), oldFreqStr);
reportingFrequency.setWithoutProcessing(atoll(freqStr.ToUTF8()));
Expand All @@ -87,6 +107,8 @@ void ReportingConfiguration::save(wxConfigBase* config)

save_(config, useUTCForReporting);

save_(config, reportingFrequencyList);

// Special save handling for reporting below.
wxString tempFreqStr = wxString::Format(wxT("%" PRIu64), reportingFrequency.getWithoutProcessing());
config->Write(reportingFrequency.getElementName(), tempFreqStr);
Expand Down
2 changes: 2 additions & 0 deletions src/config/ReportingConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ReportingConfiguration : public WxWidgetsConfigStore

ConfigurationDataElement<bool> useUTCForReporting;

ConfigurationDataElement<std::vector<wxString> > reportingFrequencyList;

virtual void load(wxConfigBase* config) override;
virtual void save(wxConfigBase* config) override;
};
Expand Down
53 changes: 53 additions & 0 deletions src/config/WxWidgetsConfigStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//
//==========================================================================

#include <wx/tokenzr.h>
#include "WxWidgetsConfigStore.h"

template<>
Expand All @@ -27,4 +28,56 @@ void WxWidgetsConfigStore::load_<unsigned int>(wxConfigBase* config, Configurati
long val;
config->Read(configElement.getElementName(), &val, (long)configElement.getDefaultVal());
configElement.setWithoutProcessing((unsigned int)val);
}

/* Note: for string arrays, we're treating them as a list of strings separated by commas. */

template<>
void WxWidgetsConfigStore::load_<std::vector<wxString> >(wxConfigBase* config, ConfigurationDataElement<std::vector<wxString> >& configElement)
{
wxString val;
wxString defaultVal = generateStringFromArray_(configElement.getDefaultVal());

config->Read(configElement.getElementName(), &val, defaultVal);
configElement.setWithoutProcessing(generateArayFromString_(val));
}

template<>
void WxWidgetsConfigStore::save_<std::vector<wxString> >(wxConfigBase* config, ConfigurationDataElement<std::vector<wxString> >& configElement)
{
wxString val = generateStringFromArray_(configElement.getWithoutProcessing());
config->Write(configElement.getElementName(), val);
}

wxString WxWidgetsConfigStore::generateStringFromArray_(std::vector<wxString> vec)
{
wxString rv = "";

int count = vec.size();
for (auto& item : vec)
{
rv += item;
count--;

if (count > 0)
{
rv += ",";
}
}

return rv;
}

std::vector<wxString> WxWidgetsConfigStore::generateArayFromString_(wxString str)
{
std::vector<wxString> rv;

wxStringTokenizer tokenizer(str, ",");
while ( tokenizer.HasMoreTokens() )
{
wxString token = tokenizer.GetNextToken();
rv.push_back(token);
}

return rv;
}
10 changes: 10 additions & 0 deletions src/config/WxWidgetsConfigStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef WXWIDGETS_CONFIG_STORE_H
#define WXWIDGETS_CONFIG_STORE_H

#include <vector>
#include <wx/config.h>
#include "ConfigurationDataElement.h"

Expand All @@ -39,6 +40,9 @@ class WxWidgetsConfigStore

template<typename UnderlyingDataType>
void save_(wxConfigBase* config, ConfigurationDataElement<UnderlyingDataType>& configElement);

wxString generateStringFromArray_(std::vector<wxString> vec);
std::vector<wxString> generateArayFromString_(wxString str);
};

template<typename UnderlyingDataType>
Expand All @@ -58,4 +62,10 @@ void WxWidgetsConfigStore::save_(wxConfigBase* config, ConfigurationDataElement<
template<>
void WxWidgetsConfigStore::load_<unsigned int>(wxConfigBase* config, ConfigurationDataElement<unsigned int>& configElement);

// Special handling for loading and saving string arrays.
template<>
void WxWidgetsConfigStore::load_<std::vector<wxString> >(wxConfigBase* config, ConfigurationDataElement<std::vector<wxString> >& configElement);
template<>
void WxWidgetsConfigStore::save_<std::vector<wxString> >(wxConfigBase* config, ConfigurationDataElement<std::vector<wxString> >& configElement);

#endif // WXWIDGETS_CONFIG_STORE_H
Loading

0 comments on commit 450c8a4

Please sign in to comment.