Added persistant setting sto demodulator of radio module

This commit is contained in:
Ryzerth
2020-12-09 15:16:38 +01:00
parent fc9e155481
commit 80badebb37
12 changed files with 301 additions and 41 deletions

View File

@@ -5,20 +5,38 @@
#include <dsp/filter.h>
#include <dsp/audio.h>
#include <string>
#include <config.h>
#include <imgui.h>
class LSBDemodulator : public Demodulator {
public:
LSBDemodulator() {}
LSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
init(prefix, vfo, audioSampleRate, bandWidth);
LSBDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
init(prefix, vfo, audioSampleRate, bandWidth, config);
}
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
void init(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth, ConfigManager* config) {
uiPrefix = prefix;
_vfo = vfo;
audioSampRate = audioSampleRate;
bw = bandWidth;
_config = config;
_config->aquire();
if(_config->conf.contains(prefix)) {
if(!_config->conf[prefix].contains("LSB")) {
_config->conf[prefix]["LSB"]["bandwidth"] = bw;
_config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
}
json conf = _config->conf[prefix]["LSB"];
bw = conf["bandwidth"];
snapInterval = conf["snapInterval"];
}
else {
_config->conf[prefix]["LSB"]["bandwidth"] = bw;
_config->conf[prefix]["LSB"]["snapInterval"] = snapInterval;
}
_config->release(true);
demod.init(_vfo->output, bbSampRate, bandWidth, dsp::SSBDemod::MODE_LSB);
@@ -99,6 +117,9 @@ public:
if (ImGui::InputFloat(("##_radio_lsb_bw_" + uiPrefix).c_str(), &bw, 1, 100, 0)) {
bw = std::clamp<float>(bw, bwMin, bwMax);
setBandwidth(bw);
_config->aquire();
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->release(true);
}
ImGui::Text("Snap Interval");
@@ -106,6 +127,9 @@ public:
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::InputFloat(("##_radio_lsb_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
setSnapInterval(snapInterval);
_config->aquire();
_config->conf[uiPrefix]["LSB"]["snapInterval"] = snapInterval;
_config->release(true);
}
}
@@ -137,4 +161,6 @@ private:
dsp::PolyphaseResampler<float> resamp;
dsp::MonoToStereo m2s;
ConfigManager* _config;
};