Skip to content

Commit

Permalink
consistent marker handling; user manual update; upversion
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Nov 15, 2019
1 parent ec1196f commit 037731c
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 211 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ firmware/hex
*.json
*.kate-swp
.directory
.kdev4
*.kdev4
Binary file modified docs/OpenHantek6022_User_Manual.odt
Binary file not shown.
Binary file modified docs/OpenHantek6022_User_Manual.pdf
Binary file not shown.
Binary file modified docs/images/screenshot_mainwindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion openhantek/src/OH_BUILD.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Do not edit, will be re-created at each commit!
#define OH_BUILD "20191112 build 548"
#define OH_BUILD "20191115 build 549"
2 changes: 1 addition & 1 deletion openhantek/src/OH_VERSION.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// define the version that is shown on top of the program
// if undefined (for development commits) the build will be shown by OpenHantek

#define OH_VERSION "v2.17-rc8"
#define OH_VERSION "3.0.0"


# ifdef OH_VERSION
Expand Down
63 changes: 34 additions & 29 deletions openhantek/src/dsowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::
markerInfoLabel->setAlignment(Qt::AlignLeft);
markerInfoLabel->setPalette(palette);
markerTimeLabel = new QLabel();
markerTimeLabel->setAlignment(Qt::AlignRight);
markerTimeLabel->setAlignment(Qt::AlignLeft);
markerTimeLabel->setPalette(palette);
markerFrequencyLabel = new QLabel();
markerFrequencyLabel->setAlignment(Qt::AlignRight);
markerFrequencyLabel->setAlignment(Qt::AlignLeft);
markerFrequencyLabel->setPalette(palette);
markerTimebaseLabel = new QLabel();
markerTimebaseLabel->setAlignment(Qt::AlignRight);
Expand Down Expand Up @@ -409,18 +409,17 @@ void DsoWidget::setMeasurementVisible(ChannelID channel) {

/// \brief Update the label about the marker measurements
void DsoWidget::updateMarkerDetails() {
double div0 = scope->horizontal.cursor.pos[0].x();
double div1 = scope->horizontal.cursor.pos[1].x();
if ( div0 > div1 )
std::swap( div0, div1 );
double divs = div1 - div0;
double time0 = div0 * scope->horizontal.timebase;
double time1 = div1 * scope->horizontal.timebase;
double m1 = scope->horizontal.cursor.pos[0].x() + DIVS_TIME / 2; // zero at center -> zero at left margin
double m2 = scope->horizontal.cursor.pos[1].x() + DIVS_TIME / 2; // zero at center -> zero at left margin
if ( m1 > m2 )
std::swap( m1, m2 );
double divs = m2 - m1;
// t = 0 at trigger position
double time0 = ( m1 - DIVS_TIME * scope->trigger.position ) * scope->horizontal.timebase;
double time1 = ( m2 - DIVS_TIME * scope->trigger.position ) * scope->horizontal.timebase;
double time = divs * scope->horizontal.timebase;
div0 += DIVS_TIME / 2; // zero at center -> zero at left margin
div1 += DIVS_TIME / 2;
double freq0 = div0 * scope->horizontal.frequencybase;
double freq1 = div1 * scope->horizontal.frequencybase;
double freq0 = m1 * scope->horizontal.frequencybase;
double freq1 = m2 * scope->horizontal.frequencybase;
double freq = divs * scope->horizontal.frequencybase;
bool timeUsed = false;
bool freqUsed = false;
Expand Down Expand Up @@ -458,7 +457,7 @@ void DsoWidget::updateMarkerDetails() {
++index;
}

if ( DIVS_TIME == divs || (div0 == 0 && div1 == 0) || (div0 == DIVS_TIME && div1 == DIVS_TIME) ) {
if ( DIVS_TIME == divs || ( m1 == 0 && m2 == 0) || ( m1 == DIVS_TIME && m2 == DIVS_TIME) ) {
// markers at left/right margins -> don't display
markerInfoLabel->setVisible( false );
markerTimeLabel->setVisible( false );
Expand Down Expand Up @@ -487,21 +486,27 @@ void DsoWidget::updateMarkerDetails() {
markerFrequencybaseLabel->setVisible( freqUsed );
}
markerInfoLabel->setText( mInfo );
if ( timeUsed )
markerTimeLabel->setText( mTime.append( "%1 -> %2, Δt: %3 " )
.arg( valueToString( time0, UNIT_SECONDS, 4 ) )
.arg( valueToString( time1, UNIT_SECONDS, 4 ) )
.arg( valueToString( time, UNIT_SECONDS, 4 ) )
);
else
if ( timeUsed ) {
mTime += QString( "%1" ).arg( valueToString( time0, UNIT_SECONDS, 4 ) );
if ( time )
mTime += QString( " -> %1, Δt: %2 (%3) ")
.arg( valueToString( time1, UNIT_SECONDS, 4 ) )
.arg( valueToString( time, UNIT_SECONDS, 4 ) )
.arg( valueToString( 1/time, UNIT_HERTZ, 4) )
;
markerTimeLabel->setText( mTime );
} else {
markerTimeLabel->setText( "" );
if ( freqUsed )
markerFrequencyLabel->setText( mFreq.append( "%1 -> %2, Δf: %3 " )
.arg( valueToString( freq0, UNIT_HERTZ, 4) )
.arg( valueToString( freq1, UNIT_HERTZ, 4) )
.arg( valueToString( freq, UNIT_HERTZ, 4) )
);
else
}
if ( freqUsed ) {
mFreq += QString( "%1" ).arg( valueToString( freq0, UNIT_HERTZ, 4) );
if ( freq )
mFreq += QString( " -> %2, Δf: %3 " )
.arg( valueToString( freq1, UNIT_HERTZ, 4) )
.arg( valueToString( freq, UNIT_HERTZ, 4) )
;
markerFrequencyLabel->setText( mFreq );
} else
markerFrequencyLabel->setText( "" );
}
}
Expand All @@ -524,7 +529,7 @@ void DsoWidget::updateTriggerDetails() {
tablePalette.setColor(QPalette::WindowText, view->screen.voltage[scope->trigger.source]);
settingsTriggerLabel->setPalette(tablePalette);
QString levelString = valueToString(scope->voltage[scope->trigger.source].trigger, UNIT_VOLTS, 3);
QString pretriggerString = tr("%L1%").arg((int)(scope->trigger.position * 100 + 0.5));
QString pretriggerString = tr("%L1%").arg( (int)round(scope->trigger.position * 100 ) );
QString pre = Dso::slopeString(scope->trigger.slope); // trigger slope
QString post = pre; // opposite trigger slope
if ( scope->trigger.slope == Dso::Slope::Positive )
Expand Down
42 changes: 31 additions & 11 deletions openhantek/src/exporting/legacyexportdrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,16 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
painter.setPen(colorValues->text);

// Calculate variables needed for zoomed scope
double m1 = settings->scope.getMarker(0);
double m2 = settings->scope.getMarker(1);
double m1 = settings->scope.getMarker(0) + DIVS_TIME / 2; // zero at center -> zero at left margin
double m2 = settings->scope.getMarker(1) + DIVS_TIME / 2; // zero at center -> zero at left margin
if ( m1 > m2 )
std::swap( m1, m2 );
double divs = m2 - m1;
double zoomFactor = DIVS_TIME / divs;
double zoomOffset = (m1 + m2) / 2;
double time1 = m1 * settings->scope.horizontal.timebase;
double time2 = m2 * settings->scope.horizontal.timebase;
double time1 = ( m1 - DIVS_TIME * settings->scope.trigger.position) * settings->scope.horizontal.timebase;
double time2 = ( m2 - DIVS_TIME * settings->scope.trigger.position) * settings->scope.horizontal.timebase;
double time = divs * settings->scope.horizontal.timebase;
m1 += DIVS_TIME / 2; // zero at center -> zero at left margin
m2 += DIVS_TIME / 2;
double freq1 = m1 * settings->scope.horizontal.frequencybase;
double freq2 = m2 * settings->scope.horizontal.frequencybase;
double freq = freq2 - freq1;
Expand Down Expand Up @@ -221,7 +219,7 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
tr("/div"),
QTextOption(Qt::AlignRight));
} else {
stretchBase = (double)paintDevice->width() / 7;
stretchBase = (double)paintDevice->width() / 8;
scopeHeight = (double)paintDevice->height() - (channelCount + 4) * lineHeight;
double top = 2.5 * lineHeight + scopeHeight;

Expand All @@ -230,13 +228,18 @@ bool LegacyExportDrawer::exportSamples(const PPresult *result, QPaintDevice* pai
"t1: " + valueToString( time1, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
painter.drawText(QRectF(stretchBase * 2, top, stretchBase, lineHeight),
"t2: " + valueToString( time2, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
painter.drawText(QRectF(stretchBase * 3, top, stretchBase, lineHeight),
if ( time ) {
painter.drawText(QRectF(stretchBase * 3, top, stretchBase, lineHeight),
"Δt: " + valueToString( time, UNIT_SECONDS, 4 ), QTextOption(Qt::AlignRight));
painter.drawText(QRectF(stretchBase * 4, top, stretchBase, lineHeight),
"f1: " + valueToString( freq1, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
painter.drawText(QRectF(stretchBase * 4, top, stretchBase, lineHeight),
" (=" + valueToString( 1/time, UNIT_HERTZ, 4 ) + ")", QTextOption(Qt::AlignLeft));
}
painter.drawText(QRectF(stretchBase * 5, top, stretchBase, lineHeight),
"f2: " + valueToString( freq2, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
"f1: " + valueToString( freq1, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
painter.drawText(QRectF(stretchBase * 6, top, stretchBase, lineHeight),
"f2: " + valueToString( freq2, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
if ( freq)
painter.drawText(QRectF(stretchBase * 7, top, stretchBase, lineHeight),
"Δf: " + valueToString( freq, UNIT_HERTZ, 4 ), QTextOption(Qt::AlignRight));
}

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

case Dso::GraphFormat::XY:
// TODO: create also XY image
break;

default:
break;
}

if ( !zoomed ) { // draw marker lines and trigger position
const double trig = DIVS_TIME * ( settings->scope.trigger.position - 0.5 );
const double tick = (double)DIVS_TIME / 250.0;
const double top = DIVS_VOLTAGE/2;
const double bottom = -DIVS_VOLTAGE/2;
const double left = -DIVS_TIME/2;
//const double right = DIVS_TIME/2;
painter.setPen( QPen(colorValues->markers, 0) );
// markers
painter.drawLine( QLineF( m1 + left, bottom - 4 * tick, m1 + left, top ) );
painter.drawLine( QLineF( m2 + left, bottom - 4 * tick, m2 + left, top ) );
// trigger point (t=0)
painter.drawLine( QLineF( trig - tick, top + 4 * tick, trig, top ) );
painter.drawLine( QLineF( trig + tick, top + 4 * tick, trig, top ) );
}

// Set DIVS_TIME / zoomFactor x DIVS_VOLTAGE matrix for zoomed
// oscillograph
painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME * zoomFactor, 0, 0,
Expand Down
5 changes: 4 additions & 1 deletion openhantek/src/selectdevice/selectsupporteddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
if (ui->cmbDevices->currentData(Qt::UserRole+2).toBool()) {
ui->labelReadyState->setText(tr("<p>Upload in progress ...</p>"
"<p>If the upload takes more than 30 s, please close this window <br/>and restart the program!</p>"));
"<p><b>If the upload takes more than 30 s, please close this window <br/>and restart the program!</b></p>"
"<p>In this case, please unplug other USB devices on the same bus!<br/>"
"You can check this under Linux with: <pre>lsusb; lsusb -t</pre></p>"
));
} else {
ui->labelReadyState->setText(tr("Connection failed!"));
}
Expand Down
Loading

0 comments on commit 037731c

Please sign in to comment.