diff --git a/openhantek/src/dsowidget.cpp b/openhantek/src/dsowidget.cpp index 20d1de1..94294ec 100644 --- a/openhantek/src/dsowidget.cpp +++ b/openhantek/src/dsowidget.cpp @@ -84,6 +84,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla // The table for the settings settingsTriggerLabel = new QLabel(); settingsTriggerLabel->setMinimumWidth(160); + settingsTriggerLabel->setIndent(5); settingsRecordLengthLabel = new QLabel(); settingsRecordLengthLabel->setAlignment(Qt::AlignRight); settingsRecordLengthLabel->setPalette(palette); @@ -96,7 +97,13 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla settingsFrequencybaseLabel = new QLabel(); settingsFrequencybaseLabel->setAlignment(Qt::AlignRight); settingsFrequencybaseLabel->setPalette(palette); + swTriggerStatus = new QLabel(); + swTriggerStatus->setMinimumWidth(30); + swTriggerStatus->setText(tr("TR")); + swTriggerStatus->setAlignment(Qt::AlignCenter); + swTriggerStatus->setAutoFillBackground(true); settingsLayout = new QHBoxLayout(); + settingsLayout->addWidget(swTriggerStatus); settingsLayout->addWidget(settingsTriggerLabel); settingsLayout->addWidget(settingsRecordLengthLabel, 1); settingsLayout->addWidget(settingsSamplerateLabel, 1); @@ -438,7 +445,11 @@ void DsoWidget::doShowNewData() { exportNextFrame.reset(nullptr); } - generator->generateGraphs(data.get()); + bool triggered = generator->generateGraphs(data.get()); + QPalette triggerLabelPalette = palette(); + triggerLabelPalette.setColor(QPalette::WindowText, Qt::black); + triggerLabelPalette.setColor(QPalette::Background, triggered ? Qt::green : Qt::red); + swTriggerStatus->setPalette(triggerLabelPalette); updateRecordLength(data.get()->getMaxSamples()); diff --git a/openhantek/src/dsowidget.h b/openhantek/src/dsowidget.h index 3e566ec..baf3dac 100644 --- a/openhantek/src/dsowidget.h +++ b/openhantek/src/dsowidget.h @@ -51,6 +51,8 @@ class DsoWidget : public QWidget { QLabel *settingsTimebaseLabel; ///< The timebase of the main scope QLabel *settingsFrequencybaseLabel; ///< The frequencybase of the main scope + QLabel *swTriggerStatus; ///< The status of SW trigger + QHBoxLayout *markerLayout; ///< The table for the marker details QLabel *markerInfoLabel; ///< The info about the zoom factor QLabel *markerTimeLabel; ///< The time period between the markers diff --git a/openhantek/src/glgenerator.cpp b/openhantek/src/glgenerator.cpp index 590dd4b..d72c122 100644 --- a/openhantek/src/glgenerator.cpp +++ b/openhantek/src/glgenerator.cpp @@ -124,7 +124,7 @@ GlGenerator::PrePostStartTriggerSamples GlGenerator::computeSoftwareTriggerTY(co const std::vector& samples = result->data(channel)->voltage.sample; double level = settings->voltage[channel].trigger; size_t sampleCount = samples.size(); - double timeDisplay = settings->horizontal.timebase * 10; + double timeDisplay = settings->horizontal.timebase * DIVS_TIME; double samplesDisplay = timeDisplay * settings->horizontal.samplerate; if (samplesDisplay >= sampleCount) { // For sure not enough samples to adjust for jitter. @@ -172,6 +172,7 @@ GlGenerator::PrePostStartTriggerSamples GlGenerator::computeSoftwareTriggerTY(co if (swTriggerStart == 0) { timestampDebug(QString("Trigger not asserted. Data ignored")); preTrigSamples = 0; // preTrigSamples may never be greater than swTriggerStart + postTrigSamples = 0; } return PrePostStartTriggerSamples(preTrigSamples, postTrigSamples, swTriggerStart); } @@ -188,7 +189,7 @@ const SampleValues& GlGenerator::useSamplesOf(int mode, unsigned channel, const } } -void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { +bool GlGenerator::generateGraphs(const DataAnalyzerResult *result) { unsigned digitalPhosphorDepth = view->digitalPhosphor ? view->digitalPhosphorDepth : 1; @@ -214,10 +215,11 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { unsigned preTrigSamples=0; unsigned postTrigSamples=0; unsigned swTriggerStart=0; + bool triggered = false; switch (settings->horizontal.format) { case Dso::GRAPHFORMAT_TY: std::tie(preTrigSamples, postTrigSamples, swTriggerStart) = computeSoftwareTriggerTY(result); - + triggered = postTrigSamples > preTrigSamples; // Add graphs for channels for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { DrawLinesWithHistoryPerChannel& dPerChannel = vaChannel[mode]; @@ -289,6 +291,7 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { break; case Dso::GRAPHFORMAT_XY: + triggered = true; for (unsigned channel = 0; channel < settings->voltage.size(); ++channel) { // For even channel numbers check if this channel is used and this and the // following channel are available at the data analyzer @@ -345,4 +348,6 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { } emit graphsGenerated(); + + return triggered; } diff --git a/openhantek/src/glgenerator.h b/openhantek/src/glgenerator.h index 4dba5c8..7ea4322 100644 --- a/openhantek/src/glgenerator.h +++ b/openhantek/src/glgenerator.h @@ -24,7 +24,7 @@ class GlGenerator : public QObject { /// \param settings The target settings object. /// \param parent The parent widget. GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view); - void generateGraphs(const DataAnalyzerResult *result); + bool generateGraphs(const DataAnalyzerResult *result); const std::vector &channel(int mode, unsigned channel, unsigned index) const; const std::vector &grid(int a) const; bool isReady() const; diff --git a/openhantek/src/hantekdso/hantekdsocontrol.cpp b/openhantek/src/hantekdso/hantekdsocontrol.cpp index 0c706ee..efbb7dd 100644 --- a/openhantek/src/hantekdso/hantekdsocontrol.cpp +++ b/openhantek/src/hantekdso/hantekdsocontrol.cpp @@ -1307,8 +1307,11 @@ void HantekDsoControl::run() { this->_samplingStarted = false; // Start next capture if necessary by leaving out the break statement - if (!this->sampling) break; else [[fallthrough]]; + if (!this->sampling) break; +#if __has_cpp_attribute(fallthrough) // Make compiler happy + [[fallthrough]] +#endif case CAPTURE_WAITING: // Sampling hasn't started, update the expected sample count this->previousSampleCount = this->getSampleCount(); diff --git a/openhantek/src/mainwindow.cpp b/openhantek/src/mainwindow.cpp index 4606705..3e6d72c 100644 --- a/openhantek/src/mainwindow.cpp +++ b/openhantek/src/mainwindow.cpp @@ -443,9 +443,8 @@ void OpenHantekMainWindow::samplerateChanged(double samplerate) { // The timebase was set, let's adapt the samplerate accordingly settings->scope.horizontal.samplerate = samplerate; horizontalDock->setSamplerate(samplerate); + dsoWidget->updateSamplerate(samplerate); } - - dsoWidget->updateSamplerate(samplerate); } /// \brief Apply new record length to settings. @@ -455,7 +454,10 @@ void OpenHantekMainWindow::recordLengthSelected(unsigned long recordLength) { } /// \brief Sets the samplerate of the oscilloscope. -void OpenHantekMainWindow::samplerateSelected() { dsoControl->setSamplerate(settings->scope.horizontal.samplerate); } +void OpenHantekMainWindow::samplerateSelected() { + dsoControl->setSamplerate(settings->scope.horizontal.samplerate); + dsoWidget->updateSamplerate(settings->scope.horizontal.samplerate); +} /// \brief Sets the record time of the oscilloscope. void OpenHantekMainWindow::timebaseSelected() {