mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Zerospan mode for spectrum analyzer mode
This commit is contained in:
parent
6adac7ebb4
commit
8492b38936
9 changed files with 96 additions and 16 deletions
|
|
@ -135,6 +135,13 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
|
|||
connect(bZoomOut, &QPushButton::clicked, this, &SpectrumAnalyzer::SpanZoomOut);
|
||||
tb_sweep->addWidget(bZoomOut);
|
||||
|
||||
auto bZero = new QPushButton("0");
|
||||
bZero->setToolTip("Zero span");
|
||||
bZero->setMaximumWidth(28);
|
||||
bZero->setMaximumHeight(24);
|
||||
connect(bZero, &QPushButton::clicked, this, &SpectrumAnalyzer::SetZeroSpan);
|
||||
tb_sweep->addWidget(bZero);
|
||||
|
||||
window->addToolBar(tb_sweep);
|
||||
toolbars.insert(tb_sweep);
|
||||
|
||||
|
|
@ -450,6 +457,16 @@ void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d)
|
|||
|
||||
d = average.process(d);
|
||||
|
||||
if(settings.f_start == settings.f_stop) {
|
||||
// keep track of first point time
|
||||
if(d.pointNum == 0) {
|
||||
firstPointTime = d.us;
|
||||
d.us = 0;
|
||||
} else {
|
||||
d.us -= firstPointTime;
|
||||
}
|
||||
}
|
||||
|
||||
if(normalize.measuring) {
|
||||
if(average.currentSweep() == averages) {
|
||||
// this is the last averaging sweep, use values for normalization
|
||||
|
|
@ -464,7 +481,7 @@ void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d)
|
|||
normalize.f_stop = settings.f_stop;
|
||||
normalize.points = settings.pointNum;
|
||||
EnableNormalization(true);
|
||||
qDebug() << "Normalization measuremen complete";
|
||||
qDebug() << "Normalization measurement complete";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -496,7 +513,7 @@ void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d)
|
|||
void SpectrumAnalyzer::SettingsChanged()
|
||||
{
|
||||
changingSettings = true;
|
||||
if(settings.f_stop - settings.f_start >= 1000) {
|
||||
if(settings.f_stop - settings.f_start >= 1000 || settings.f_stop - settings.f_start <= 0) {
|
||||
settings.pointNum = 1001;
|
||||
} else {
|
||||
settings.pointNum = settings.f_stop - settings.f_start + 1;
|
||||
|
|
@ -505,10 +522,16 @@ void SpectrumAnalyzer::SettingsChanged()
|
|||
settings.applySourceCorrection = 1;
|
||||
|
||||
auto pref = Preferences::getInstance();
|
||||
if(!settings.trackingGenerator && pref.Acquisition.useDFTinSAmode && settings.RBW <= pref.Acquisition.RBWLimitForDFT) {
|
||||
// Enable DFT if below RBW threshold and TG is not enabled
|
||||
settings.UseDFT = 1;
|
||||
if(settings.f_stop > settings.f_start) {
|
||||
// non-zerospan, check usability of DFT
|
||||
if(!settings.trackingGenerator && pref.Acquisition.useDFTinSAmode && settings.RBW <= pref.Acquisition.RBWLimitForDFT) {
|
||||
// Enable DFT if below RBW threshold and TG is not enabled
|
||||
settings.UseDFT = 1;
|
||||
} else {
|
||||
settings.UseDFT = 0;
|
||||
}
|
||||
} else {
|
||||
// zerospan, DFT not usable
|
||||
settings.UseDFT = 0;
|
||||
}
|
||||
|
||||
|
|
@ -620,6 +643,13 @@ void SpectrumAnalyzer::SetFullSpan()
|
|||
ConstrainAndUpdateFrequencies();
|
||||
}
|
||||
|
||||
void SpectrumAnalyzer::SetZeroSpan()
|
||||
{
|
||||
auto center = (settings.f_start + settings.f_stop) / 2;
|
||||
SetStartFreq(center);
|
||||
SetStopFreq(center);
|
||||
}
|
||||
|
||||
void SpectrumAnalyzer::SpanZoomIn()
|
||||
{
|
||||
auto center = (settings.f_start + settings.f_stop) / 2;
|
||||
|
|
@ -853,6 +883,11 @@ void SpectrumAnalyzer::SetupSCPI()
|
|||
SetFullSpan();
|
||||
return "";
|
||||
}, nullptr));
|
||||
scpi_freq->add(new SCPICommand("ZERO", [=](QStringList params) -> QString {
|
||||
Q_UNUSED(params)
|
||||
SetZeroSpan();
|
||||
return "";
|
||||
}, nullptr));
|
||||
auto scpi_acq = new SCPINode("ACQuisition");
|
||||
SCPINode::add(scpi_acq);
|
||||
scpi_acq->add(new SCPICommand("RBW", [=](QStringList params) -> QString {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ private slots:
|
|||
void SetCenterFreq(double freq);
|
||||
void SetSpan(double span);
|
||||
void SetFullSpan();
|
||||
void SetZeroSpan();
|
||||
void SpanZoomIn();
|
||||
void SpanZoomOut();
|
||||
void SetSingleSweep(bool single);
|
||||
|
|
@ -92,6 +93,7 @@ private:
|
|||
bool changingSettings;
|
||||
unsigned int averages;
|
||||
bool singleSweep;
|
||||
double firstPointTime; // timestamp of the first point in the sweep, only use when zerospan is used
|
||||
TraceModel traceModel;
|
||||
TraceWidget *traceWidget;
|
||||
MarkerModel *markerModel;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue