diff --git a/openhantek/src/docks/HorizontalDock.cpp b/openhantek/src/docks/HorizontalDock.cpp index 81af81e..27cb695 100644 --- a/openhantek/src/docks/HorizontalDock.cpp +++ b/openhantek/src/docks/HorizontalDock.cpp @@ -164,9 +164,16 @@ void HorizontalDock::setSamplerateLimits(double minimum, double maximum) { } void HorizontalDock::setSamplerateSteps(int mode, QList steps) { - QSignalBlocker blocker(samplerateSiSpinBox); - this->samplerateSiSpinBox->setMode(mode); - this->samplerateSiSpinBox->setSteps(steps); + // Assume that method is invoked for fixed samplerate devices only + QSignalBlocker samplerateBlocker(samplerateSiSpinBox); + samplerateSiSpinBox->setMode(mode); + samplerateSiSpinBox->setSteps(steps); + samplerateSiSpinBox->setMinimum(steps.first()); + samplerateSiSpinBox->setMaximum(steps.last()); + // Make reasonable adjustments to the timebase spinbox + QSignalBlocker timebaseBlocker(timebaseSiSpinBox); + timebaseSiSpinBox->setMinimum(pow(10, floor(log10(1.0 / steps.last())))); + timebaseSiSpinBox->setMaximum(pow(10, ceil(log10(8192.0 / (steps.first() * 10))))); } /// \brief Called when the frequencybase spinbox changes its value. diff --git a/openhantek/src/hantekdso/hantekdsocontrol.cpp b/openhantek/src/hantekdso/hantekdsocontrol.cpp index 5bd3b6d..83a4d0c 100644 --- a/openhantek/src/hantekdso/hantekdsocontrol.cpp +++ b/openhantek/src/hantekdso/hantekdsocontrol.cpp @@ -583,9 +583,8 @@ void HantekDsoControl::restoreTargets() { void HantekDsoControl::updateSamplerateLimits() { if (specification->isFixedSamplerateDevice) { - // Convert to GUI presentable values (1e5 -> 1.0, 48e6 -> 480.0 etc) QList sampleSteps; - for (auto &v : specification->fixedSampleRates) { sampleSteps << v.samplerate / 1e5; } + for (auto &v : specification->fixedSampleRates) { sampleSteps << v.samplerate; } emit samplerateSet(1, sampleSteps); } else { // Works only if the minimum samplerate for normal mode is lower than for fast @@ -691,10 +690,13 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { // For now - we go for the 10240 size sampling - the other seems not to be supported // Find highest samplerate using less than 10240 samples to obtain our duration. unsigned sampleCount = 10240; - if (specification->isSoftwareTriggerDevice) sampleCount -= controlsettings.swSampleMargin; - unsigned sampleId; - for (sampleId = 0; sampleId < specification->fixedSampleRates.size(); ++sampleId) { - if (specification->fixedSampleRates[sampleId].samplerate * duration < sampleCount) break; + // Ensure that at least 1/2 of remaining samples are available for SW trigger algorithm + if (specification->isSoftwareTriggerDevice) { + sampleCount = (sampleCount - controlsettings.swSampleMargin) / 2; + } + unsigned sampleId = 0; + for (unsigned id = 0; id < specification->fixedSampleRates.size(); ++id) { + if (specification->fixedSampleRates[id].samplerate * duration < sampleCount) sampleId = id; } // Usable sample value modifyCommand(ControlCode::CONTROL_SETTIMEDIV) diff --git a/openhantek/src/post/ppresult.cpp b/openhantek/src/post/ppresult.cpp index ae323f9..435adf4 100644 --- a/openhantek/src/post/ppresult.cpp +++ b/openhantek/src/post/ppresult.cpp @@ -19,6 +19,7 @@ unsigned int PPresult::sampleCount() const { return (unsigned)analyzedData[0].vo unsigned int PPresult::channelCount() const { return (unsigned)analyzedData.size(); } double DataChannel::computeAmplitude() const { + if (voltage.sample.empty()) return 0.0; double minimalVoltage, maximalVoltage; minimalVoltage = maximalVoltage = voltage.sample[0]; diff --git a/openhantek/src/settings.cpp b/openhantek/src/settings.cpp index 0d8b449..b73eb41 100644 --- a/openhantek/src/settings.cpp +++ b/openhantek/src/settings.cpp @@ -106,7 +106,8 @@ void DsoSettings::load() { for (ChannelID channel = 0; channel < scope.voltage.size(); ++channel) { store->beginGroup(QString("vertical%1").arg(channel)); if (store->contains("gainStepIndex")) scope.voltage[channel].gainStepIndex = store->value("gainStepIndex").toUInt(); - if (store->contains("couplingOrMathIndex")) scope.voltage[channel].couplingOrMathIndex = store->value("couplingIndex").toUInt(); + if (store->contains("couplingOrMathIndex")) scope.voltage[channel].couplingOrMathIndex = + store->value("couplingOrMathIndex").toUInt(); if (store->contains("inverted")) scope.voltage[channel].inverted = store->value("inverted").toBool(); if (store->contains("offset")) scope.voltage[channel].offset = store->value("offset").toDouble(); if (store->contains("trigger")) scope.voltage[channel].trigger = store->value("trigger").toDouble(); diff --git a/openhantek/src/widgets/sispinbox.cpp b/openhantek/src/widgets/sispinbox.cpp index f1a2da5..f02470d 100644 --- a/openhantek/src/widgets/sispinbox.cpp +++ b/openhantek/src/widgets/sispinbox.cpp @@ -124,7 +124,8 @@ void SiSpinBox::stepBy(int steps) { if (stepsId < 0) stepsId += stepsCount; value = pow(stepsSpan, floor((double)this->stepId / stepsCount)) * this->steps[stepsId]; } else { - value = this->minimum() * this->steps[stepId]; + stepId = std::min(std::max(stepId, 0), stepsCount); + value = this->steps[stepId]; } if (value <= this->minimum() || value >= this->maximum()) break; }