From 9b1c9e9e29883cf1f35eb44b056c9ac71397aba6 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Wed, 9 Dec 2020 15:28:31 +0100 Subject: [PATCH] Added persistant config for the selected demodulator --- radio/src/main.cpp | 46 +++++++++++++++++++++----------------------- root_dev/config.json | 4 ++-- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 97f72d98..250b9903 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -57,12 +57,7 @@ public: stream.init(wfmDemod.getOutput(), srChangeHandler, audioSampRate); sigpath::sinkManager.registerStream(name, &stream); - // TODO: Replace with config load - demodId = 1; - selectDemod(&wfmDemod); - - // TODO: Remove the two above lines when implemented - // selectDemodulatorByID(demodId); + selectDemodById(demodId); stream.start(); @@ -107,39 +102,31 @@ private: ImGui::Columns(4, CONCAT("RadioModeColumns##_", _this->name), false); if (ImGui::RadioButton(CONCAT("NFM##_", _this->name), _this->demodId == 0) && _this->demodId != 0) { - _this->demodId = 0; - _this->selectDemod(&_this->fmDemod); + _this->selectDemodById(0); } if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demodId == 1) && _this->demodId != 1) { - _this->demodId = 1; - _this->selectDemod(&_this->wfmDemod); + _this->selectDemodById(1); } ImGui::NextColumn(); if (ImGui::RadioButton(CONCAT("AM##_", _this->name), _this->demodId == 2) && _this->demodId != 2) { - _this->demodId = 2; - _this->selectDemod(&_this->amDemod); + _this->selectDemodById(2); } if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demodId == 3) && _this->demodId != 3) { - _this->demodId = 3; - _this->selectDemod(&_this->dsbDemod); + _this->selectDemodById(3); } ImGui::NextColumn(); if (ImGui::RadioButton(CONCAT("USB##_", _this->name), _this->demodId == 4) && _this->demodId != 4) { - _this->demodId = 4; - _this->selectDemod(&_this->usbDemod); + _this->selectDemodById(4); } if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demodId == 5) && _this->demodId != 5) { - _this->demodId = 5; - _this->selectDemod(&_this->cwDemod); + _this->selectDemodById(5); }; ImGui::NextColumn(); if (ImGui::RadioButton(CONCAT("LSB##_", _this->name), _this->demodId == 6) && _this->demodId != 6) { - _this->demodId = 6; - _this->selectDemod(&_this->lsbDemod); + _this->selectDemodById(6); } if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demodId == 7) && _this->demodId != 7) { - _this->demodId = 7; - _this->selectDemod(&_this->rawDemod); + _this->selectDemodById(7); }; ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false); @@ -169,8 +156,19 @@ private: currentDemod->start(); } - void selectDemodByID(int id) { - // TODO: Implement + void selectDemodById(int id) { + demodId = id; + if (id == 0) { selectDemod(&fmDemod); } + if (id == 1) { selectDemod(&wfmDemod); } + if (id == 2) { selectDemod(&amDemod); } + if (id == 3) { selectDemod(&dsbDemod); } + if (id == 4) { selectDemod(&usbDemod); } + if (id == 5) { selectDemod(&cwDemod); } + if (id == 6) { selectDemod(&lsbDemod); } + if (id == 7) { selectDemod(&rawDemod); } + config.aquire(); + config.conf[name]["selectedDemodId"] = demodId; + config.release(true); } std::string name; diff --git a/root_dev/config.json b/root_dev/config.json index 2f15ee03..0cf291fb 100644 --- a/root_dev/config.json +++ b/root_dev/config.json @@ -1,9 +1,9 @@ { "bandPlan": "General", "bandPlanEnabled": true, - "centerTuning": true, + "centerTuning": false, "fftHeight": 300, - "frequency": 100100000, + "frequency": 99808000, "max": 0.0, "maximized": false, "menuOrder": [