mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-02-04 21:54:45 +01:00
add rds region selection
This commit is contained in:
parent
120745de19
commit
f8183739f7
@ -7,6 +7,11 @@
|
|||||||
#include <rds.h>
|
#include <rds.h>
|
||||||
|
|
||||||
namespace demod {
|
namespace demod {
|
||||||
|
enum RDSRegion {
|
||||||
|
RDS_REGION_EUROPE,
|
||||||
|
RDS_REGION_NORTH_AMERICA
|
||||||
|
};
|
||||||
|
|
||||||
class WFM : public Demodulator {
|
class WFM : public Demodulator {
|
||||||
public:
|
public:
|
||||||
WFM() : diag(0.5, 4096) {}
|
WFM() : diag(0.5, 4096) {}
|
||||||
@ -24,10 +29,18 @@ namespace demod {
|
|||||||
this->name = name;
|
this->name = name;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
|
// Define RDS regions
|
||||||
|
rdsRegions.define("eu", "Europe", RDS_REGION_EUROPE);
|
||||||
|
rdsRegions.define("na", "North America", RDS_REGION_NORTH_AMERICA);
|
||||||
|
|
||||||
|
// Register FFT draw handler
|
||||||
fftRedrawHandler.handler = fftRedraw;
|
fftRedrawHandler.handler = fftRedraw;
|
||||||
fftRedrawHandler.ctx = this;
|
fftRedrawHandler.ctx = this;
|
||||||
gui::waterfall.onFFTRedraw.bindHandler(&fftRedrawHandler);
|
gui::waterfall.onFFTRedraw.bindHandler(&fftRedrawHandler);
|
||||||
|
|
||||||
|
// Default
|
||||||
|
std::string rdsRegionStr = "eu";
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
_config->acquire();
|
_config->acquire();
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
@ -43,8 +56,21 @@ namespace demod {
|
|||||||
if (config->conf[name][getName()].contains("rdsInfo")) {
|
if (config->conf[name][getName()].contains("rdsInfo")) {
|
||||||
_rdsInfo = config->conf[name][getName()]["rdsInfo"];
|
_rdsInfo = config->conf[name][getName()]["rdsInfo"];
|
||||||
}
|
}
|
||||||
|
if (config->conf[name][getName()].contains("rdsRegion")) {
|
||||||
|
rdsRegionStr = config->conf[name][getName()]["rdsRegion"];
|
||||||
|
}
|
||||||
_config->release(modified);
|
_config->release(modified);
|
||||||
|
|
||||||
|
// Load RDS region
|
||||||
|
if (rdsRegions.keyExists(rdsRegionStr)) {
|
||||||
|
rdsRegionId = rdsRegions.keyId(rdsRegionStr);
|
||||||
|
rdsRegion = rdsRegions.value(rdsRegionId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rdsRegion = RDS_REGION_EUROPE;
|
||||||
|
rdsRegionId = rdsRegions.valueId(rdsRegion);
|
||||||
|
}
|
||||||
|
|
||||||
// Init DSP
|
// Init DSP
|
||||||
demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds);
|
demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds);
|
||||||
rdsDemod.init(&demod.rdsOut, _rdsInfo);
|
rdsDemod.init(&demod.rdsOut, _rdsInfo);
|
||||||
@ -93,7 +119,7 @@ namespace demod {
|
|||||||
_config->release(true);
|
_config->release(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This will break when the entire radio module is disabled
|
// TODO: This might break when the entire radio module is disabled
|
||||||
if (!_rds) { ImGui::BeginDisabled(); }
|
if (!_rds) { ImGui::BeginDisabled(); }
|
||||||
if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) {
|
if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) {
|
||||||
setAdvancedRds(_rdsInfo);
|
setAdvancedRds(_rdsInfo);
|
||||||
@ -101,6 +127,14 @@ namespace demod {
|
|||||||
_config->conf[name][getName()]["rdsInfo"] = _rdsInfo;
|
_config->conf[name][getName()]["rdsInfo"] = _rdsInfo;
|
||||||
_config->release(true);
|
_config->release(true);
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::FillWidth();
|
||||||
|
if (ImGui::Combo(("##_radio_wfm_rds_region_" + name).c_str(), &rdsRegionId, rdsRegions.txt)) {
|
||||||
|
rdsRegion = rdsRegions.value(rdsRegionId);
|
||||||
|
_config->acquire();
|
||||||
|
_config->conf[name][getName()]["rdsRegion"] = rdsRegions.key(rdsRegionId);
|
||||||
|
_config->release(true);
|
||||||
|
}
|
||||||
if (!_rds) { ImGui::EndDisabled(); }
|
if (!_rds) { ImGui::EndDisabled(); }
|
||||||
|
|
||||||
float menuWidth = ImGui::GetContentRegionAvail().x;
|
float menuWidth = ImGui::GetContentRegionAvail().x;
|
||||||
@ -112,7 +146,12 @@ namespace demod {
|
|||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::TextUnformatted("PI Code");
|
ImGui::TextUnformatted("PI Code");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||||
ImGui::Text("0x%04X (%s)", rdsDecode.getPICode(), rdsDecode.getCallsign().c_str());
|
ImGui::Text("0x%04X (%s)", rdsDecode.getPICode(), rdsDecode.getCallsign().c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGui::Text("0x%04X", rdsDecode.getPICode());
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
@ -137,7 +176,12 @@ namespace demod {
|
|||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::TextUnformatted("PI Code");
|
ImGui::TextUnformatted("PI Code");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||||
ImGui::TextUnformatted("0x---- (----)");
|
ImGui::TextUnformatted("0x---- (----)");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGui::TextUnformatted("0x----");
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
@ -163,8 +207,13 @@ namespace demod {
|
|||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::TextUnformatted("Program Type");
|
ImGui::TextUnformatted("Program Type");
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
|
||||||
ImGui::Text("%s (%d)", rds::PROGRAM_TYPE_US_TO_STR[rdsDecode.getProgramType()], rdsDecode.getProgramType());
|
ImGui::Text("%s (%d)", rds::PROGRAM_TYPE_US_TO_STR[rdsDecode.getProgramType()], rdsDecode.getProgramType());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ImGui::Text("%s (%d)", rds::PROGRAM_TYPE_EU_TO_STR[rdsDecode.getProgramType()], rdsDecode.getProgramType());
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
@ -308,6 +357,12 @@ namespace demod {
|
|||||||
float muGain = 0.01;
|
float muGain = 0.01;
|
||||||
float omegaGain = (0.01*0.01)/4.0;
|
float omegaGain = (0.01*0.01)/4.0;
|
||||||
|
|
||||||
|
int rdsRegionId = 0;
|
||||||
|
RDSRegion rdsRegion = RDS_REGION_EUROPE;
|
||||||
|
|
||||||
|
OptionList<std::string, RDSRegion> rdsRegions;
|
||||||
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user