Commit 5395af64ba57647e4a82acb0d2315eca94361302

Authored by dendvz
Committed by David Gräff
1 parent c7518c52

minor bugfixes + SW trigger status display

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