Skip to content

Commit 037731c

Browse files
committed
consistent marker handling; user manual update; upversion
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
1 parent ec1196f commit 037731c

13 files changed

+237
-211
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ firmware/hex
1212
*.json
1313
*.kate-swp
1414
.directory
15+
.kdev4
16+
*.kdev4

docs/OpenHantek6022_User_Manual.odt

105 KB
Binary file not shown.

docs/OpenHantek6022_User_Manual.pdf

105 KB
Binary file not shown.

docs/images/screenshot_mainwindow.png

-4.46 KB
Loading

openhantek/src/OH_BUILD.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Do not edit, will be re-created at each commit!
2-
#define OH_BUILD "20191112 build 548"
2+
#define OH_BUILD "20191115 build 549"

openhantek/src/OH_VERSION.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// define the version that is shown on top of the program
22
// if undefined (for development commits) the build will be shown by OpenHantek
33

4-
#define OH_VERSION "v2.17-rc8"
4+
#define OH_VERSION "3.0.0"
55

66

77
# ifdef OH_VERSION

openhantek/src/dsowidget.cpp

+34-29
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::
8484
markerInfoLabel->setAlignment(Qt::AlignLeft);
8585
markerInfoLabel->setPalette(palette);
8686
markerTimeLabel = new QLabel();
87-
markerTimeLabel->setAlignment(Qt::AlignRight);
87+
markerTimeLabel->setAlignment(Qt::AlignLeft);
8888
markerTimeLabel->setPalette(palette);
8989
markerFrequencyLabel = new QLabel();
90-
markerFrequencyLabel->setAlignment(Qt::AlignRight);
90+
markerFrequencyLabel->setAlignment(Qt::AlignLeft);
9191
markerFrequencyLabel->setPalette(palette);
9292
markerTimebaseLabel = new QLabel();
9393
markerTimebaseLabel->setAlignment(Qt::AlignRight);
@@ -409,18 +409,17 @@ void DsoWidget::setMeasurementVisible(ChannelID channel) {
409409

410410
/// \brief Update the label about the marker measurements
411411
void DsoWidget::updateMarkerDetails() {
412-
double div0 = scope->horizontal.cursor.pos[0].x();
413-
double div1 = scope->horizontal.cursor.pos[1].x();
414-
if ( div0 > div1 )
415-
std::swap( div0, div1 );
416-
double divs = div1 - div0;
417-
double time0 = div0 * scope->horizontal.timebase;
418-
double time1 = div1 * scope->horizontal.timebase;
412+
double m1 = scope->horizontal.cursor.pos[0].x() + DIVS_TIME / 2; // zero at center -> zero at left margin
413+
double m2 = scope->horizontal.cursor.pos[1].x() + DIVS_TIME / 2; // zero at center -> zero at left margin
414+
if ( m1 > m2 )
415+
std::swap( m1, m2 );
416+
double divs = m2 - m1;
417+
// t = 0 at trigger position
418+
double time0 = ( m1 - DIVS_TIME * scope->trigger.position ) * scope->horizontal.timebase;
419+
double time1 = ( m2 - DIVS_TIME * scope->trigger.position ) * scope->horizontal.timebase;
419420
double time = divs * scope->horizontal.timebase;
420-
div0 += DIVS_TIME / 2; // zero at center -> zero at left margin
421-
div1 += DIVS_TIME / 2;
422-
double freq0 = div0 * scope->horizontal.frequencybase;
423-
double freq1 = div1 * scope->horizontal.frequencybase;
421+
double freq0 = m1 * scope->horizontal.frequencybase;
422+
double freq1 = m2 * scope->horizontal.frequencybase;
424423
double freq = divs * scope->horizontal.frequencybase;
425424
bool timeUsed = false;
426425
bool freqUsed = false;
@@ -458,7 +457,7 @@ void DsoWidget::updateMarkerDetails() {
458457
++index;
459458
}
460459

461-
if ( DIVS_TIME == divs || (div0 == 0 && div1 == 0) || (div0 == DIVS_TIME && div1 == DIVS_TIME) ) {
460+
if ( DIVS_TIME == divs || ( m1 == 0 && m2 == 0) || ( m1 == DIVS_TIME && m2 == DIVS_TIME) ) {
462461
// markers at left/right margins -> don't display
463462
markerInfoLabel->setVisible( false );
464463
markerTimeLabel->setVisible( false );
@@ -487,21 +486,27 @@ void DsoWidget::updateMarkerDetails() {
487486
markerFrequencybaseLabel->setVisible( freqUsed );
488487
}
489488
markerInfoLabel->setText( mInfo );
490-
if ( timeUsed )
491-
markerTimeLabel->setText( mTime.append( "%1 -> %2, Δt: %3 " )
492-
.arg( valueToString( time0, UNIT_SECONDS, 4 ) )
493-
.arg( valueToString( time1, UNIT_SECONDS, 4 ) )
494-
.arg( valueToString( time, UNIT_SECONDS, 4 ) )
495-
);
496-
else
489+
if ( timeUsed ) {
490+
mTime += QString( "%1" ).arg( valueToString( time0, UNIT_SECONDS, 4 ) );
491+
if ( time )
492+
mTime += QString( " -> %1, Δt: %2 (%3) ")
493+
.arg( valueToString( time1, UNIT_SECONDS, 4 ) )
494+
.arg( valueToString( time, UNIT_SECONDS, 4 ) )
495+
.arg( valueToString( 1/time, UNIT_HERTZ, 4) )
496+
;
497+
markerTimeLabel->setText( mTime );
498+
} else {
497499
markerTimeLabel->setText( "" );
498-
if ( freqUsed )
499-
markerFrequencyLabel->setText( mFreq.append( "%1 -> %2, Δf: %3 " )
500-
.arg( valueToString( freq0, UNIT_HERTZ, 4) )
501-
.arg( valueToString( freq1, UNIT_HERTZ, 4) )
502-
.arg( valueToString( freq, UNIT_HERTZ, 4) )
503-
);
504-
else
500+
}
501+
if ( freqUsed ) {
502+
mFreq += QString( "%1" ).arg( valueToString( freq0, UNIT_HERTZ, 4) );
503+
if ( freq )
504+
mFreq += QString( " -> %2, Δf: %3 " )
505+
.arg( valueToString( freq1, UNIT_HERTZ, 4) )
506+
.arg( valueToString( freq, UNIT_HERTZ, 4) )
507+
;
508+
markerFrequencyLabel->setText( mFreq );
509+
} else
505510
markerFrequencyLabel->setText( "" );
506511
}
507512
}
@@ -524,7 +529,7 @@ void DsoWidget::updateTriggerDetails() {
524529
tablePalette.setColor(QPalette::WindowText, view->screen.voltage[scope->trigger.source]);
525530
settingsTriggerLabel->setPalette(tablePalette);
526531
QString levelString = valueToString(scope->voltage[scope->trigger.source].trigger, UNIT_VOLTS, 3);
527-
QString pretriggerString = tr("%L1%").arg((int)(scope->trigger.position * 100 + 0.5));
532+
QString pretriggerString = tr("%L1%").arg( (int)round(scope->trigger.position * 100 ) );
528533
QString pre = Dso::slopeString(scope->trigger.slope); // trigger slope
529534
QString post = pre; // opposite trigger slope
530535
if ( scope->trigger.slope == Dso::Slope::Positive )

openhantek/src/exporting/legacyexportdrawer.cpp

+31-11
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,16 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
176176
painter.setPen(colorValues->text);
177177

178178
// Calculate variables needed for zoomed scope
179-
double m1 = settings->scope.getMarker(0);
180-
double m2 = settings->scope.getMarker(1);
179+
double m1 = settings->scope.getMarker(0) + DIVS_TIME / 2; // zero at center -> zero at left margin
180+
double m2 = settings->scope.getMarker(1) + DIVS_TIME / 2; // zero at center -> zero at left margin
181181
if ( m1 > m2 )
182182
std::swap( m1, m2 );
183183
double divs = m2 - m1;
184184
double zoomFactor = DIVS_TIME / divs;
185185
double zoomOffset = (m1 + m2) / 2;
186-
double time1 = m1 * settings->scope.horizontal.timebase;
187-
double time2 = m2 * settings->scope.horizontal.timebase;
186+
double time1 = ( m1 - DIVS_TIME * settings->scope.trigger.position) * settings->scope.horizontal.timebase;
187+
double time2 = ( m2 - DIVS_TIME * settings->scope.trigger.position) * settings->scope.horizontal.timebase;
188188
double time = divs * settings->scope.horizontal.timebase;
189-
m1 += DIVS_TIME / 2; // zero at center -> zero at left margin
190-
m2 += DIVS_TIME / 2;
191189
double freq1 = m1 * settings->scope.horizontal.frequencybase;
192190
double freq2 = m2 * settings->scope.horizontal.frequencybase;
193191
double freq = freq2 - freq1;
@@ -221,7 +219,7 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
221219
tr("/div"),
222220
QTextOption(Qt::AlignRight));
223221
} else {
224-
stretchBase = (double)paintDevice->width() / 7;
222+
stretchBase = (double)paintDevice->width() / 8;
225223
scopeHeight = (double)paintDevice->height() - (channelCount + 4) * lineHeight;
226224
double top = 2.5 * lineHeight + scopeHeight;
227225

@@ -230,13 +228,18 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
230228
"t1: " + valueToString( time1, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
231229
painter.drawText(QRectF(stretchBase * 2, top, stretchBase, lineHeight),
232230
"t2: " + valueToString( time2, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
233-
painter.drawText(QRectF(stretchBase * 3, top, stretchBase, lineHeight),
231+
if ( time ) {
232+
painter.drawText(QRectF(stretchBase * 3, top, stretchBase, lineHeight),
234233
"Δt: " + valueToString( time, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
235-
painter.drawText(QRectF(stretchBase * 4, top, stretchBase, lineHeight),
236-
"f1: " + valueToString( freq1, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
234+
painter.drawText(QRectF(stretchBase * 4, top, stretchBase, lineHeight),
235+
" (=" + valueToString( 1/time, UNIT_HERTZ, 4 ) + ")", QTextOption(Qt::AlignLeft));
236+
}
237237
painter.drawText(QRectF(stretchBase * 5, top, stretchBase, lineHeight),
238-
"f2: " + valueToString( freq2, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
238+
"f1: " + valueToString( freq1, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
239239
painter.drawText(QRectF(stretchBase * 6, top, stretchBase, lineHeight),
240+
"f2: " + valueToString( freq2, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
241+
if ( freq)
242+
painter.drawText(QRectF(stretchBase * 7, top, stretchBase, lineHeight),
240243
"Δf: " + valueToString( freq, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
241244
}
242245

@@ -325,12 +328,29 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
325328
break;
326329

327330
case Dso::GraphFormat::XY:
331+
// TODO: create also XY image
328332
break;
329333

330334
default:
331335
break;
332336
}
333337

338+
if ( !zoomed ) { // draw marker lines and trigger position
339+
const double trig = DIVS_TIME * ( settings->scope.trigger.position - 0.5 );
340+
const double tick = (double)DIVS_TIME / 250.0;
341+
const double top = DIVS_VOLTAGE/2;
342+
const double bottom = -DIVS_VOLTAGE/2;
343+
const double left = -DIVS_TIME/2;
344+
//const double right = DIVS_TIME/2;
345+
painter.setPen( QPen(colorValues->markers, 0) );
346+
// markers
347+
painter.drawLine( QLineF( m1 + left, bottom - 4 * tick, m1 + left, top ) );
348+
painter.drawLine( QLineF( m2 + left, bottom - 4 * tick, m2 + left, top ) );
349+
// trigger point (t=0)
350+
painter.drawLine( QLineF( trig - tick, top + 4 * tick, trig, top ) );
351+
painter.drawLine( QLineF( trig + tick, top + 4 * tick, trig, top ) );
352+
}
353+
334354
// Set DIVS_TIME / zoomFactor x DIVS_VOLTAGE matrix for zoomed
335355
// oscillograph
336356
painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME * zoomFactor, 0, 0,

openhantek/src/selectdevice/selectsupporteddevice.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
5757
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
5858
if (ui->cmbDevices->currentData(Qt::UserRole+2).toBool()) {
5959
ui->labelReadyState->setText(tr("<p>Upload in progress ...</p>"
60-
"<p>If the upload takes more than 30 s, please close this window <br/>and restart the program!</p>"));
60+
"<p><b>If the upload takes more than 30 s, please close this window <br/>and restart the program!</b></p>"
61+
"<p>In this case, please unplug other USB devices on the same bus!<br/>"
62+
"You can check this under Linux with: <pre>lsusb; lsusb -t</pre></p>"
63+
));
6164
} else {
6265
ui->labelReadyState->setText(tr("Connection failed!"));
6366
}

0 commit comments

Comments
 (0)