Skip to content

Commit

Permalink
upversion to 3.1.1-rc; options to force OpenGL SL versions
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Jun 20, 2020
1 parent d592942 commit 1dad788
Show file tree
Hide file tree
Showing 29 changed files with 301 additions and 190 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
3.0.1
3.1.1-rc1
2020-06-20
Slow timebases up to 10s/div
Near real time screen updates with trigger mode NONE
Screenshot and hardcopy are identical to the screen content
Force OpenGL SL version (option --useGLSL120 or --useGLSL150)

3.1.0
2020-05-08
Demo mode without scope hardware (option -d or --demoMode)
Support for high-dpi displays
Expand Down
2 changes: 1 addition & 1 deletion openhantek/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
Expand Down
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 "20200616 build 706"
#define OH_BUILD "20200620 build 707"
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 "3.1.1-rc1"
#define OH_VERSION "3.1.1-rc1"

#ifdef OH_VERSION
#undef VERSION
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/docks/HorizontalDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ HorizontalDock::HorizontalDock( DsoSettingsScope *scope, const Dso::ControlSpeci
this->timebaseSiSpinBox = new SiSpinBox( UNIT_SECONDS );
this->timebaseSiSpinBox->setSteps( timebaseSteps );
this->timebaseSiSpinBox->setMinimum( 1e-9 );
this->timebaseSiSpinBox->setMaximum( 3.6e3 );
this->timebaseSiSpinBox->setMaximum( 1e3 );

this->frequencybaseLabel = new QLabel( tr( "Frequencybase" ) );
this->frequencybaseSiSpinBox = new SiSpinBox( UNIT_HERTZ );
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/dsosettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void DsoSettings::save() {
storeSettings->setValue( "frequencybase", scope.horizontal.frequencybase );
for ( int marker = 0; marker < 2; ++marker )
storeSettings->setValue( QString( "marker%1" ).arg( marker ), scope.getMarker( unsigned( marker ) ) );
storeSettings->setValue( "timebase", qMin( scope.horizontal.timebase, 0.1 ) );
storeSettings->setValue( "timebase", scope.horizontal.timebase );
storeSettings->setValue( "maxTimebase", scope.horizontal.maxTimebase );
storeSettings->setValue( "acquireInterval", scope.horizontal.acquireInterval );
storeSettings->setValue( "recordLength", scope.horizontal.recordLength );
Expand Down
38 changes: 19 additions & 19 deletions openhantek/src/dsowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ DsoWidget::DsoWidget( DsoSettingsScope *scope, DsoSettingsView *view, const Dso:
mainLayout->setColumnStretch( 3, 1 ); // Scopes increase their size
// Bars around the scope, needed because the slider-drawing-area is outside
// the scope at min/max
mainLayout->setColumnMinimumWidth( 2, mainSliders.triggerOffsetSlider->preMargin() );
mainLayout->setColumnMinimumWidth( 4, mainSliders.triggerOffsetSlider->postMargin() );
mainLayout->setColumnMinimumWidth( 2, mainSliders.triggerPositionSlider->preMargin() );
mainLayout->setColumnMinimumWidth( 4, mainSliders.triggerPositionSlider->postMargin() );
mainLayout->setSpacing( 0 );
int row = 0;
// display settings on top of scope
mainLayout->addLayout( settingsLayout, row, 1, 1, 5 );
++row;
// 5x5 box for mainScope & mainSliders & markerSlider
mainLayout->addWidget( mainSliders.triggerOffsetSlider, row, 2, 2, 3, Qt::AlignBottom );
mainLayout->addWidget( mainSliders.triggerPositionSlider, row, 2, 2, 3, Qt::AlignBottom );
++row;
mainLayout->setRowMinimumHeight( row, mainSliders.voltageOffsetSlider->preMargin() );
mainLayout->addWidget( mainSliders.voltageOffsetSlider, row, 1, 3, 2, Qt::AlignRight );
Expand All @@ -247,7 +247,7 @@ DsoWidget::DsoWidget( DsoSettingsScope *scope, DsoSettingsView *view, const Dso:
++row;
++row;
// 5x4 box for zoomScope & zoomSliders
mainLayout->addWidget( zoomSliders.triggerOffsetSlider, row, 2, 2, 3, Qt::AlignBottom );
mainLayout->addWidget( zoomSliders.triggerPositionSlider, row, 2, 2, 3, Qt::AlignBottom );
++row;
mainLayout->setRowMinimumHeight( row, zoomSliders.voltageOffsetSlider->preMargin() );
mainLayout->addWidget( zoomSliders.voltageOffsetSlider, row, 1, 3, 2, Qt::AlignRight );
Expand All @@ -273,9 +273,9 @@ DsoWidget::DsoWidget( DsoSettingsScope *scope, DsoSettingsView *view, const Dso:
connect( mainSliders.voltageOffsetSlider, &LevelSlider::valueChanged, this, &DsoWidget::updateOffset );
connect( zoomSliders.voltageOffsetSlider, &LevelSlider::valueChanged, this, &DsoWidget::updateOffset );

connect( mainSliders.triggerOffsetSlider, &LevelSlider::valueChanged,
connect( mainSliders.triggerPositionSlider, &LevelSlider::valueChanged,
[this]( int index, double value ) { updateTriggerOffset( index, value, true ); } );
connect( zoomSliders.triggerOffsetSlider, &LevelSlider::valueChanged,
connect( zoomSliders.triggerPositionSlider, &LevelSlider::valueChanged,
[this]( int index, double value ) { updateTriggerOffset( index, value, false ); } );

connect( mainSliders.triggerLevelSlider, &LevelSlider::valueChanged, this, &DsoWidget::updateTriggerLevel );
Expand Down Expand Up @@ -402,12 +402,12 @@ void DsoWidget::setupSliders( DsoWidget::Sliders &sliders ) {
}

// The triggerPosition slider
sliders.triggerOffsetSlider = new LevelSlider( Qt::DownArrow );
sliders.triggerOffsetSlider->addSlider();
sliders.triggerOffsetSlider->setLimits( 0, 0.0, 1.0 );
sliders.triggerOffsetSlider->setStep( 0, 0.2 / double( DIVS_TIME ) );
sliders.triggerOffsetSlider->setValue( 0, scope->trigger.offset );
sliders.triggerOffsetSlider->setIndexVisible( 0, true );
sliders.triggerPositionSlider = new LevelSlider( Qt::DownArrow );
sliders.triggerPositionSlider->addSlider();
sliders.triggerPositionSlider->setLimits( 0, 0.0, 1.0 );
sliders.triggerPositionSlider->setStep( 0, 0.2 / double( DIVS_TIME ) );
sliders.triggerPositionSlider->setValue( 0, scope->trigger.offset );
sliders.triggerPositionSlider->setIndexVisible( 0, true );

// The sliders for the trigger levels
sliders.triggerLevelSlider = new LevelSlider( Qt::LeftArrow );
Expand Down Expand Up @@ -704,8 +704,8 @@ void DsoWidget::updateTriggerSlope() { updateTriggerDetails(); }
/// \brief Handles sourceChanged signal from the trigger dock.
void DsoWidget::updateTriggerSource() {
// Change the colors of the trigger sliders
mainSliders.triggerOffsetSlider->setColor( 0, view->colors->voltage[ scope->trigger.source ] );
zoomSliders.triggerOffsetSlider->setColor( 0, view->colors->voltage[ scope->trigger.source ] );
mainSliders.triggerPositionSlider->setColor( 0, view->colors->voltage[ scope->trigger.source ] );
zoomSliders.triggerPositionSlider->setColor( 0, view->colors->voltage[ scope->trigger.source ] );

for ( ChannelID channel = 0; channel < spec->channels; ++channel ) {
QColor color =
Expand Down Expand Up @@ -778,7 +778,7 @@ void DsoWidget::updateZoom( bool enabled ) {
mainLayout->setRowStretch( zoomScopeRow, enabled ? 1 : 0 );
zoomScope->setVisible( enabled );
zoomSliders.voltageOffsetSlider->setVisible( enabled );
zoomSliders.triggerOffsetSlider->setVisible( enabled );
zoomSliders.triggerPositionSlider->setVisible( enabled );
zoomSliders.triggerLevelSlider->setVisible( enabled );
// Show time-/frequencybase and zoom factor if the magnified scope is shown
markerLayout->setStretch( 3, enabled ? 1 : 0 );
Expand Down Expand Up @@ -915,7 +915,7 @@ double DsoWidget::zoomToMain( double position ) const {
void DsoWidget::adaptTriggerOffsetSlider() {
double value = mainToZoom( scope->trigger.offset );

LevelSlider &slider = *zoomSliders.triggerOffsetSlider;
LevelSlider &slider = *zoomSliders.triggerPositionSlider;
const QSignalBlocker blocker( slider );
if ( slider.minimum( 0 ) <= value && value <= slider.maximum( 0 ) ) {
slider.setEnabled( true );
Expand Down Expand Up @@ -944,8 +944,8 @@ void DsoWidget::updateTriggerOffset( int index, double value, bool mainView ) {
adaptTriggerOffsetSlider();
} else {
scope->trigger.offset = zoomToMain( value );
const QSignalBlocker blocker( mainSliders.triggerOffsetSlider );
mainSliders.triggerOffsetSlider->setValue( index, scope->trigger.offset );
const QSignalBlocker blocker( mainSliders.triggerPositionSlider );
mainSliders.triggerPositionSlider->setValue( index, scope->trigger.offset );
}

updateTriggerDetails();
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void DsoWidget::updateSlidersSettings() {
}

// The trigger position slider
mainSliders.triggerOffsetSlider->setValue( 0, scope->trigger.offset );
mainSliders.triggerPositionSlider->setValue( 0, scope->trigger.offset );
updateTriggerOffset( 0, scope->trigger.offset, true ); // main slider
updateTriggerOffset( 0, mainToZoom( scope->trigger.offset ), false ); // zoom slider

Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/dsowidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DsoWidget : public QWidget {
public:
struct Sliders {
LevelSlider *voltageOffsetSlider; ///< The sliders for the graph offsets
LevelSlider *triggerOffsetSlider; ///< The slider for the pretrigger
LevelSlider *triggerPositionSlider; ///< The slider for the pretrigger
LevelSlider *triggerLevelSlider; ///< The sliders for the trigger level
LevelSlider *markerSlider; ///< The sliders for the markers
};
Expand Down
14 changes: 9 additions & 5 deletions openhantek/src/glscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GlScope *GlScope::createZoomed( DsoSettingsScope *scope, DsoSettingsView *view,
return s;
}

void GlScope::fixOpenGLversion( QSurfaceFormat::RenderableType t ) {
void GlScope::useQSurfaceFormat( QSurfaceFormat::RenderableType t ) {
QCoreApplication::setAttribute( Qt::AA_ShareOpenGLContexts, true );

// Prefer full desktop OpenGL without fixed pipeline
Expand Down Expand Up @@ -67,8 +67,7 @@ GlScope::GlScope( DsoSettingsScope *scope, DsoSettingsView *view, QWidget *paren
context.makeCurrent( &surface );
QString glVersion = reinterpret_cast< const char * >( context.functions()->glGetString( GL_VERSION ) );
GLSLversion = glVersion >= "3.2" ? 150 : 120; // version string "3.2 xxxx" > "3.2" is true
// qDebug() << glVersion;
// qDebug() << GLSLversion;
// qDebug() << "OpenGL version" << glVersion << GLSLversion;
surface.destroy();

cursorInfo.clear();
Expand Down Expand Up @@ -227,6 +226,8 @@ void GlScope::paintEvent( QPaintEvent *event ) {
event->accept(); // consume the event
}

unsigned GlScope::forceGLSLversion = 0;

void GlScope::initializeGL() {
if ( !QOpenGLShaderProgram::hasOpenGLShaderPrograms( context() ) ) {
errorMessage = tr( "System does not support OpenGL Shading Language (GLSL)" );
Expand Down Expand Up @@ -287,11 +288,14 @@ void GlScope::initializeGL() {
out vec4 flatColor;
void main() { flatColor = colour; }
)";
// GLSLversion = 150;

if ( GlScope::forceGLSLversion )
GLSLversion = GlScope::forceGLSLversion;
// qDebug() << "compile shaders" << GlScope::forceGLSLversion << GLSLversion;

const char *vshaderDesktop = GLSLversion == 120 ? vshaderDesktop120 : vshaderDesktop150;
const char *fshaderDesktop = GLSLversion == 120 ? fshaderDesktop120 : fshaderDesktop150;

// qDebug() << "compile shaders";
// Compile vertex shader
bool usesOpenGL = QSurfaceFormat::defaultFormat().renderableType() == QSurfaceFormat::OpenGL;
if ( !program->addShaderFromSourceCode( QOpenGLShader::Vertex, usesOpenGL ? vshaderDesktop : vshaderES ) ||
Expand Down
7 changes: 5 additions & 2 deletions openhantek/src/glscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class GlScope : public QOpenGLWidget {
static GlScope *createZoomed( DsoSettingsScope *scope, DsoSettingsView *view, QWidget *parent = nullptr );

/**
* We need at least OpenGL 3.2 with shader version 150 or
* We need at least OpenGL 3.2 with shader version 150 (else version 120) or
* OpenGL ES 2.0 with shader version 100.
*/
static void fixOpenGLversion( QSurfaceFormat::RenderableType t = QSurfaceFormat::DefaultRenderableType );
static void useQSurfaceFormat( QSurfaceFormat::RenderableType t = QSurfaceFormat::DefaultRenderableType );
// force either GLSL version 1.20 or 1.50
static void useOpenGLSLversion( unsigned version ) { forceGLSLversion = version; }
/**
* Show new post processed data
* @param data
Expand Down Expand Up @@ -121,6 +123,7 @@ class GlScope : public QOpenGLWidget {

// OpenGL shader, matrix, var-locations
unsigned int GLSLversion = 150;
static unsigned forceGLSLversion;
bool shaderCompileSuccess = false;
QString errorMessage;
std::unique_ptr< QOpenGLShaderProgram > m_program;
Expand Down
35 changes: 19 additions & 16 deletions openhantek/src/hantekdso/capturing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <cmath>


static std::vector< QString > controlNames = {"SETGAIN_CH1", "SETGAIN_CH2", "SETSAMPLERATE", "STARTSAMPLING",
"SETNUMCHANNELS", "SETCOUPLING", "SETCALFREQ"};
// static std::vector< QString > controlNames = {"SETGAIN_CH1", "SETGAIN_CH2", "SETSAMPLERATE", "STARTSAMPLING",
// "SETNUMCHANNELS", "SETCOUPLING", "SETCALFREQ"};

Capturing::Capturing( HantekDsoControl *hdc ) : hdc( hdc ) { hdc->capturing = true; }

Expand Down Expand Up @@ -88,7 +88,7 @@ void Capturing::capture() {
}
QString name = "";
if ( controlCommand->code >= 0xe0 && controlCommand->code <= 0xe6 )
name = controlNames[ controlCommand->code - 0xe0 ];
name = hdc->controlNames[ controlCommand->code - 0xe0 ];
timestampDebug( QString( "Sending control command 0x%1 (%2):%3" )
.arg( QString::number( controlCommand->code, 16 ), name,
hexdecDump( controlCommand->data(), unsigned( controlCommand->size() ) ) ) );
Expand Down Expand Up @@ -146,7 +146,8 @@ unsigned Capturing::getRealSamples() {
}
// Save raw data to temporary buffer
timestampDebug( QString( "Request packet %1: %2" ).arg( tag ).arg( rawSamplesize ) );
int retval = hdc->scopeDevice->bulkReadMulti( dp->data(), rawSamplesize, !realSlow );
hdc->raw.received = 0;
int retval = hdc->scopeDevice->bulkReadMulti( dp->data(), rawSamplesize, realSlow, hdc->raw.received );
if ( retval < 0 ) {
qWarning() << "bulkReadMulti: Getting sample data failed: " << libUsbErrorString( retval );
dp->clear();
Expand All @@ -158,14 +159,17 @@ unsigned Capturing::getRealSamples() {


unsigned Capturing::getDemoSamples() {
const uint8_t V_zero = 128; // ADC = 0V
const uint8_t V_plus_1 = 153; // ADC = 1V
const uint8_t V_plus_2 = 178; // ADC = 2V
const uint8_t V_minus_2 = 78; // ADC = -2V
static uint8_t ch1 = V_zero;
static uint8_t ch2 = V_zero;
const uint8_t V_zero = 0x80; // ADC = 0V
const int8_t V_plus_1 = 25; // ADC = 1V
const int8_t V_plus_2 = 50; // ADC = 2V
const int8_t V_minus_2 = -50; // ADC = -2V
const int gain1 = int( gainValue[ 0 ] );
const int gain2 = int( gainValue[ 1 ] );
static int ch1 = 0;
static int ch2 = 0;
static int counter = 0;
unsigned received = 0;
hdc->raw.received = 0;
timestampDebug( QString( "Request dummy packet %1: %2" ).arg( tag ).arg( rawSamplesize ) );
int deltaT = 99;
// deltaT (=99) defines the frequency of the dummy signals:
Expand All @@ -178,28 +182,27 @@ unsigned Capturing::getDemoSamples() {
deltaT = int( round( deltaT * samplerate / 10e6 ) );
const unsigned packetLength = 512 * 78; // 50 blocks for one screen width of 20000
unsigned block = 0;
dp->resize( rawSamplesize, 0x80 );
dp->resize( rawSamplesize, V_zero );
auto end = dp->end();
unsigned packet = 0;
for ( auto it = dp->begin(); it != end; ++it ) {
if ( ++counter >= deltaT ) {
counter = 0;
if ( --ch1 < V_minus_2 ) {
ch1 = V_plus_2;
ch2 = ch2 <= V_plus_1 ? V_plus_2 : V_zero;
ch2 = ch2 <= V_plus_1 ? V_plus_2 : 0;
}
}
*it = ch1;
*it = uint8_t( qBound( 0, ch1 * gain1 + V_zero, 0xFF ) ); // simulate clipping
++received;
if ( 2 == channels ) {
*++it = ch2;
*++it = uint8_t( qBound( 0, ch2 * gain2 + V_zero, 0xFF ) ); // simulate clipping
++received;
}
if ( ( block += channels ) >= packetLength ) {
++packet;
block = 0;
if ( realSlow ) // clear next block as visible hint where we are
std::for_each( it, qMin( it + packetLength, end ), []( uint8_t &d ) { d = 0x80; } );
hdc->raw.received = received;
QThread::usleep( unsigned( 1e6 * packetLength / channels / samplerate ) );
if ( !hdc->capturing || hdc->scopeDevice->hasStopped() )
break;
Expand Down
3 changes: 2 additions & 1 deletion openhantek/src/hantekdso/dsosamples.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ struct DSOsamples {
double samplerate = 0.0; ///< The samplerate of the input data
unsigned char clipped = 0; ///< Bitmask of clipped channels
bool liveTrigger = false; ///< live samples are triggered
unsigned triggerPosition = 0; ///< position for a triggered trace, 0 = not triggered
unsigned triggeredPosition = 0; ///< position for a triggered trace, 0 = not triggered
double pulseWidth1 = 0.0; ///< width from trigger point to next opposite slope
double pulseWidth2 = 0.0; ///< width from next opposite slope to third slope
bool freeRunning = false; ///< trigger: NONE, half sample count
unsigned freeRunPosition = 0; ///< position of free running capturing
unsigned tag = 0; ///< track individual sample blocks (debug support)
mutable QReadWriteLock lock;
};
Loading

0 comments on commit 1dad788

Please sign in to comment.