Skip to content

Commit 2ef8ee3

Browse files
disable rds symbol diagram data stream when not visible
1 parent 14cb839 commit 2ef8ee3

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

decoder_modules/radio/src/demodulators/wfm.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace demod {
4747

4848
// Init DSP
4949
demod.init(input, bandwidth / 2.0f, getIFSampleRate(), _stereo, _lowPass, _rds);
50-
rdsDemod.init(&demod.rdsOut);
50+
rdsDemod.init(&demod.rdsOut, _rdsInfo);
5151
hs.init(&rdsDemod.out, rdsHandler, this);
5252
reshape.init(&rdsDemod.soft, 4096, (1187 / 30) - 4096);
5353
diagHandler.init(&reshape.out, _diagHandler, this);
@@ -96,6 +96,7 @@ namespace demod {
9696
// TODO: This will break when the entire radio module is disabled
9797
if (!_rds) { ImGui::BeginDisabled(); }
9898
if (ImGui::Checkbox(("Advanced RDS Info##_radio_wfm_rds_info_" + name).c_str(), &_rdsInfo)) {
99+
setAdvancedRds(_rdsInfo);
99100
_config->acquire();
100101
_config->conf[name][getName()]["rdsInfo"] = _rdsInfo;
101102
_config->release(true);
@@ -229,13 +230,17 @@ namespace demod {
229230
demod.setStereo(_stereo);
230231
}
231232

233+
void setAdvancedRds(bool enabled) {
234+
rdsDemod.setSoftEnabled(enabled);
235+
_rdsInfo = enabled;
236+
}
237+
232238
private:
233239
static void rdsHandler(uint8_t* data, int count, void* ctx) {
234240
WFM* _this = (WFM*)ctx;
235241
_this->rdsDecode.process(data, count);
236242
}
237243

238-
// DEBUGGING ONLY
239244
static void _diagHandler(float* data, int count, void* ctx) {
240245
WFM* _this = (WFM*)ctx;
241246
float* buf = _this->diag.acquireBuffer();

decoder_modules/radio/src/rds_demod.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ class RDSDemod : public dsp::Processor<dsp::complex_t, uint8_t> {
1313
using base_type = dsp::Processor<dsp::complex_t, uint8_t>;
1414
public:
1515
RDSDemod() {}
16-
RDSDemod(dsp::stream<dsp::complex_t>* in) { init(in); }
16+
RDSDemod(dsp::stream<dsp::complex_t>* in, bool enableSoft) { init(in, enableSoft); }
1717
~RDSDemod() {}
1818

19-
void init(dsp::stream<dsp::complex_t>* in) {
19+
void init(dsp::stream<dsp::complex_t>* in, bool enableSoft) {
20+
// Save config
21+
this->enableSoft = enableSoft;
22+
2023
// Initialize the DSP
2124
agc.init(NULL, 1.0, 1e6, 0.1);
2225
costas.init(NULL, 0.005f);
@@ -37,6 +40,14 @@ class RDSDemod : public dsp::Processor<dsp::complex_t, uint8_t> {
3740
base_type::init(in);
3841
}
3942

43+
void setSoftEnabled(bool enable) {
44+
assert(base_type::_block_init);
45+
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
46+
base_type::tempStop();
47+
enableSoft = enable;
48+
base_type::tempStart();
49+
}
50+
4051
void reset() {
4152
assert(base_type::_block_init);
4253
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
@@ -70,13 +81,17 @@ class RDSDemod : public dsp::Processor<dsp::complex_t, uint8_t> {
7081

7182
base_type::_in->flush();
7283
if (!base_type::out.swap(count)) { return -1; }
73-
if (!soft.swap(count)) { return -1; }
84+
if (enableSoft) {
85+
if (!soft.swap(count)) { return -1; }
86+
}
7487
return count;
7588
}
7689

7790
dsp::stream<float> soft;
7891

7992
private:
93+
bool enableSoft = false;
94+
8095
dsp::loop::FastAGC<dsp::complex_t> agc;
8196
dsp::loop::Costas<2> costas;
8297
dsp::tap<dsp::complex_t> taps;

0 commit comments

Comments
 (0)