Added persistant config for the selected demodulator

This commit is contained in:
Ryzerth 2020-12-09 15:28:31 +01:00
parent 80badebb37
commit 9b1c9e9e29
2 changed files with 24 additions and 26 deletions

View File

@ -57,12 +57,7 @@ public:
stream.init(wfmDemod.getOutput(), srChangeHandler, audioSampRate); stream.init(wfmDemod.getOutput(), srChangeHandler, audioSampRate);
sigpath::sinkManager.registerStream(name, &stream); sigpath::sinkManager.registerStream(name, &stream);
// TODO: Replace with config load selectDemodById(demodId);
demodId = 1;
selectDemod(&wfmDemod);
// TODO: Remove the two above lines when implemented
// selectDemodulatorByID(demodId);
stream.start(); stream.start();
@ -107,39 +102,31 @@ private:
ImGui::Columns(4, CONCAT("RadioModeColumns##_", _this->name), false); ImGui::Columns(4, CONCAT("RadioModeColumns##_", _this->name), false);
if (ImGui::RadioButton(CONCAT("NFM##_", _this->name), _this->demodId == 0) && _this->demodId != 0) { if (ImGui::RadioButton(CONCAT("NFM##_", _this->name), _this->demodId == 0) && _this->demodId != 0) {
_this->demodId = 0; _this->selectDemodById(0);
_this->selectDemod(&_this->fmDemod);
} }
if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demodId == 1) && _this->demodId != 1) { if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demodId == 1) && _this->demodId != 1) {
_this->demodId = 1; _this->selectDemodById(1);
_this->selectDemod(&_this->wfmDemod);
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::RadioButton(CONCAT("AM##_", _this->name), _this->demodId == 2) && _this->demodId != 2) { if (ImGui::RadioButton(CONCAT("AM##_", _this->name), _this->demodId == 2) && _this->demodId != 2) {
_this->demodId = 2; _this->selectDemodById(2);
_this->selectDemod(&_this->amDemod);
} }
if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demodId == 3) && _this->demodId != 3) { if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demodId == 3) && _this->demodId != 3) {
_this->demodId = 3; _this->selectDemodById(3);
_this->selectDemod(&_this->dsbDemod);
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::RadioButton(CONCAT("USB##_", _this->name), _this->demodId == 4) && _this->demodId != 4) { if (ImGui::RadioButton(CONCAT("USB##_", _this->name), _this->demodId == 4) && _this->demodId != 4) {
_this->demodId = 4; _this->selectDemodById(4);
_this->selectDemod(&_this->usbDemod);
} }
if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demodId == 5) && _this->demodId != 5) { if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demodId == 5) && _this->demodId != 5) {
_this->demodId = 5; _this->selectDemodById(5);
_this->selectDemod(&_this->cwDemod);
}; };
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::RadioButton(CONCAT("LSB##_", _this->name), _this->demodId == 6) && _this->demodId != 6) { if (ImGui::RadioButton(CONCAT("LSB##_", _this->name), _this->demodId == 6) && _this->demodId != 6) {
_this->demodId = 6; _this->selectDemodById(6);
_this->selectDemod(&_this->lsbDemod);
} }
if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demodId == 7) && _this->demodId != 7) { if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demodId == 7) && _this->demodId != 7) {
_this->demodId = 7; _this->selectDemodById(7);
_this->selectDemod(&_this->rawDemod);
}; };
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false); ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false);
@ -169,8 +156,19 @@ private:
currentDemod->start(); currentDemod->start();
} }
void selectDemodByID(int id) { void selectDemodById(int id) {
// TODO: Implement 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; std::string name;

View File

@ -1,9 +1,9 @@
{ {
"bandPlan": "General", "bandPlan": "General",
"bandPlanEnabled": true, "bandPlanEnabled": true,
"centerTuning": true, "centerTuning": false,
"fftHeight": 300, "fftHeight": 300,
"frequency": 100100000, "frequency": 99808000,
"max": 0.0, "max": 0.0,
"maximized": false, "maximized": false,
"menuOrder": [ "menuOrder": [