From a4c25280b36d7acb94a0bf8a6adfb853c1e0c519 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Thu, 22 Apr 2021 05:38:25 +0200 Subject: [PATCH] bunch of stuff idk i'm tired --- core/src/signal_path/vfo_manager.cpp | 11 +++++++++++ core/src/signal_path/vfo_manager.h | 2 ++ radio/src/am_demod.h | 11 +++++++---- radio/src/cw_demod.h | 11 +++++++---- radio/src/dsb_demod.h | 11 +++++++---- radio/src/fm_demod.h | 11 +++++++---- radio/src/lsb_demod.h | 11 +++++++---- radio/src/main.cpp | 7 ++++--- radio/src/raw_demod.h | 13 ++++++++----- radio/src/usb_demod.h | 11 +++++++---- 10 files changed, 67 insertions(+), 32 deletions(-) diff --git a/core/src/signal_path/vfo_manager.cpp b/core/src/signal_path/vfo_manager.cpp index dbe8e8c1..ef7a6477 100644 --- a/core/src/signal_path/vfo_manager.cpp +++ b/core/src/signal_path/vfo_manager.cpp @@ -30,6 +30,10 @@ void VFOManager::VFO::setOffset(double offset) { dspVFO->setOffset(wtfVFO->centerOffset); } +double VFOManager::VFO::getOffset() { + return wtfVFO->generalOffset; +} + void VFOManager::VFO::setCenterOffset(double offset) { wtfVFO->setCenterOffset(offset); dspVFO->setOffset(offset); @@ -104,6 +108,13 @@ void VFOManager::setOffset(std::string name, double offset) { vfos[name]->setOffset(offset); } +double VFOManager::getOffset(std::string name) { + if (vfos.find(name) == vfos.end()) { + return 0; + } + return vfos[name]->getOffset(); +} + void VFOManager::setCenterOffset(std::string name, double offset) { if (vfos.find(name) == vfos.end()) { return; diff --git a/core/src/signal_path/vfo_manager.h b/core/src/signal_path/vfo_manager.h index e255790f..8bc2fd90 100644 --- a/core/src/signal_path/vfo_manager.h +++ b/core/src/signal_path/vfo_manager.h @@ -13,6 +13,7 @@ public: ~VFO(); void setOffset(double offset); + double getOffset(); void setCenterOffset(double offset); void setBandwidth(double bandwidth, bool updateWaterfall = true); void setSampleRate(double sampleRate, double bandwidth); @@ -37,6 +38,7 @@ public: void deleteVFO(VFOManager::VFO* vfo); void setOffset(std::string name, double offset); + double getOffset(std::string name); void setCenterOffset(std::string name, double offset); void setBandwidth(std::string name, double bandwidth, bool updateWaterfall = true); void setSampleRate(std::string name, double sampleRate, double bandwidth); diff --git a/radio/src/am_demod.h b/radio/src/am_demod.h index 54752397..889c8302 100644 --- a/radio/src/am_demod.h +++ b/radio/src/am_demod.h @@ -26,16 +26,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("AM")) { - if (!_config->conf[prefix]["AM"].contains("bandwidth")) { _config->conf[prefix]["AM"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["AM"].contains("snapInterval")) { _config->conf[prefix]["AM"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["AM"]["bandwidth"] = bw; + _config->conf[prefix]["AM"]["snapInterval"] = snapInterval; + _config->conf[prefix]["AM"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["AM"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["AM"]["bandwidth"] = bw; _config->conf[prefix]["AM"]["snapInterval"] = snapInterval; + _config->conf[prefix]["AM"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/cw_demod.h b/radio/src/cw_demod.h index bcf0e2aa..fbd76b0a 100644 --- a/radio/src/cw_demod.h +++ b/radio/src/cw_demod.h @@ -29,16 +29,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("CW")) { - if (!_config->conf[prefix]["CW"].contains("bandwidth")) { _config->conf[prefix]["CW"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["CW"].contains("snapInterval")) { _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["CW"]["bandwidth"] = bw; + _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; + _config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["CW"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["CW"]["bandwidth"] = bw; _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; + _config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/dsb_demod.h b/radio/src/dsb_demod.h index 6887a18e..d8aa72e4 100644 --- a/radio/src/dsb_demod.h +++ b/radio/src/dsb_demod.h @@ -26,16 +26,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("DSB")) { - if (!_config->conf[prefix]["DSB"].contains("bandwidth")) { _config->conf[prefix]["DSB"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["DSB"].contains("snapInterval")) { _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["DSB"]["bandwidth"] = bw; + _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["DSB"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["DSB"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["DSB"]["bandwidth"] = bw; _config->conf[prefix]["DSB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["DSB"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/fm_demod.h b/radio/src/fm_demod.h index e326e6bc..16a808cd 100644 --- a/radio/src/fm_demod.h +++ b/radio/src/fm_demod.h @@ -26,16 +26,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("FM")) { - if (!_config->conf[prefix]["FM"].contains("bandwidth")) { _config->conf[prefix]["FM"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["FM"].contains("snapInterval")) { _config->conf[prefix]["FM"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["FM"]["bandwidth"] = bw; + _config->conf[prefix]["FM"]["snapInterval"] = snapInterval; + _config->conf[prefix]["FM"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["FM"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["FM"]["bandwidth"] = bw; _config->conf[prefix]["FM"]["snapInterval"] = snapInterval; + _config->conf[prefix]["FM"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/lsb_demod.h b/radio/src/lsb_demod.h index f237bf06..b96fb186 100644 --- a/radio/src/lsb_demod.h +++ b/radio/src/lsb_demod.h @@ -26,16 +26,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("LSB")) { - if (!_config->conf[prefix]["LSB"].contains("bandwidth")) { _config->conf[prefix]["LSB"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["LSB"].contains("snapInterval")) { _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["LSB"]["bandwidth"] = bw; + _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["LSB"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["LSB"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["LSB"]["bandwidth"] = bw; _config->conf[prefix]["LSB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["LSB"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 8fabe838..50012d66 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -73,7 +73,8 @@ public: } void enable() { - vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 200000, 200000, 50000, 200000, false); + double bw = gui::waterfall.getBandwidth(); + vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, std::clamp(savedOffset, -bw/2.0, bw/2.0), 200000, 200000, 50000, 200000, false); wfmDemod.setVFO(vfo); fmDemod.setVFO(vfo); @@ -91,9 +92,8 @@ public: void disable() { currentDemod->stop(); + savedOffset = vfo->getOffset(); sigpath::vfoManager.deleteVFO(vfo); - //ns.setInput(vfo->output); - //ns.start(); enabled = false; } @@ -194,6 +194,7 @@ private: bool enabled = true; int demodId = 0; float audioSampRate = 48000; + double savedOffset; Demodulator* currentDemod = NULL; VFOManager::VFO* vfo; diff --git a/radio/src/raw_demod.h b/radio/src/raw_demod.h index d29ac926..a25c156e 100644 --- a/radio/src/raw_demod.h +++ b/radio/src/raw_demod.h @@ -25,14 +25,17 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { - if(!_config->conf[prefix].contains("RAW")) { - if (!_config->conf[prefix]["RAW"].contains("snapInterval")) { _config->conf[prefix]["RAW"]["snapInterval"] = snapInterval; } + if(!_config->conf[prefix].contains("CW")) { + _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; + _config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel; } - json conf = _config->conf[prefix]["RAW"]; - snapInterval = conf["snapInterval"]; + json conf = _config->conf[prefix]["CW"]; + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { - _config->conf[prefix]["RAW"]["snapInterval"] = snapInterval; + _config->conf[prefix]["CW"]["snapInterval"] = snapInterval; + _config->conf[prefix]["CW"]["squelchLevel"] = squelchLevel; } _config->release(true); diff --git a/radio/src/usb_demod.h b/radio/src/usb_demod.h index e3ed4ac7..071bea65 100644 --- a/radio/src/usb_demod.h +++ b/radio/src/usb_demod.h @@ -26,16 +26,19 @@ public: _config->aquire(); if(_config->conf.contains(prefix)) { if(!_config->conf[prefix].contains("USB")) { - if (!_config->conf[prefix]["USB"].contains("bandwidth")) { _config->conf[prefix]["USB"]["bandwidth"] = bw; } - if (!_config->conf[prefix]["USB"].contains("snapInterval")) { _config->conf[prefix]["USB"]["snapInterval"] = snapInterval; } + _config->conf[prefix]["USB"]["bandwidth"] = bw; + _config->conf[prefix]["USB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel; } json conf = _config->conf[prefix]["USB"]; - bw = conf["bandwidth"]; - snapInterval = conf["snapInterval"]; + if (conf.contains("bandwidth")) { bw = conf["bandwidth"]; } + if (conf.contains("snapInterval")) { snapInterval = conf["snapInterval"]; } + if (conf.contains("squelchLevel")) { squelchLevel = conf["squelchLevel"]; } } else { _config->conf[prefix]["USB"]["bandwidth"] = bw; _config->conf[prefix]["USB"]["snapInterval"] = snapInterval; + _config->conf[prefix]["USB"]["squelchLevel"] = squelchLevel; } _config->release(true);