mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-02-24 08:24:16 +01:00
Improve averaging
- keep already acquired data when changing the amount of averaging - add reset button for averaging
This commit is contained in:
parent
d99dab35aa
commit
a77d675a39
|
|
@ -215,6 +215,12 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
|
|||
connect(sbAverages, qOverload<int>(&QSpinBox::valueChanged), this, &SpectrumAnalyzer::SetAveraging);
|
||||
connect(this, &SpectrumAnalyzer::averagingChanged, sbAverages, &QSpinBox::setValue);
|
||||
tb_acq->addWidget(sbAverages);
|
||||
auto bResetAvg = new QPushButton("Reset");
|
||||
connect(bResetAvg, &QPushButton::clicked, this, [=](){
|
||||
average.reset(DeviceDriver::SApoints());
|
||||
UpdateAverageCount();
|
||||
});
|
||||
tb_acq->addWidget(bResetAvg);
|
||||
|
||||
window->addToolBar(tb_acq);
|
||||
toolbars.insert(tb_acq);
|
||||
|
|
@ -696,7 +702,7 @@ void SpectrumAnalyzer::SetAveraging(unsigned int averages)
|
|||
this->averages = averages;
|
||||
average.setAverages(averages);
|
||||
emit averagingChanged(averages);
|
||||
SettingsChanged();
|
||||
UpdateAverageCount();
|
||||
}
|
||||
|
||||
void SpectrumAnalyzer::SetTGEnabled(bool enabled)
|
||||
|
|
|
|||
|
|
@ -431,6 +431,12 @@ VNA::VNA(AppWindow *window, QString name)
|
|||
connect(sbAverages, qOverload<int>(&QSpinBox::valueChanged), this, &VNA::SetAveraging);
|
||||
connect(this, &VNA::averagingChanged, sbAverages, &QSpinBox::setValue);
|
||||
tb_acq->addWidget(sbAverages);
|
||||
auto bResetAvg = new QPushButton("Reset");
|
||||
connect(bResetAvg, &QPushButton::clicked, this, [=](){
|
||||
average.reset(settings.npoints);
|
||||
UpdateAverageCount();
|
||||
});
|
||||
tb_acq->addWidget(bResetAvg);
|
||||
|
||||
window->addToolBar(tb_acq);
|
||||
toolbars.insert(tb_acq);
|
||||
|
|
@ -1211,7 +1217,7 @@ void VNA::SetAveraging(unsigned int averages)
|
|||
this->averages = averages;
|
||||
average.setAverages(averages);
|
||||
emit averagingChanged(averages);
|
||||
SettingsChanged();
|
||||
UpdateAverageCount();
|
||||
}
|
||||
|
||||
void VNA::ExcitationRequired()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,12 @@ void Averaging::reset(unsigned int points)
|
|||
void Averaging::setAverages(unsigned int a)
|
||||
{
|
||||
averages = a;
|
||||
reset(avg.size());
|
||||
// throw away additional stored data if averaging has been reduced
|
||||
for(auto &d : avg) {
|
||||
while(d.size() > averages) {
|
||||
d.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeviceDriver::VNAMeasurement Averaging::process(DeviceDriver::VNAMeasurement d)
|
||||
|
|
@ -109,7 +114,7 @@ void Averaging::process(unsigned int pointNum, std::vector<std::complex<double>>
|
|||
// add newest sample to queue
|
||||
deque->push_back(data);
|
||||
// remove oldest sample if required number of averages reached
|
||||
if(deque->size() > averages) {
|
||||
while(deque->size() > averages) {
|
||||
deque->pop_front();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue