Commit 5395af64ba57647e4a82acb0d2315eca94361302
Committed by
David Gräff
1 parent
c7518c52
minor bugfixes + SW trigger status display
Showing
6 changed files
with
32 additions
and
9 deletions
openhantek/src/dsowidget.cpp
| ... | ... | @@ -84,6 +84,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla |
| 84 | 84 | // The table for the settings |
| 85 | 85 | settingsTriggerLabel = new QLabel(); |
| 86 | 86 | settingsTriggerLabel->setMinimumWidth(160); |
| 87 | + settingsTriggerLabel->setIndent(5); | |
| 87 | 88 | settingsRecordLengthLabel = new QLabel(); |
| 88 | 89 | settingsRecordLengthLabel->setAlignment(Qt::AlignRight); |
| 89 | 90 | settingsRecordLengthLabel->setPalette(palette); |
| ... | ... | @@ -96,7 +97,13 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla |
| 96 | 97 | settingsFrequencybaseLabel = new QLabel(); |
| 97 | 98 | settingsFrequencybaseLabel->setAlignment(Qt::AlignRight); |
| 98 | 99 | settingsFrequencybaseLabel->setPalette(palette); |
| 100 | + swTriggerStatus = new QLabel(); | |
| 101 | + swTriggerStatus->setMinimumWidth(30); | |
| 102 | + swTriggerStatus->setText(tr("TR")); | |
| 103 | + swTriggerStatus->setAlignment(Qt::AlignCenter); | |
| 104 | + swTriggerStatus->setAutoFillBackground(true); | |
| 99 | 105 | settingsLayout = new QHBoxLayout(); |
| 106 | + settingsLayout->addWidget(swTriggerStatus); | |
| 100 | 107 | settingsLayout->addWidget(settingsTriggerLabel); |
| 101 | 108 | settingsLayout->addWidget(settingsRecordLengthLabel, 1); |
| 102 | 109 | settingsLayout->addWidget(settingsSamplerateLabel, 1); |
| ... | ... | @@ -438,7 +445,11 @@ void DsoWidget::doShowNewData() { |
| 438 | 445 | exportNextFrame.reset(nullptr); |
| 439 | 446 | } |
| 440 | 447 | |
| 441 | - generator->generateGraphs(data.get()); | |
| 448 | + bool triggered = generator->generateGraphs(data.get()); | |
| 449 | + QPalette triggerLabelPalette = palette(); | |
| 450 | + triggerLabelPalette.setColor(QPalette::WindowText, Qt::black); | |
| 451 | + triggerLabelPalette.setColor(QPalette::Background, triggered ? Qt::green : Qt::red); | |
| 452 | + swTriggerStatus->setPalette(triggerLabelPalette); | |
| 442 | 453 | |
| 443 | 454 | updateRecordLength(data.get()->getMaxSamples()); |
| 444 | 455 | ... | ... |
openhantek/src/dsowidget.h
| ... | ... | @@ -51,6 +51,8 @@ class DsoWidget : public QWidget { |
| 51 | 51 | QLabel *settingsTimebaseLabel; ///< The timebase of the main scope |
| 52 | 52 | QLabel *settingsFrequencybaseLabel; ///< The frequencybase of the main scope |
| 53 | 53 | |
| 54 | + QLabel *swTriggerStatus; ///< The status of SW trigger | |
| 55 | + | |
| 54 | 56 | QHBoxLayout *markerLayout; ///< The table for the marker details |
| 55 | 57 | QLabel *markerInfoLabel; ///< The info about the zoom factor |
| 56 | 58 | QLabel *markerTimeLabel; ///< The time period between the markers | ... | ... |
openhantek/src/glgenerator.cpp
| ... | ... | @@ -124,7 +124,7 @@ GlGenerator::PrePostStartTriggerSamples GlGenerator::computeSoftwareTriggerTY(co |
| 124 | 124 | const std::vector<double>& samples = result->data(channel)->voltage.sample; |
| 125 | 125 | double level = settings->voltage[channel].trigger; |
| 126 | 126 | size_t sampleCount = samples.size(); |
| 127 | - double timeDisplay = settings->horizontal.timebase * 10; | |
| 127 | + double timeDisplay = settings->horizontal.timebase * DIVS_TIME; | |
| 128 | 128 | double samplesDisplay = timeDisplay * settings->horizontal.samplerate; |
| 129 | 129 | if (samplesDisplay >= sampleCount) { |
| 130 | 130 | // For sure not enough samples to adjust for jitter. |
| ... | ... | @@ -172,6 +172,7 @@ GlGenerator::PrePostStartTriggerSamples GlGenerator::computeSoftwareTriggerTY(co |
| 172 | 172 | if (swTriggerStart == 0) { |
| 173 | 173 | timestampDebug(QString("Trigger not asserted. Data ignored")); |
| 174 | 174 | preTrigSamples = 0; // preTrigSamples may never be greater than swTriggerStart |
| 175 | + postTrigSamples = 0; | |
| 175 | 176 | } |
| 176 | 177 | return PrePostStartTriggerSamples(preTrigSamples, postTrigSamples, swTriggerStart); |
| 177 | 178 | } |
| ... | ... | @@ -188,7 +189,7 @@ const SampleValues& GlGenerator::useSamplesOf(int mode, unsigned channel, const |
| 188 | 189 | } |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | -void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { | |
| 192 | +bool GlGenerator::generateGraphs(const DataAnalyzerResult *result) { | |
| 192 | 193 | |
| 193 | 194 | unsigned digitalPhosphorDepth = view->digitalPhosphor ? view->digitalPhosphorDepth : 1; |
| 194 | 195 | |
| ... | ... | @@ -214,10 +215,11 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { |
| 214 | 215 | unsigned preTrigSamples=0; |
| 215 | 216 | unsigned postTrigSamples=0; |
| 216 | 217 | unsigned swTriggerStart=0; |
| 218 | + bool triggered = false; | |
| 217 | 219 | switch (settings->horizontal.format) { |
| 218 | 220 | case Dso::GRAPHFORMAT_TY: |
| 219 | 221 | std::tie(preTrigSamples, postTrigSamples, swTriggerStart) = computeSoftwareTriggerTY(result); |
| 220 | - | |
| 222 | + triggered = postTrigSamples > preTrigSamples; | |
| 221 | 223 | // Add graphs for channels |
| 222 | 224 | for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 223 | 225 | DrawLinesWithHistoryPerChannel& dPerChannel = vaChannel[mode]; |
| ... | ... | @@ -289,6 +291,7 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { |
| 289 | 291 | break; |
| 290 | 292 | |
| 291 | 293 | case Dso::GRAPHFORMAT_XY: |
| 294 | + triggered = true; | |
| 292 | 295 | for (unsigned channel = 0; channel < settings->voltage.size(); ++channel) { |
| 293 | 296 | // For even channel numbers check if this channel is used and this and the |
| 294 | 297 | // following channel are available at the data analyzer |
| ... | ... | @@ -345,4 +348,6 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { |
| 345 | 348 | } |
| 346 | 349 | |
| 347 | 350 | emit graphsGenerated(); |
| 351 | + | |
| 352 | + return triggered; | |
| 348 | 353 | } | ... | ... |
openhantek/src/glgenerator.h
| ... | ... | @@ -24,7 +24,7 @@ class GlGenerator : public QObject { |
| 24 | 24 | /// \param settings The target settings object. |
| 25 | 25 | /// \param parent The parent widget. |
| 26 | 26 | GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view); |
| 27 | - void generateGraphs(const DataAnalyzerResult *result); | |
| 27 | + bool generateGraphs(const DataAnalyzerResult *result); | |
| 28 | 28 | const std::vector<GLfloat> &channel(int mode, unsigned channel, unsigned index) const; |
| 29 | 29 | const std::vector<GLfloat> &grid(int a) const; |
| 30 | 30 | bool isReady() const; | ... | ... |
openhantek/src/hantekdso/hantekdsocontrol.cpp
| ... | ... | @@ -1307,8 +1307,11 @@ void HantekDsoControl::run() { |
| 1307 | 1307 | this->_samplingStarted = false; |
| 1308 | 1308 | |
| 1309 | 1309 | // Start next capture if necessary by leaving out the break statement |
| 1310 | - if (!this->sampling) break; else [[fallthrough]]; | |
| 1310 | + if (!this->sampling) break; | |
| 1311 | 1311 | |
| 1312 | +#if __has_cpp_attribute(fallthrough) // Make compiler happy | |
| 1313 | + [[fallthrough]] | |
| 1314 | +#endif | |
| 1312 | 1315 | case CAPTURE_WAITING: |
| 1313 | 1316 | // Sampling hasn't started, update the expected sample count |
| 1314 | 1317 | this->previousSampleCount = this->getSampleCount(); | ... | ... |
openhantek/src/mainwindow.cpp
| ... | ... | @@ -443,9 +443,8 @@ void OpenHantekMainWindow::samplerateChanged(double samplerate) { |
| 443 | 443 | // The timebase was set, let's adapt the samplerate accordingly |
| 444 | 444 | settings->scope.horizontal.samplerate = samplerate; |
| 445 | 445 | horizontalDock->setSamplerate(samplerate); |
| 446 | + dsoWidget->updateSamplerate(samplerate); | |
| 446 | 447 | } |
| 447 | - | |
| 448 | - dsoWidget->updateSamplerate(samplerate); | |
| 449 | 448 | } |
| 450 | 449 | |
| 451 | 450 | /// \brief Apply new record length to settings. |
| ... | ... | @@ -455,7 +454,10 @@ void OpenHantekMainWindow::recordLengthSelected(unsigned long recordLength) { |
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | /// \brief Sets the samplerate of the oscilloscope. |
| 458 | -void OpenHantekMainWindow::samplerateSelected() { dsoControl->setSamplerate(settings->scope.horizontal.samplerate); } | |
| 457 | +void OpenHantekMainWindow::samplerateSelected() { | |
| 458 | + dsoControl->setSamplerate(settings->scope.horizontal.samplerate); | |
| 459 | + dsoWidget->updateSamplerate(settings->scope.horizontal.samplerate); | |
| 460 | +} | |
| 459 | 461 | |
| 460 | 462 | /// \brief Sets the record time of the oscilloscope. |
| 461 | 463 | void OpenHantekMainWindow::timebaseSelected() { | ... | ... |