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

@ -322,6 +322,7 @@ namespace ImGui {
}
hzDist = std::clamp<double>(hzDist, relatedVfo->minBandwidth, relatedVfo->maxBandwidth);
relatedVfo->setBandwidth(hzDist);
relatedVfo->onUserChangedBandwidth.emit(hzDist);
return;
}

View File

@ -67,6 +67,8 @@ namespace ImGui {
bool bandwidthLocked;
ImU32 color = IM_COL32(255, 255, 255, 50);
Event<double> onUserChangedBandwidth;
};
class WaterFall {

View File

@ -30,10 +30,11 @@ public:
friend class VFOManager;
private:
std::string name;
dsp::VFO* dspVFO;
ImGui::WaterfallVFO* wtfVFO;
private:
std::string name;
};

View File

@ -55,6 +55,11 @@ public:
resamp.updateWindow(&win);
m2s.init(&resamp.out);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -89,6 +94,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -130,15 +136,6 @@ public:
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
_config->release(true);
}
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
ImGui::SameLine();
@ -160,7 +157,18 @@ public:
_config->conf[uiPrefix]["AM"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
AMDemodulator* _this = (AMDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["AM"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -175,9 +183,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["AM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["AM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["AM"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -208,4 +216,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

View File

@ -57,6 +57,11 @@ public:
resamp.updateWindow(&win);
m2s.init(&resamp.out);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -93,6 +98,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -133,14 +139,6 @@ public:
_config->acquire();
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
_config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
@ -163,7 +161,18 @@ public:
_config->conf[uiPrefix]["CW"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
CWDemodulator* _this = (CWDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["CW"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -178,9 +187,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["CW"]["bandwidth"] = bw;
_config->conf[uiPrefix]["CW"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["CW"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -212,4 +221,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

View File

@ -55,6 +55,11 @@ public:
resamp.updateWindow(&win);
m2s.init(&resamp.out);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -89,6 +94,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -130,15 +136,6 @@ public:
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
_config->release(true);
}
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
ImGui::SameLine();
@ -160,7 +157,18 @@ public:
_config->conf[uiPrefix]["DSB"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
DSBDemodulator* _this = (DSBDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["DSB"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -170,9 +178,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["DSB"]["bandwidth"] = bw;
_config->conf[uiPrefix]["DSB"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["DSB"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -203,4 +211,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

View File

@ -51,6 +51,11 @@ public:
resamp.init(&demod.out, &win, bbSampRate, audioSampRate);
win.setSampleRate(bbSampRate * resamp.getInterpolation());
resamp.updateWindow(&win);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -81,6 +86,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -122,15 +128,6 @@ public:
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
_config->release(true);
}
if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
ImGui::SameLine();
@ -152,7 +149,18 @@ public:
_config->conf[uiPrefix]["FM"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
FMDemodulator* _this = (FMDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["FM"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -164,9 +172,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["FM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["FM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["FM"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -195,4 +203,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

View File

@ -55,6 +55,11 @@ public:
resamp.updateWindow(&win);
m2s.init(&resamp.out);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -89,6 +94,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -129,14 +135,6 @@ public:
_config->acquire();
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
@ -159,7 +157,18 @@ public:
_config->conf[uiPrefix]["LSB"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
LSBDemodulator* _this = (LSBDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["LSB"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -175,9 +184,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["LSB"]["bandwidth"] = bw;
_config->conf[uiPrefix]["LSB"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["LSB"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -208,4 +217,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

View File

@ -120,8 +120,8 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["RAW"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["RAW"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}

View File

@ -55,6 +55,11 @@ public:
resamp.updateWindow(&win);
m2s.init(&resamp.out);
onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler;
onUserChangedBandwidthHandler.ctx = this;
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
void start() {
@ -89,6 +94,7 @@ public:
void setVFO(VFOManager::VFO* vfo) {
_vfo = vfo;
squelch.setInput(_vfo->output);
_vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler);
}
VFOManager::VFO* getVFO() {
@ -129,14 +135,6 @@ public:
_config->acquire();
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
_config->release(true);
}if (running) {
if (_vfo->getBandwidthChanged()) {
bw = _vfo->getBandwidth();
setBandwidth(bw, false);
_config->acquire();
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
_config->release(true);
}
}
ImGui::Text("Snap Interval");
@ -159,7 +157,18 @@ public:
_config->conf[uiPrefix]["USB"]["squelchLevel"] = squelchLevel;
_config->release(true);
}
}
}
static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) {
USBDemodulator* _this = (USBDemodulator*)ctx;
if (_this->running) {
_this->bw = newBw;
_this->setBandwidth(_this->bw, false);
_this->_config->acquire();
_this->_config->conf[_this->uiPrefix]["USB"]["bandwidth"] = _this->bw;
_this->_config->release(true);
}
}
void setBandwidth(float bandWidth, bool updateWaterfall = true) {
bandWidth = std::clamp<float>(bandWidth, bwMin, bwMax);
@ -175,9 +184,9 @@ public:
void saveParameters(bool lock = true) {
if (lock) { _config->acquire(); }
_config->conf[uiPrefix]["WFM"]["bandwidth"] = bw;
_config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel;
_config->conf[uiPrefix]["USB"]["bandwidth"] = bw;
_config->conf[uiPrefix]["USB"]["snapInterval"] = snapInterval;
_config->conf[uiPrefix]["USB"]["squelchLevel"] = squelchLevel;
if (lock) { _config->release(true); }
}
@ -208,4 +217,6 @@ private:
ConfigManager* _config;
EventHandler<double> onUserChangedBandwidthHandler;
};

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;
};