Skip to content

Commit

Permalink
refactor MATH channel, can now trigger on MATH; more tool tips
Browse files Browse the repository at this point in the history
move math channel generation in front of trigger search
add more math modes (logical and of CH1 and CH2)
can now trigger on conditions like CH1 < 3V and CH2 > 4V
tool tip voltage/time display when moving trigger level and position
tool tips for most UI elements
silence some more warnings
new firmware that allows HW calibration generation (HW change needed)

Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
  • Loading branch information
Ho-Ro committed Apr 2, 2022
1 parent a2c57e7 commit 2fb76ba
Show file tree
Hide file tree
Showing 52 changed files with 4,731 additions and 2,158 deletions.
Binary file modified docs/OpenHantek6022_User_Manual.odt
Binary file not shown.
Binary file modified docs/OpenHantek6022_User_Manual.pdf
Binary file not shown.
413 changes: 207 additions & 206 deletions openhantek/res/firmware/dso6022be-firmware.hex

Large diffs are not rendered by default.

418 changes: 209 additions & 209 deletions openhantek/res/firmware/dso6022bl-firmware.hex

Large diffs are not rendered by default.

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 "20220325 - commit 977"
#define OH_BUILD "20220402 - commit 978"
15 changes: 9 additions & 6 deletions openhantek/src/configdialog/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ DsoConfigDialog::DsoConfigDialog( DsoSettings *settings, QWidget *parent ) : QDi
contentsWidget->setMinimumWidth( CONFIG_LIST_WIDTH );
contentsWidget->setMinimumHeight( CONFIG_LIST_ITEMHEIGHT * 3 + 2 * ( contentsWidget->frameWidth() ) );

analysisPage = new DsoConfigAnalysisPage( settings );
colorsPage = new DsoConfigColorsPage( settings );
scopePage = new DsoConfigScopePage( settings );
pagesWidget = new QStackedWidget;
scopePage = new DsoConfigScopePage( settings );
pagesWidget->addWidget( scopePage );
analysisPage = new DsoConfigAnalysisPage( settings );
pagesWidget->addWidget( analysisPage );
colorsPage = new DsoConfigColorsPage( settings );
pagesWidget->addWidget( colorsPage );

acceptButton = new QPushButton( tr( "&Ok" ) );
Expand Down Expand Up @@ -90,14 +90,17 @@ void DsoConfigDialog::createIcons() {
QListWidgetItem *scopeButton = new QListWidgetItem( contentsWidget );
scopeButton->setIcon( QIcon( ":config/scope.png" ) );
scopeButton->setText( tr( "Scope" ) );
scopeButton->setToolTip( tr( "Timing, display settings, and HW configuration" ) );

QListWidgetItem *spectrumButton = new QListWidgetItem( contentsWidget );
spectrumButton->setIcon( QIcon( ":config/spectrum.png" ) );
spectrumButton->setText( tr( "Analysis" ) );
QListWidgetItem *analysisButton = new QListWidgetItem( contentsWidget );
analysisButton->setIcon( QIcon( ":config/spectrum.png" ) );
analysisButton->setText( tr( "Analysis" ) );
analysisButton->setToolTip( tr( "FFT settings, power and THD calculation, musical note detection" ) );

QListWidgetItem *colorsButton = new QListWidgetItem( contentsWidget );
colorsButton->setIcon( QIcon( ":config/colors.png" ) );
colorsButton->setText( tr( "Colors" ) );
colorsButton->setToolTip( tr( "Screen and printer colors, theme and style settings" ) );

connect( contentsWidget, &QListWidget::currentItemChanged, this, &DsoConfigDialog::changePage );
}
Expand Down
4 changes: 2 additions & 2 deletions openhantek/src/configdialog/configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class DsoConfigDialog : public QDialog {

public:
DsoConfigDialog( DsoSettings *settings, QWidget *parent = nullptr );
~DsoConfigDialog();
~DsoConfigDialog() override;

public slots:
void accept();
void accept() override;
void apply();

void changePage( QListWidgetItem *current, QListWidgetItem *previous );
Expand Down
4 changes: 4 additions & 0 deletions openhantek/src/docks/HorizontalDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ HorizontalDock::HorizontalDock( DsoSettingsScope *scope, const Dso::ControlSpeci
// Initialize elements
samplerateLabel = new QLabel( tr( "Samplerate" ) );
samplerateSiSpinBox = new SiSpinBox( UNIT_SAMPLES );
samplerateSiSpinBox->setToolTip( tr( "Effective samplerate, automatically selected from 'Timebase' setting" ) );
samplerateSiSpinBox->setMinimum( 1 );
samplerateSiSpinBox->setMaximum( 1e8 );
samplerateSiSpinBox->setUnitPostfix( tr( "/s" ) );
Expand All @@ -43,19 +44,22 @@ HorizontalDock::HorizontalDock( DsoSettingsScope *scope, const Dso::ControlSpeci

timebaseLabel = new QLabel( tr( "Timebase" ) );
timebaseSiSpinBox = new SiSpinBox( UNIT_SECONDS );
timebaseSiSpinBox->setToolTip( tr( "Time per horizontal screen division" ) );
timebaseSiSpinBox->setSteps( timebaseSteps );
timebaseSiSpinBox->setMinimum( 1e-9 );
timebaseSiSpinBox->setMaximum( 1e3 );

formatLabel = new QLabel( tr( "Format" ) );
formatComboBox = new QComboBox();
formatComboBox->setToolTip( tr( "Select signal over time or XY display" ) );
for ( Dso::GraphFormat format : Dso::GraphFormatEnum )
formatComboBox->addItem( Dso::graphFormatString( format ) );

calfreqLabel = new QLabel( tr( "Calibration out" ) );
calfreqSteps = spec->calfreqSteps;
std::reverse( calfreqSteps.begin(), calfreqSteps.end() ); // put highest value on top of the list
calfreqComboBox = new QComboBox();
calfreqComboBox->setToolTip( tr( "Select the frequency of the calibration output, scroll for fast change" ) );
for ( double calfreqStep : calfreqSteps )
calfreqComboBox->addItem( valueToString( calfreqStep, UNIT_HERTZ, calfreqStep < 10e3 ? 2 : 0 ) );

Expand Down
11 changes: 8 additions & 3 deletions openhantek/src/docks/SpectrumDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SpectrumDock::SpectrumDock( DsoSettingsScope *scope, QWidget *parent ) : QDockWi
for ( channel = 0; channel < scope->voltage.size(); ++channel ) {
ChannelBlock b;
b.magnitudeComboBox = ( new QComboBox() );
b.magnitudeComboBox->setToolTip( tr( "Magnitude per vertical screen division" ) );
QString name = scope->spectrum[ channel ].name;
name.insert( int( channel ), '&' ); // &SP1, S&P2, SP&M
b.usedCheckBox = ( new QCheckBox( name ) );
Expand Down Expand Up @@ -72,6 +73,7 @@ SpectrumDock::SpectrumDock( DsoSettingsScope *scope, QWidget *parent ) : QDockWi
}
frequencybaseLabel = new QLabel( tr( "Frequencybase" ) );
frequencybaseSiSpinBox = new SiSpinBox( UNIT_HERTZ );
frequencybaseSiSpinBox->setToolTip( tr( "Frequency range per horizontal screen division" ) );
frequencybaseSiSpinBox->setMinimum( 0.1 );
frequencybaseSiSpinBox->setMaximum( 100e6 );
dockLayout->addWidget( frequencybaseLabel, int( channel ), 0 );
Expand Down Expand Up @@ -136,20 +138,23 @@ unsigned SpectrumDock::setUsed( ChannelID channel, bool used ) {
scope->spectrum[ channel ].visible = used;
QSignalBlocker blocker( channelBlocks[ channel ].usedCheckBox );
channelBlocks[ channel ].usedCheckBox->setChecked( used );
emit usedChanged( channel, used );
if ( used )
emit usedChannelChanged( channel, channel + 1 ); // channel bit mask 0b01, 0b10, 0b11
else
emit usedChannelChanged( channel, 0 );
return channel;
}


void SpectrumDock::enableSpectrum( bool enabled ) {
void SpectrumDock::enableSpectrumDock( bool enabled ) { // disable when using XY display
if ( scope->verboseLevel > 2 )
qDebug() << " SDock::enableSpectrum()" << enabled;
for ( unsigned channel = 0; channel < scope->voltage.size(); ++channel ) {
QSignalBlocker blocker( channelBlocks[ channel ].usedCheckBox );
channelBlocks[ channel ].usedCheckBox->setEnabled( enabled );
channelBlocks[ channel ].usedCheckBox->setChecked( false );
scope->spectrum[ channel ].used = false;
emit usedChanged( channel, false );
emit usedChannelChanged( channel, 0 );
}
}

Expand Down
6 changes: 3 additions & 3 deletions openhantek/src/docks/SpectrumDock.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SpectrumDock : public QDockWidget {

/// \brief Enables/disables all channels.
/// \param enabled True if the channel should be enabled, false otherwise.
void enableSpectrum( bool enabled );
void enableSpectrumDock( bool enabled );

/// \brief Changes the frequencybase.
/// \param frequencybase The frequencybase in hertz.
Expand All @@ -59,7 +59,7 @@ class SpectrumDock : public QDockWidget {
void frequencybaseSelected( double frequencybase );

protected:
void closeEvent( QCloseEvent *event );
void closeEvent( QCloseEvent *event ) override;

QGridLayout *dockLayout; ///< The main layout for the dock window
QWidget *dockWidget; ///< The main widget for the dock window
Expand All @@ -80,6 +80,6 @@ class SpectrumDock : public QDockWidget {

signals:
void magnitudeChanged( ChannelID channel, double magnitude ); ///< A magnitude has been selected
void usedChanged( ChannelID channel, bool used ); ///< A spectrum has been enabled/disabled
void usedChannelChanged( ChannelID channel, unsigned used ); ///< A spectrum has been enabled/disabled
void frequencybaseChanged( double frequencybase ); ///< The frequencybase has been changed
};
5 changes: 5 additions & 0 deletions openhantek/src/docks/TriggerDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,29 @@ TriggerDock::TriggerDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
// Initialize lists for comboboxes
for ( ChannelID channel = 0; channel < mSpec->channels; ++channel )
sourceStandardStrings << tr( "CH%1" ).arg( channel + 1 );
sourceStandardStrings << tr( "MATH" );
// add "smooth" source
smoothStandardStrings << tr( "HF" ) << tr( "Normal" ) << tr( "LF" );

// Initialize elements
modeLabel = new QLabel( tr( "Mode" ) );
modeComboBox = new QComboBox();
modeComboBox->setToolTip( tr( "Select the trigger mode" ) );
for ( Dso::TriggerMode mode : mSpec->triggerModes )
modeComboBox->addItem( Dso::triggerModeString( mode ) );

slopeLabel = new QLabel( tr( "Slope" ) );
slopeComboBox = new QComboBox();
slopeComboBox->setToolTip( tr( "Select positive, negative or both (alternating) slopes" ) );
for ( Dso::Slope slope : Dso::SlopeEnum )
slopeComboBox->addItem( Dso::slopeString( slope ) );

sourceLabel = new QLabel( tr( "Source" ) );
sourceComboBox = new QComboBox();
sourceComboBox->setToolTip( tr( "Select the trigger channel (CH1, CH2, or MATH)" ) );
sourceComboBox->addItems( sourceStandardStrings );
smoothComboBox = new QComboBox();
smoothComboBox->setToolTip( tr( "Trigger on fast, normal, or slow signals" ) );
smoothComboBox->addItems( smoothStandardStrings );

dockLayout = new QGridLayout();
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/docks/TriggerDock.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TriggerDock : public QDockWidget {
void loadSettings( DsoSettingsScope *scope );

protected:
void closeEvent( QCloseEvent *event );
void closeEvent( QCloseEvent *event ) override;

QGridLayout *dockLayout; ///< The main layout for the dock window
QWidget *dockWidget; ///< The main widget for the dock window
Expand Down
74 changes: 45 additions & 29 deletions openhantek/src/docks/VoltageDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
if ( scope->verboseLevel > 1 )
qDebug() << " VoltageDock::VoltageDock()";

const size_t MATH = 2;

// Initialize lists for comboboxes
for ( Dso::Coupling c : spec->couplings )
if ( c == Dso::Coupling::DC || scope->hasACcoupling || scope->hasACmodification )
Expand Down Expand Up @@ -57,38 +59,45 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
b.usedCheckBox = new QCheckBox( tr( "MA&TH" ) );
b.miscComboBox = new QComboBox();
b.gainComboBox = new QComboBox();
b.gainComboBox->setToolTip( tr( "Voltage range per vertical screen division" ) );
b.invertCheckBox = new QCheckBox( tr( "Invert" ) );
b.attnSpinBox = new QSpinBox();
b.attnSpinBox->setToolTip( tr( "Set probe attenuation, scroll or type a value to select" ) );
b.attnSpinBox->setMinimum( ATTENUATION_MIN );
b.attnSpinBox->setMaximum( ATTENUATION_MAX );
b.attnSpinBox->setPrefix( tr( "x" ) );

channelBlocks.push_back( std::move( b ) );

if ( channel < spec->channels )
if ( channel < spec->channels ) {
b.miscComboBox->addItems( couplingStrings );
else
b.miscComboBox->setToolTip( tr( "Select DC or AC coupling" ) );
} else {
b.miscComboBox->addItems( modeStrings );

b.miscComboBox->setToolTip( tr( "Select the mathematical operation for this channel" ) );
}
b.gainComboBox->addItems( gainStrings );

dockLayout->setColumnStretch( 1, 1 ); // stretch ComboBox in 2nd (middle) column 1x
dockLayout->setColumnStretch( 2, 2 ); // stretch ComboBox in 3rd (last) column 2x
dockLayout->addWidget( b.usedCheckBox, row, 0 );
dockLayout->addWidget( b.gainComboBox, row++, 1, 1, 2 ); // fill 1 row, 2 col
dockLayout->addWidget( b.invertCheckBox, row, 0 );
dockLayout->addWidget( b.attnSpinBox, row, 1, 1, 1 ); // fill 1 row, 2 col
dockLayout->addWidget( b.miscComboBox, row++, 2, 1, 1 ); // fill 1 row, 2 col

// draw divider line
if ( channel < spec->channels ) {
dockLayout->setColumnStretch( 1, 1 ); // stretch ComboBox in 2nd (middle) column 1x
dockLayout->setColumnStretch( 2, 2 ); // stretch ComboBox in 3rd (last) column 2x
dockLayout->addWidget( b.usedCheckBox, row, 0 );
dockLayout->addWidget( b.gainComboBox, row++, 1, 1, 2 ); // fill 1 row, 2 col
dockLayout->addWidget( b.invertCheckBox, row, 0 );
dockLayout->addWidget( b.attnSpinBox, row, 1, 1, 1 ); // fill 1 row, 2 col
dockLayout->addWidget( b.miscComboBox, row++, 2, 1, 1 ); // fill 1 row, 2 col
// draw divider line
QFrame *divider = new QFrame();
divider->setLineWidth( 1 );
divider->setFrameShape( QFrame::HLine );
QPalette palette = QPalette();
palette.setColor( QPalette::WindowText, QColor( 128, 128, 128 ) );
divider->setPalette( palette ); // reduce the contrast of the divider
dockLayout->addWidget( divider, row++, 0, 1, 3 );
} else { // MATH function, all in one row
dockLayout->addWidget( b.usedCheckBox, row, 0 );
dockLayout->addWidget( b.gainComboBox, row, 1 );
dockLayout->addWidget( b.miscComboBox, row, 2 );
}

connect( b.gainComboBox, SELECT< int >::OVERLOAD_OF( &QComboBox::currentIndexChanged ),
Expand All @@ -109,18 +118,27 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
connect( b.miscComboBox, SELECT< int >::OVERLOAD_OF( &QComboBox::currentIndexChanged ),
[ this, channel, spec, scope ]( unsigned index ) {
this->scope->voltage[ channel ].couplingOrMathIndex = index;
if ( channel < spec->channels ) {
if ( channel < spec->channels ) { // CH1 & CH2
// setCoupling(channel, (unsigned)index);
emit couplingChanged( channel, scope->coupling( channel, spec ) );
} else { // MATH function changed
setAttn( channel, this->scope->voltage[ channel ].probeAttn ); // update unit
emit modeChanged( Dso::getMathMode( this->scope->voltage[ channel ] ) );
} else { // MATH function changed
Dso::MathMode mathMode = Dso::getMathMode( this->scope->voltage[ channel ] );
setAttn( channel, this->scope->voltage[ channel ].probeAttn );
emit modeChanged( mathMode );
emit usedChannelChanged( channel, Dso::mathChannelsUsed( mathMode ) );
}
} );
connect( b.usedCheckBox, &QCheckBox::toggled, [ this, channel ]( bool checked ) {
this->scope->voltage[ channel ].used = checked;
this->scope->voltage[ channel ].visible = checked;
emit usedChanged( channel, checked );
unsigned mask = 0;
if ( checked ) {
if ( channel < this->spec->channels )
mask = channel + 1;
else
mask = Dso::mathChannelsUsed( Dso::MathMode( this->scope->voltage[ MATH ].couplingOrMathIndex ) );
}
emit usedChannelChanged( channel, mask ); // channel bit mask 0b01, 0b10, 0b11
} );
}

Expand Down Expand Up @@ -192,19 +210,17 @@ void VoltageDock::setAttn( ChannelID channel, double attnValue ) {
QSignalBlocker blocker( channelBlocks[ channel ].gainComboBox );
int index = channelBlocks[ channel ].gainComboBox->currentIndex();
gainStrings.clear();

// change unit to V² for the multiplying math functions
if ( channel >= spec->channels && // MATH channel
( ( scope->voltage[ spec->channels ].couplingOrMathIndex == unsigned( Dso::MathMode::MUL_CH1_CH2 ) ) ||
( scope->voltage[ spec->channels ].couplingOrMathIndex == unsigned( Dso::MathMode::SQ_CH1 ) ) ||
( scope->voltage[ spec->channels ].couplingOrMathIndex == unsigned( Dso::MathMode::SQ_CH2 ) ) ) ) {
for ( double gainStep : scope->gainSteps ) {
gainStrings << valueToString( gainStep * attnValue, UNIT_VOLTSQUARE, -1 ); // auto format V²
}
} else {
for ( double gainStep : scope->gainSteps ) {
gainStrings << valueToString( gainStep * attnValue, UNIT_VOLTS, -1 ); // auto format V
}
}
if ( channel >= spec->channels ) // MATH channel
for ( double gainStep : scope->gainSteps )
gainStrings << valueToString(
gainStep * attnValue, Dso::mathModeUnit( Dso::MathMode( scope->voltage[ spec->channels ].couplingOrMathIndex ) ),
-1 ); // auto format V²
else
for ( double gainStep : scope->gainSteps )
gainStrings << valueToString( gainStep * attnValue, UNIT_VOLTS, -1 ); // auto format V²

channelBlocks[ channel ].gainComboBox->clear();
channelBlocks[ channel ].gainComboBox->addItems( gainStrings );
channelBlocks[ channel ].gainComboBox->setCurrentIndex( index );
Expand Down
4 changes: 2 additions & 2 deletions openhantek/src/docks/VoltageDock.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class VoltageDock : public QDockWidget {
void loadSettings( DsoSettingsScope *scope, const Dso::ControlSpecification *spec );

protected:
void closeEvent( QCloseEvent *event );
void closeEvent( QCloseEvent *event ) override;

QGridLayout *dockLayout; ///< The main layout for the dock window
QWidget *dockWidget; ///< The main widget for the dock window
Expand All @@ -94,7 +94,7 @@ class VoltageDock : public QDockWidget {
void couplingChanged( ChannelID channel, Dso::Coupling coupling ); ///< A coupling has been selected
void gainChanged( ChannelID channel, double gain ); ///< A gain has been selected
void modeChanged( Dso::MathMode mode ); ///< The mode for the math channels has been changed
void usedChanged( ChannelID channel, bool used ); ///< A channel has been enabled/disabled
void usedChannelChanged( ChannelID channel, unsigned used ); ///< A channel has been enabled/disabled
void probeAttnChanged( ChannelID channel, double probeAttn ); ///< A channel probe attenuation has been changed
void invertedChanged( ChannelID channel, bool inverted ); ///< A channel "inverted" has been toggled
};
Loading

0 comments on commit 2fb76ba

Please sign in to comment.