From 860121dad27c2f5341bdbc52c201c68c568e3a69 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Sat, 29 Jan 2022 16:55:31 +0100 Subject: [PATCH] Added CW tone option plus clean up --- decoder_modules/radio/src/demodulators/cw.h | 25 ++++++++++++++++++-- decoder_modules/radio/src/demodulators/wfm.h | 4 ---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/decoder_modules/radio/src/demodulators/cw.h b/decoder_modules/radio/src/demodulators/cw.h index 8443917a..b1a59193 100644 --- a/decoder_modules/radio/src/demodulators/cw.h +++ b/decoder_modules/radio/src/demodulators/cw.h @@ -18,10 +18,18 @@ namespace demod { void init(std::string name, ConfigManager* config, dsp::stream* input, double bandwidth, EventHandler*> outputChangeHandler, double audioSR) { this->name = name; + this->_config = config; this->outputChangeHandler = outputChangeHandler; + // Load config + config->acquire(); + if (config->conf[name][getName()].contains("tone")) { + tone = config->conf[name][getName()]["tone"]; + } + config->release(); + // Define structure - xlator.init(input, getIFSampleRate(), 1000.0); + xlator.init(input, getIFSampleRate(), tone); c2r.init(&xlator.out); agc.init(&c2r.out, 20.0f, getIFSampleRate()); m2s.init(&agc.out); @@ -41,7 +49,17 @@ namespace demod { m2s.stop(); } - void showMenu() {} + void showMenu() { + ImGui::LeftLabel("Tone Frequency"); + ImGui::FillWidth(); + if (ImGui::InputInt(("Stereo##_radio_cw_tone_" + name).c_str(), &tone, 10, 100)) { + tone = std::clamp(tone, 250, 1250); + xlator.setFrequency(tone); + _config->acquire(); + _config->conf[name][getName()]["tone"] = tone; + _config->release(true); + } + } void setBandwidth(double bandwidth) {} @@ -73,6 +91,7 @@ namespace demod { dsp::stream* getOutput() { return &m2s.out; } private: + ConfigManager* _config = NULL; dsp::FrequencyXlator xlator; dsp::ComplexToReal c2r; dsp::AGC agc; @@ -80,5 +99,7 @@ namespace demod { std::string name; EventHandler*> outputChangeHandler; + + int tone = 800; }; } \ No newline at end of file diff --git a/decoder_modules/radio/src/demodulators/wfm.h b/decoder_modules/radio/src/demodulators/wfm.h index 7ca1a11f..6a48c3c7 100644 --- a/decoder_modules/radio/src/demodulators/wfm.h +++ b/decoder_modules/radio/src/demodulators/wfm.h @@ -24,10 +24,6 @@ namespace demod { // Load config _config->acquire(); bool modified = false; - if (!config->conf[name].contains(getName())) { - config->conf[name][getName()]["stereo"] = false; - modified = true; - } if (config->conf[name][getName()].contains("stereo")) { stereo = config->conf[name][getName()]["stereo"]; }