Skip to content

Commit 4ffe158

Browse files
committed
add refresh button to restart roll mode sampling
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
1 parent e0c6482 commit 4ffe158

18 files changed

+568
-377
lines changed

openhantek/res/application.qrc

+2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
<file>images/measure.svg</file>
99
<file>images/pause.svg</file>
1010
<file>images/play.svg</file>
11+
<file>images/refresh.svg</file>
1112
<file>images/zoom.svg</file>
1213
<file>images/darktheme/phosphor.svg</file>
1314
<file>images/darktheme/histogram.svg</file>
1415
<file>images/darktheme/measure.svg</file>
1516
<file>images/darktheme/pause.svg</file>
1617
<file>images/darktheme/play.svg</file>
18+
<file>images/darktheme/refresh.svg</file>
1719
<file>images/darktheme/zoom.svg</file>
1820
</qresource>
1921
<qresource prefix="/actions"/>
Loading

openhantek/res/images/measure.svg

+1-1
Loading

openhantek/res/images/refresh.svg

+59
Loading

openhantek/res/images/zoom.svg

+1-1
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 "20200626 build 709"
2+
#define OH_BUILD "20200628 build 710"

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 "3.1.1-rc3"
4+
// #define OH_VERSION "3.1.1"
55

66
#ifdef OH_VERSION
77
#undef VERSION

openhantek/src/docks/TriggerDock.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void TriggerDock::setMode( Dso::TriggerMode mode ) {
9898
int index = int( std::find( mSpec->triggerModes.begin(), mSpec->triggerModes.end(), mode ) - mSpec->triggerModes.begin() );
9999
QSignalBlocker blocker( modeComboBox );
100100
modeComboBox->setCurrentIndex( index );
101+
emit modeChanged( this->scope->trigger.mode );
101102
}
102103

103104
void TriggerDock::setSlope( Dso::Slope slope ) {

openhantek/src/hantekdso/hantekdsocontrol.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ void HantekDsoControl::controlSetSamplerate( uint8_t sampleIndex ) {
8383
uint8_t id = specification->fixedSampleRates[ sampleIndex ].id;
8484
modifyCommand< ControlSetSamplerate >( ControlCode::CONTROL_SETSAMPLERATE )->setSamplerate( id, sampleIndex );
8585
if ( sampleIndex != lastIndex ) {
86-
scopeDevice->stopSampling(); // invalidate old samples
87-
raw.rollMode = false;
86+
restartSampling();
8887
}
8988
lastIndex = sampleIndex;
9089
}
@@ -230,15 +229,13 @@ Dso::ErrorCode HantekDsoControl::setGain( ChannelID channel, double gain ) {
230229
if ( channel == 0 ) {
231230
modifyCommand< ControlSetGain_CH1 >( ControlCode::CONTROL_SETGAIN_CH1 )->setGainCH1( gainValue, gainID );
232231
if ( lastGain[ 0 ] != gainValue ) { // HW gain changed, start new samples
233-
scopeDevice->stopSampling();
234-
raw.rollMode = false;
232+
restartSampling();
235233
}
236234
lastGain[ 0 ] = gainValue;
237235
} else if ( channel == 1 ) {
238236
modifyCommand< ControlSetGain_CH2 >( ControlCode::CONTROL_SETGAIN_CH2 )->setGainCH2( gainValue, gainID );
239237
if ( lastGain[ 1 ] != gainValue ) { // HW gain changed, start new samples
240-
scopeDevice->stopSampling();
241-
raw.rollMode = false;
238+
restartSampling();
242239
}
243240
lastGain[ 1 ] = gainValue;
244241
} else
@@ -271,8 +268,7 @@ Dso::ErrorCode HantekDsoControl::setCoupling( ChannelID channel, Dso::Coupling c
271268
->setCoupling( channel, coupling == Dso::Coupling::DC );
272269
controlsettings.voltage[ channel ].coupling = coupling;
273270
if ( lastCoupling[ channel ] != int( coupling ) ) { // HW coupling changed, start new samples
274-
scopeDevice->stopSampling();
275-
raw.rollMode = false;
271+
restartSampling();
276272
}
277273
lastCoupling[ channel ] = int( coupling );
278274
return Dso::ErrorCode::NONE;
@@ -290,8 +286,7 @@ Dso::ErrorCode HantekDsoControl::setTriggerMode( Dso::TriggerMode mode ) {
290286
// trigger mode changed NONE <-> !NONE
291287
if ( ( Dso::TriggerMode::ROLL == mode && Dso::TriggerMode::ROLL != lastMode ) ||
292288
( Dso::TriggerMode::ROLL != mode && Dso::TriggerMode::ROLL == lastMode ) ) {
293-
scopeDevice->stopSampling(); // invalidate old samples;
294-
raw.rollMode = false; // draw next screen from left to right
289+
restartSampling(); // invalidate old samples
295290
raw.freeRun = Dso::TriggerMode::ROLL == mode;
296291
}
297292
lastMode = mode;
@@ -367,6 +362,13 @@ void HantekDsoControl::applySettings( DsoSettingsScope *dsoSettingsScope ) {
367362
}
368363

369364

365+
/// \brief Starts a new sampling block.
366+
void HantekDsoControl::restartSampling() {
367+
scopeDevice->stopSampling();
368+
raw.rollMode = false;
369+
}
370+
371+
370372
/// \brief Start sampling process.
371373
void HantekDsoControl::enableSampling( bool enabled ) {
372374
sampling = enabled;

openhantek/src/hantekdso/hantekdsocontrol.h

+3
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ class HantekDsoControl : public QObject {
301301
/// \param scope The settings for the oscilloscope.
302302
void applySettings( DsoSettingsScope *scope );
303303

304+
/// \brief Starts a new sampling block.
305+
void restartSampling();
306+
304307
signals:
305308
void samplingStatusChanged( bool enabled ); ///< The oscilloscope started/stopped sampling/waiting for trigger
306309
void statusMessage( const QString &message, int timeout ); ///< Status message about the oscilloscope

openhantek/src/mainwindow.cpp

+18-10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
5959
shortcuts << QKeySequence( Qt::Key::Key_S ); // else put this shortcut at the end of the list
6060
#endif
6161
ui->actionSampling->setShortcuts( shortcuts );
62+
ui->actionRefresh->setIcon( QIcon( iconPath + "refresh.svg" ) );
63+
ui->actionRefresh->setShortcut( Qt::Key::Key_R );
6264
ui->actionPhosphor->setIcon( QIcon( iconPath + "phosphor.svg" ) );
6365
ui->actionPhosphor->setShortcut( Qt::Key::Key_P );
6466
ui->actionHistogram->setIcon( QIcon( iconPath + "histogram.svg" ) );
@@ -86,16 +88,6 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
8688
setDockOptions( dockOptions() | QMainWindow::GroupedDragging );
8789
#endif
8890
QAction *action;
89-
for ( auto *exporter : *exporterRegistry ) {
90-
action = new QAction( iconFont->icon( exporter->faIcon(), colorMap ), exporter->name(), this );
91-
action->setCheckable( exporter->type() == ExporterInterface::Type::ContinousExport );
92-
connect( action, &QAction::triggered, [exporter, exporterRegistry]( bool checked ) {
93-
exporterRegistry->setExporterEnabled( exporter,
94-
exporter->type() == ExporterInterface::Type::ContinousExport ? checked : true );
95-
} );
96-
ui->menuExport->addAction( action );
97-
}
98-
9991
action = new QAction( iconFont->icon( fa::camera, colorMap ), tr( "Screenshot .." ), this );
10092
action->setToolTip( "Make a screenshot of the program window" );
10193
connect( action, &QAction::triggered, [this]() { screenShot( SCREENSHOT ); } );
@@ -117,6 +109,18 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
117109
} );
118110
ui->menuExport->addAction( action );
119111

112+
ui->menuExport->addSeparator();
113+
114+
for ( auto *exporter : *exporterRegistry ) {
115+
action = new QAction( iconFont->icon( exporter->faIcon(), colorMap ), exporter->name(), this );
116+
action->setCheckable( exporter->type() == ExporterInterface::Type::ContinousExport );
117+
connect( action, &QAction::triggered, [exporter, exporterRegistry]( bool checked ) {
118+
exporterRegistry->setExporterEnabled( exporter,
119+
exporter->type() == ExporterInterface::Type::ContinousExport ? checked : true );
120+
} );
121+
ui->menuExport->addAction( action );
122+
}
123+
120124
DsoSettingsScope *scope = &( dsoSettings->scope );
121125
const Dso::ControlSpecification *spec = dsoControl->getModel()->spec();
122126

@@ -189,6 +193,8 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
189193

190194
connect( triggerDock, &TriggerDock::modeChanged, dsoControl, &HantekDsoControl::setTriggerMode );
191195
connect( triggerDock, &TriggerDock::modeChanged, dsoWidget, &DsoWidget::updateTriggerMode );
196+
connect( triggerDock, &TriggerDock::modeChanged,
197+
[this]( Dso::TriggerMode mode ) { ui->actionRefresh->setEnabled( Dso::TriggerMode::ROLL == mode ); } );
192198
connect( triggerDock, &TriggerDock::sourceChanged, dsoControl, &HantekDsoControl::setTriggerSource );
193199
connect( triggerDock, &TriggerDock::sourceChanged, dsoWidget, &DsoWidget::updateTriggerSource );
194200
connect( triggerDock, &TriggerDock::slopeChanged, dsoControl, &HantekDsoControl::setTriggerSlope );
@@ -258,6 +264,8 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
258264
connect( this->ui->actionSampling, &QAction::triggered, dsoControl, &HantekDsoControl::enableSampling );
259265
this->ui->actionSampling->setChecked( dsoControl->isSampling() );
260266

267+
connect( this->ui->actionRefresh, &QAction::triggered, dsoControl, &HantekDsoControl::restartSampling );
268+
261269
connect( dsoControl, &HantekDsoControl::samplerateLimitsChanged, horizontalDock, &HorizontalDock::setSamplerateLimits );
262270
connect( dsoControl, &HantekDsoControl::samplerateSet, horizontalDock, &HorizontalDock::setSamplerateSteps );
263271

openhantek/src/mainwindow.ui

+15-4
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@
3737
<property name="title">
3838
<string>&amp;View</string>
3939
</property>
40+
<addaction name="actionSampling"/>
41+
<addaction name="separator"/>
42+
<addaction name="actionRefresh"/>
43+
<addaction name="separator"/>
4044
<addaction name="actionPhosphor"/>
4145
<addaction name="actionHistogram"/>
4246
<addaction name="actionZoom"/>
4347
<addaction name="actionMeasure"/>
44-
<addaction name="separator"/>
4548
</widget>
4649
<widget class="QMenu" name="menuOscilloscope">
4750
<property name="title">
4851
<string>&amp;Oscilloscope</string>
4952
</property>
5053
<addaction name="actionSettings"/>
51-
<addaction name="actionSampling"/>
5254
<addaction name="separator"/>
5355
<addaction name="actionManualCommand"/>
5456
</widget>
@@ -83,11 +85,12 @@
8385
</attribute>
8486
<addaction name="actionSampling"/>
8587
<addaction name="separator"/>
88+
<addaction name="actionRefresh"/>
89+
<addaction name="separator"/>
8690
<addaction name="actionPhosphor"/>
8791
<addaction name="actionHistogram"/>
8892
<addaction name="actionZoom"/>
8993
<addaction name="actionMeasure"/>
90-
<addaction name="separator"/>
9194
</widget>
9295
<action name="actionOpen">
9396
<property name="text">
@@ -129,6 +132,14 @@
129132
<string>Space</string>
130133
</property>
131134
</action>
135+
<action name="actionRefresh">
136+
<property name="checkable">
137+
<bool>false</bool>
138+
</property>
139+
<property name="text">
140+
<string>&amp;Refresh</string>
141+
</property>
142+
</action>
132143
<action name="actionPhosphor">
133144
<property name="checkable">
134145
<bool>true</bool>
@@ -191,7 +202,7 @@
191202
<bool>true</bool>
192203
</property>
193204
<property name="text">
194-
<string>Manual &amp;command</string>
205+
<string>&amp;Manual command</string>
195206
</property>
196207
</action>
197208
</widget>

0 commit comments

Comments
 (0)