diff --git a/spectrumscope.cpp b/spectrumscope.cpp index ba2c7f4..f16c971 100644 --- a/spectrumscope.cpp +++ b/spectrumscope.cpp @@ -1636,21 +1636,53 @@ void spectrumScope::wfTheme(int num) configTheme->setCurrentIndex(configTheme->findData(currentTheme)); } -void spectrumScope::setPBTInner (double hz) { - PBTInner = hz; - double pbFreq = ((double)(this->PBTInner) / this->passbandWidth) * 127.0; - qint16 newFreq = pbFreq + 128; - if (newFreq >= 0 && newFreq <= 255) { - configPbtInner->setValue(newFreq); +void spectrumScope::setPBTInner (uchar val) { + qint16 shift = (qint16)(val - 128); + double tempVar = ceil((shift / 127.0) * passbandWidth * 20000.0) / 20000.0; + // tempVar now contains value to the nearest 50Hz If CW mode, add/remove the cwPitch. + double pitch = 0.0; + if ((this->mode.mk == modeCW || this->mode.mk == modeCW_R) && this->passbandWidth > 0.0006) + { + pitch = (600.0 - cwPitch) / 1000000.0; + } + + double newPBT = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz. + + if (newPBT != this->PBTInner) { + this->PBTInner = newPBT; + qInfo(logSystem()) << "New PBT Inner value received" << this->PBTInner << "CW Pitch" << this->cwPitch << "Passband" << this->passbandWidth; + double pbFreq = ((double)(this->PBTInner) / this->passbandWidth) * 127.0; + qint16 newFreq = pbFreq + 128; + if (newFreq >= 0 && newFreq <= 255) { + configPbtInner->blockSignals(true); + configPbtInner->setValue(newFreq); + configPbtInner->blockSignals(false); + } } } -void spectrumScope::setPBTOuter (double hz) { - PBTOuter = hz; - double pbFreq = ((double)(this->PBTOuter) / this->passbandWidth) * 127.0; - qint16 newFreq = pbFreq + 128; - if (newFreq >= 0 && newFreq <= 255) { - configPbtOuter->setValue(newFreq); +void spectrumScope::setPBTOuter (uchar val) { + qint16 shift = (qint16)(val - 128); + double tempVar = ceil((shift / 127.0) * this->passbandWidth * 20000.0) / 20000.0; + // tempVar now contains value to the nearest 50Hz If CW mode, add/remove the cwPitch. + double pitch = 0.0; + if ((this->mode.mk == modeCW || this->mode.mk == modeCW_R) && this->passbandWidth > 0.0006) + { + pitch = (600.0 - cwPitch) / 1000000.0; + } + + double newPBT = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz. + + if (newPBT != this->PBTOuter) { + this->PBTOuter = newPBT; + qInfo(logSystem()) << "New PBT Outer value received" << this->PBTOuter << "CW Pitch" << this->cwPitch << "Passband" << this->passbandWidth; + double pbFreq = ((double)(this->PBTOuter) / this->passbandWidth) * 127.0; + qint16 newFreq = pbFreq + 128; + if (newFreq >= 0 && newFreq <= 255) { + configPbtOuter->blockSignals(true); + configPbtOuter->setValue(newFreq); + configPbtOuter->blockSignals(false); + } } } diff --git a/spectrumscope.h b/spectrumscope.h index 0dcb930..1b12319 100644 --- a/spectrumscope.h +++ b/spectrumscope.h @@ -64,10 +64,10 @@ public: void receivePassband(quint16 pass); double getPBTInner () { return PBTInner;} - void setPBTInner (double hz); + void setPBTInner (uchar val); double getPBTOuter () { return PBTOuter;} - void setPBTOuter (double hz); + void setPBTOuter (uchar val); quint16 getStepSize () { return stepSize;} void setStepSize (quint16 hz) { stepSize = hz;} diff --git a/wfmain.cpp b/wfmain.cpp index 1a690b8..0a1d851 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -5510,25 +5510,11 @@ void wfmain::receiveValue(cacheItem val){ receiveAntennaSel(val.value.value().antenna,val.value.value().rx); break; case funcPBTOuter: + vfos[val.vfo]->setPBTOuter(val.value.value()); + break; case funcPBTInner: { - uchar level = val.value.value(); - qint16 shift = (qint16)(level - 128); - double tempVar = ceil((shift / 127.0) * vfos[val.vfo]->getPassbandWidth() * 20000.0) / 20000.0; - // tempVar now contains value to the nearest 50Hz If CW mode, add/remove the cwPitch. - double pitch = 0.0; - modeInfo mode = vfos[val.vfo]->currentMode(); - if ((mode.mk == modeCW || mode.mk == modeCW_R) && vfos[val.vfo]->getPassbandWidth() > 0.0006) - { - pitch = (600.0 - cwPitch) / 1000000.0; - } - double newVal = round((tempVar + pitch) * 200000.0) / 200000.0; // Nearest 5Hz. - - if (val.command == funcPBTInner) { - vfos[val.vfo]->setPBTInner(newVal); - } else { - vfos[val.vfo]->setPBTOuter(newVal); - } + vfos[val.vfo]->setPBTInner(val.value.value()); break; } case funcIFShift: