77#include < rds.h>
88
99namespace demod {
10+ enum RDSRegion {
11+ RDS_REGION_EUROPE,
12+ RDS_REGION_NORTH_AMERICA
13+ };
14+
1015 class WFM : public Demodulator {
1116 public:
1217 WFM () : diag(0.5 , 4096 ) {}
@@ -24,10 +29,18 @@ namespace demod {
2429 this ->name = name;
2530 _config = config;
2631
32+ // Define RDS regions
33+ rdsRegions.define (" eu" , " Europe" , RDS_REGION_EUROPE);
34+ rdsRegions.define (" na" , " North America" , RDS_REGION_NORTH_AMERICA);
35+
36+ // Register FFT draw handler
2737 fftRedrawHandler.handler = fftRedraw;
2838 fftRedrawHandler.ctx = this ;
2939 gui::waterfall.onFFTRedraw .bindHandler (&fftRedrawHandler);
3040
41+ // Default
42+ std::string rdsRegionStr = " eu" ;
43+
3144 // Load config
3245 _config->acquire ();
3346 bool modified = false ;
@@ -43,8 +56,21 @@ namespace demod {
4356 if (config->conf [name][getName ()].contains (" rdsInfo" )) {
4457 _rdsInfo = config->conf [name][getName ()][" rdsInfo" ];
4558 }
59+ if (config->conf [name][getName ()].contains (" rdsRegion" )) {
60+ rdsRegionStr = config->conf [name][getName ()][" rdsRegion" ];
61+ }
4662 _config->release (modified);
4763
64+ // Load RDS region
65+ if (rdsRegions.keyExists (rdsRegionStr)) {
66+ rdsRegionId = rdsRegions.keyId (rdsRegionStr);
67+ rdsRegion = rdsRegions.value (rdsRegionId);
68+ }
69+ else {
70+ rdsRegion = RDS_REGION_EUROPE;
71+ rdsRegionId = rdsRegions.valueId (rdsRegion);
72+ }
73+
4874 // Init DSP
4975 demod.init (input, bandwidth / 2 .0f , getIFSampleRate (), _stereo, _lowPass, _rds);
5076 rdsDemod.init (&demod.rdsOut , _rdsInfo);
@@ -93,14 +119,22 @@ namespace demod {
93119 _config->release (true );
94120 }
95121
96- // TODO: This will break when the entire radio module is disabled
122+ // TODO: This might break when the entire radio module is disabled
97123 if (!_rds) { ImGui::BeginDisabled (); }
98124 if (ImGui::Checkbox ((" Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str (), &_rdsInfo)) {
99125 setAdvancedRds (_rdsInfo);
100126 _config->acquire ();
101127 _config->conf [name][getName ()][" rdsInfo" ] = _rdsInfo;
102128 _config->release (true );
103129 }
130+ ImGui::SameLine ();
131+ ImGui::FillWidth ();
132+ if (ImGui::Combo ((" ##_radio_wfm_rds_region_" + name).c_str (), &rdsRegionId, rdsRegions.txt )) {
133+ rdsRegion = rdsRegions.value (rdsRegionId);
134+ _config->acquire ();
135+ _config->conf [name][getName ()][" rdsRegion" ] = rdsRegions.key (rdsRegionId);
136+ _config->release (true );
137+ }
104138 if (!_rds) { ImGui::EndDisabled (); }
105139
106140 float menuWidth = ImGui::GetContentRegionAvail ().x ;
@@ -112,7 +146,12 @@ namespace demod {
112146 ImGui::TableSetColumnIndex (0 );
113147 ImGui::TextUnformatted (" PI Code" );
114148 ImGui::TableSetColumnIndex (1 );
115- ImGui::Text (" 0x%04X (%s)" , rdsDecode.getPICode (), rdsDecode.getCallsign ().c_str ());
149+ if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
150+ ImGui::Text (" 0x%04X (%s)" , rdsDecode.getPICode (), rdsDecode.getCallsign ().c_str ());
151+ }
152+ else {
153+ ImGui::Text (" 0x%04X" , rdsDecode.getPICode ());
154+ }
116155
117156 ImGui::TableNextRow ();
118157 ImGui::TableSetColumnIndex (0 );
@@ -137,7 +176,12 @@ namespace demod {
137176 ImGui::TableSetColumnIndex (0 );
138177 ImGui::TextUnformatted (" PI Code" );
139178 ImGui::TableSetColumnIndex (1 );
140- ImGui::TextUnformatted (" 0x---- (----)" );
179+ if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
180+ ImGui::TextUnformatted (" 0x---- (----)" );
181+ }
182+ else {
183+ ImGui::TextUnformatted (" 0x----" );
184+ }
141185
142186 ImGui::TableNextRow ();
143187 ImGui::TableSetColumnIndex (0 );
@@ -163,7 +207,12 @@ namespace demod {
163207 ImGui::TableSetColumnIndex (0 );
164208 ImGui::TextUnformatted (" Program Type" );
165209 ImGui::TableSetColumnIndex (1 );
166- ImGui::Text (" %s (%d)" , rds::PROGRAM_TYPE_US_TO_STR[rdsDecode.getProgramType ()], rdsDecode.getProgramType ());
210+ if (rdsRegion == RDS_REGION_NORTH_AMERICA) {
211+ ImGui::Text (" %s (%d)" , rds::PROGRAM_TYPE_US_TO_STR[rdsDecode.getProgramType ()], rdsDecode.getProgramType ());
212+ }
213+ else {
214+ ImGui::Text (" %s (%d)" , rds::PROGRAM_TYPE_EU_TO_STR[rdsDecode.getProgramType ()], rdsDecode.getProgramType ());
215+ }
167216 }
168217 else {
169218 ImGui::TableNextRow ();
@@ -308,6 +357,12 @@ namespace demod {
308357 float muGain = 0.01 ;
309358 float omegaGain = (0.01 *0.01 )/4.0 ;
310359
360+ int rdsRegionId = 0 ;
361+ RDSRegion rdsRegion = RDS_REGION_EUROPE;
362+
363+ OptionList<std::string, RDSRegion> rdsRegions;
364+
365+
311366 std::string name;
312367 };
313368}
0 commit comments