Skip to content

Commit

Permalink
Save lo frequency and fix restoration of FFT panel config
Browse files Browse the repository at this point in the history
  • Loading branch information
BatchDrake committed Aug 15, 2019
1 parent b1f0334 commit 009b998
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
4 changes: 4 additions & 0 deletions App/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ AppConfig::serialize(void)
obj.set("height", this->height);
obj.set("x", this->x);
obj.set("y", this->y);
obj.set("loFreq", this->loFreq);
obj.set("bandwidth", this->bandwidth);

obj.setField("source", profileObj);
obj.setField("analyzerParams", this->analyzerParams.serialize());
Expand Down Expand Up @@ -81,6 +83,8 @@ AppConfig::deserialize(Suscan::Object const &conf)
TRYSILENT(this->height = conf.get("height", this->height));
TRYSILENT(this->x = conf.get("x", this->x));
TRYSILENT(this->y = conf.get("y", this->y));
TRYSILENT(this->loFreq = conf.get("loFreq", this->loFreq));
TRYSILENT(this->bandwidth = conf.get("bandwidth", this->bandwidth));
}
}

Expand Down
24 changes: 13 additions & 11 deletions Components/FftPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ FftPanel::allocConfig(void)
void
FftPanel::applyConfig(void)
{
this->setAveraging(this->panelConfig->averaging);
this->setPanWfRatio(this->panelConfig->panWfRatio);
this->setPandRangeMax(this->panelConfig->panRangeMax);
this->setPandRangeMin(this->panelConfig->panRangeMin);
this->setWfRangeMax(this->panelConfig->wfRangeMax);
this->setWfRangeMin(this->panelConfig->wfRangeMin);
this->setPalette(this->panelConfig->palette);
this->setFreqZoom(this->panelConfig->zoom);
this->setPeakHold(this->panelConfig->peakHold);
this->setPeakDetect(this->panelConfig->peakDetect);
this->setRangeLock(this->panelConfig->rangeLock);
FftPanelConfig savedConfig = *this->panelConfig;

this->setAveraging(savedConfig.averaging);
this->setPanWfRatio(savedConfig.panWfRatio);
this->setPandRangeMax(savedConfig.panRangeMax);
this->setPandRangeMin(savedConfig.panRangeMin);
this->setWfRangeMax(savedConfig.wfRangeMax);
this->setWfRangeMin(savedConfig.wfRangeMin);
this->setPalette(savedConfig.palette);
this->setFreqZoom(savedConfig.zoom);
this->setPeakHold(savedConfig.peakHold);
this->setPeakDetect(savedConfig.peakDetect);
this->setRangeLock(savedConfig.rangeLock);
}

void
Expand Down
5 changes: 3 additions & 2 deletions UIMediator/InspectorMediator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ UIMediator::connectInspectorPanel(void)
SIGNAL(requestOpenInspector(QString)),
this,
SLOT(onOpenInspector()));


}

void
UIMediator::onInspBandwidthChanged(void)
{
this->ui->spectrum->setFilterBandwidth(
this->ui->inspectorPanel->getBandwidth());
this->appConfig->bandwidth =
static_cast<unsigned int>(this->ui->spectrum->getBandwidth());
emit bandwidthChanged(this->ui->inspectorPanel->getBandwidth());
}

void
Expand Down
4 changes: 3 additions & 1 deletion UIMediator/SpectrumMediator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void
UIMediator::onBandwidthChanged(void)
{
this->ui->inspectorPanel->setBandwidth(this->ui->spectrum->getBandwidth());

this->appConfig->bandwidth =
static_cast<unsigned int>(this->ui->spectrum->getBandwidth());
emit bandwidthChanged(this->ui->spectrum->getBandwidth());
}

Expand All @@ -82,6 +83,7 @@ UIMediator::onLoChanged(qint64)
+ this->ui->spectrum->getLoFreq();
this->ui->inspectorPanel->setDemodFrequency(freq);

this->appConfig->loFreq = static_cast<int>(this->ui->spectrum->getLoFreq());
emit loChanged(this->ui->spectrum->getLoFreq());
}

Expand Down
6 changes: 6 additions & 0 deletions UIMediator/UIMediator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ UIMediator::applyConfig(void)
{
// Apply window config
QRect rec = QGuiApplication::primaryScreen()->geometry();
unsigned int savedBw = this->appConfig->bandwidth;

if (this->appConfig->x == -1)
this->appConfig->x = (rec.width() - this->appConfig->width) / 2;
Expand Down Expand Up @@ -353,6 +354,11 @@ UIMediator::applyConfig(void)

this->refreshProfile();

// Apply loFreq and bandwidth config AFTER profile has been set.
this->ui->spectrum->setLoFreq(this->appConfig->loFreq);
if (savedBw > 0)
this->setBandwidth(savedBw);

// Artificially trigger slots to synchronize UI
this->onPaletteChanged();
this->onRangesChanged();
Expand Down
3 changes: 3 additions & 0 deletions include/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ namespace SigDigger {
int x = -1;
int y = -1;

int loFreq = 0;
unsigned int bandwidth = 0;

// Methods
AppConfig(AppUI *ui = nullptr);
[[ noreturn ]] AppConfig(Suscan::Object const &conf);
Expand Down

0 comments on commit 009b998

Please sign in to comment.