Added persistent config for VFO offsets

This commit is contained in:
Ryzerth 2021-04-22 02:00:33 +02:00
parent eb8cd09e65
commit d3ad4a5035
3 changed files with 19 additions and 8 deletions

View File

@ -59,9 +59,9 @@ void ConfigManager::disableAutoSave() {
std::lock_guard<std::mutex> lock(termMtx);
autoSaveEnabled = false;
termFlag = true;
termCond.notify_one();
}
autoSaveThread.join();
termCond.notify_one();
if (autoSaveThread.joinable()) { autoSaveThread.join(); }
}
}

View File

@ -152,6 +152,8 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["windowSize"]["h"] = 720;
defConfig["windowSize"]["w"] = 1280;
defConfig["vfoOffsets"] = json::object();
#ifdef _WIN32
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";

View File

@ -240,6 +240,15 @@ void windowInit() {
centerTuning = core::configManager.conf["centerTuning"];
// Load each VFO's offset
for (auto const& [name, _vfo] : gui::waterfall.vfos) {
if (!core::configManager.conf["vfoOffsets"].contains(name)) {
continue;
}
double offset = core::configManager.conf["vfoOffsets"][name];
sigpath::vfoManager.setOffset(name, std::clamp<double>(offset, -bw/2.0, bw/2.0));
}
core::configManager.release();
}
@ -360,7 +369,7 @@ void drawWindow() {
gui::freqSelect.setFrequency(gui::waterfall.getCenterFrequency() + vfo->generalOffset);
gui::freqSelect.frequencyChanged = false;
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::freqSelect.frequency;
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset;
core::configManager.release(true);
}
}
@ -371,9 +380,6 @@ void drawWindow() {
gui::waterfall.selectedVFOChanged = false;
gui::freqSelect.setFrequency(vfo->generalOffset + gui::waterfall.getCenterFrequency());
gui::freqSelect.frequencyChanged = false;
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::freqSelect.frequency;
core::configManager.release(true);
}
if (gui::freqSelect.frequencyChanged) {
@ -385,7 +391,10 @@ void drawWindow() {
vfo->upperOffsetChanged = false;
}
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::freqSelect.frequency;
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
if (vfo != NULL) {
core::configManager.conf["vfoOffsets"][gui::waterfall.selectedVFO] = vfo->generalOffset;
}
core::configManager.release(true);
}
@ -399,7 +408,7 @@ void drawWindow() {
gui::freqSelect.setFrequency(gui::waterfall.getCenterFrequency());
}
core::configManager.aquire();
core::configManager.conf["frequency"] = gui::freqSelect.frequency;
core::configManager.conf["frequency"] = gui::waterfall.getCenterFrequency();
core::configManager.release(true);
}