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,35 @@
#include <dsp/filter.h>
#include <dsp/audio.h>
#include <string>
#include <config.h>
#include <imgui.h>
class RAWDemodulator : public Demodulator {
public:
RAWDemodulator() {}
RAWDemodulator(std::string prefix, VFOManager::VFO* vfo, float audioSampleRate, float bandWidth) {
init(prefix, vfo, audioSampleRate, bandWidth);
RAWDemodulator(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("RAW")) {
_config->conf[prefix]["RAW"]["snapInterval"] = snapInterval;
}
json conf = _config->conf[prefix]["RAW"];
snapInterval = conf["snapInterval"];
}
else {
_config->conf[prefix]["RAW"]["snapInterval"] = snapInterval;
}
_config->release(true);
c2s.init(_vfo->output);
}
@@ -75,6 +90,9 @@ public:
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::InputFloat(("##_radio_raw_snap_" + uiPrefix).c_str(), &snapInterval, 1, 100, 0)) {
setSnapInterval(snapInterval);
_config->aquire();
_config->conf[uiPrefix]["RAW"]["snapInterval"] = snapInterval;
_config->release(true);
}
// TODO: Allow selection of the bandwidth
@@ -95,4 +113,6 @@ private:
VFOManager::VFO* _vfo;
dsp::ComplexToStereo c2s;
ConfigManager* _config;
};