Fixed radio bandwidth not adjusted when the menu is closed or hidden

This commit is contained in:
Ryzerth
2021-08-20 20:40:14 +02:00
parent 1465fb784f
commit b2ce47d975
11 changed files with 164 additions and 88 deletions

View File

@@ -72,6 +72,10 @@ public:
if (deempId == 2) { deemp.bypass = true; }
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@@ -114,6 +118,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@@ -158,15 +163,6 @@ public:
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->release(true);
}
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
ImGui::SameLine();
@@ -208,6 +204,17 @@ public:
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
WFMDemodulator* _this = (WFMDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["WFM"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setDeempIndex(int id) {
if (id >= 2 || id < 0) {
deemp.bypass = true;
@@ -286,4 +293,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};