Skip to content

Commit e0c6482

Browse files
committed
real roll mode for slow sample rates
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
1 parent df55001 commit e0c6482

23 files changed

+179
-545
lines changed

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

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

66
#ifdef OH_VERSION
77
#undef VERSION

openhantek/src/dsowidget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ void DsoWidget::updateTriggerDetails() {
616616
int dutyCyle = int( 0.5 + ( 100.0 * pulseWidth1 ) / ( pulseWidth1 + pulseWidth2 ) );
617617
pulseWidthString += " (" + QString::number( dutyCyle ) + "%)";
618618
}
619-
if ( scope->trigger.mode != Dso::TriggerMode::NONE ) {
619+
if ( scope->trigger.mode != Dso::TriggerMode::ROLL ) {
620620
settingsTriggerLabel->setText( tr( "%1 %2 %3 %4 %5" )
621621
.arg( scope->voltage[ scope->trigger.source ].name,
622622
Dso::slopeString( scope->trigger.slope ), levelString, pretriggerString,
@@ -797,7 +797,7 @@ void DsoWidget::showNew( std::shared_ptr< PPresult > analysedData ) {
797797
zoomScope->showData( analysedData );
798798

799799
QPalette triggerLabelPalette = palette();
800-
if ( scope->trigger.mode == Dso::TriggerMode::NONE ) {
800+
if ( scope->trigger.mode == Dso::TriggerMode::ROLL ) {
801801
triggerLabelPalette.setColor( QPalette::WindowText, view->colors->background );
802802
triggerLabelPalette.setColor( QPalette::Background, view->colors->background );
803803
} else {

openhantek/src/hantekdso/capturing.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <cmath>
99

1010

11-
// static std::vector< QString > controlNames = {"SETGAIN_CH1", "SETGAIN_CH2", "SETSAMPLERATE", "STARTSAMPLING",
12-
// "SETNUMCHANNELS", "SETCOUPLING", "SETCALFREQ"};
13-
1411
Capturing::Capturing( HantekDsoControl *hdc ) : hdc( hdc ) { hdc->capturing = true; }
1512

1613

@@ -39,7 +36,7 @@ double id2sr( uint8_t timediv ) {
3936

4037
void Capturing::xferSamples() {
4138
QWriteLocker locker( &hdc->raw.lock );
42-
if ( !rollMode )
39+
if ( !freeRun )
4340
swap( data, hdc->raw.data );
4441
hdc->raw.channels = channels;
4542
hdc->raw.samplerate = samplerate;
@@ -48,7 +45,7 @@ void Capturing::xferSamples() {
4845
hdc->raw.gainValue[ 1 ] = gainValue[ 1 ];
4946
hdc->raw.gainIndex[ 0 ] = gainIndex[ 0 ];
5047
hdc->raw.gainIndex[ 1 ] = gainIndex[ 1 ];
51-
hdc->raw.rollMode = rollMode;
48+
hdc->raw.freeRun = freeRun;
5249
hdc->raw.valid = valid;
5350
hdc->raw.tag = tag;
5451
}
@@ -72,8 +69,12 @@ void Capturing::capture() {
7269
gainIndex[ 1 ] = controlCommand->data()[ 1 ];
7370
break;
7471
case uint8_t( ControlCode::CONTROL_SETNUMCHANNELS ):
75-
if ( realSlow ) // force 2 channels for slow samplings where roll mode is possible
76-
*controlCommand->data() = 2;
72+
if ( realSlow ) { // force 2 channels for slow samplings where roll mode is possible
73+
if ( *controlCommand->data() == channels )
74+
controlCommand->pending = false;
75+
else
76+
*controlCommand->data() = 2;
77+
}
7778
channels = *controlCommand->data();
7879
break;
7980
case uint8_t( ControlCode::CONTROL_SETSAMPLERATE ):
@@ -82,7 +83,7 @@ void Capturing::capture() {
8283
oversampling = uint8_t( hdc->specification->fixedSampleRates[ sampleIndex ].oversampling );
8384
effectiveSamplerate = hdc->specification->fixedSampleRates[ sampleIndex ].samplerate;
8485
realSlow = effectiveSamplerate < 10e3;
85-
if ( realSlow ) // always switch to two channels if roll mode is possible
86+
if ( realSlow && channels != 2 ) // always switch to two channels if roll mode is possible
8687
hdc->modifyCommand< ControlSetNumChannels >( ControlCode::CONTROL_SETNUMCHANNELS )->setNumChannels( 2 );
8788
break;
8889
}
@@ -111,12 +112,12 @@ void Capturing::capture() {
111112
controlCommand = controlCommand->next;
112113
}
113114
valid = true;
114-
rollMode = hdc->triggerModeNONE() && realSlow;
115+
freeRun = hdc->triggerModeNONE() && realSlow;
115116
// sample step by step into the target if rollMode, else buffer and switch one big block
116-
dp = rollMode ? &hdc->raw.data : &data;
117+
dp = freeRun ? &hdc->raw.data : &data;
117118
rawSamplesize = hdc->grossSampleCount( hdc->getSamplesize() * oversampling ) * channels;
118119
dp->resize( rawSamplesize, 0x80 );
119-
if ( tag && rollMode ) // in roll mode transfer settings immediately
120+
if ( tag && freeRun ) // in free run mode transfer settings immediately
120121
xferSamples();
121122
++tag;
122123
if ( hdc->scopeDevice->isRealHW() ) {
@@ -130,8 +131,10 @@ void Capturing::capture() {
130131
for ( auto it = dp->begin(); it != end; ++it )
131132
*it = 0x80; // fill with "zeros"
132133
valid = false;
134+
} else {
135+
hdc->raw.rollMode = true; // one complete buffer available, start to roll
133136
}
134-
if ( !rollMode ) // in normal capturing mode transfer after capturing one block
137+
if ( !freeRun ) // in normal capturing mode transfer after capturing one block
135138
xferSamples();
136139
}
137140

openhantek/src/hantekdso/capturing.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Capturing : public QThread {
2929
unsigned gainIndex[ 2 ] = {0, 0}; // index 0..7
3030
unsigned tag = 0;
3131
bool valid = true;
32-
bool rollMode = false;
32+
bool freeRun = false;
3333
std::vector< unsigned char > data;
3434
std::vector< unsigned char > *dp = &data;
3535
};

openhantek/src/hantekdso/controlspecification.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct ControlSpecification {
6464

6565
// Features
6666
std::vector< Coupling > couplings = {Dso::Coupling::DC, Dso::Coupling::AC};
67-
std::vector< TriggerMode > triggerModes = {TriggerMode::NONE, TriggerMode::AUTO, TriggerMode::NORMAL, TriggerMode::SINGLE};
67+
std::vector< TriggerMode > triggerModes = {TriggerMode::ROLL, TriggerMode::AUTO, TriggerMode::NORMAL, TriggerMode::SINGLE};
6868
int fixedUSBinLength = 0;
6969
bool hasACcoupling = false;
7070

openhantek/src/hantekdso/dsosamples.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ struct DSOsamples {
1212
double samplerate = 0.0; ///< The samplerate of the input data
1313
unsigned char clipped = 0; ///< Bitmask of clipped channels
1414
bool liveTrigger = false; ///< live samples are triggered
15-
unsigned triggeredPosition = 0; ///< position for a triggered trace, 0 = not triggered
15+
unsigned triggeredPosition = 0; ///< position for a triggered trace, 0 = not triggered
1616
double pulseWidth1 = 0.0; ///< width from trigger point to next opposite slope
1717
double pulseWidth2 = 0.0; ///< width from next opposite slope to third slope
1818
bool freeRunning = false; ///< trigger: NONE, half sample count
19-
unsigned freeRunPosition = 0; ///< position of free running capturing
2019
unsigned tag = 0; ///< track individual sample blocks (debug support)
2120
mutable QReadWriteLock lock;
2221
};

openhantek/src/hantekdso/enums.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <QCoreApplication>
55

66
namespace Dso {
7-
Enum< Dso::TriggerMode, Dso::TriggerMode::NONE, Dso::TriggerMode::SINGLE > TriggerModeEnum;
7+
Enum< Dso::TriggerMode, Dso::TriggerMode::ROLL, Dso::TriggerMode::SINGLE > TriggerModeEnum;
88
Enum< Dso::Slope, Dso::Slope::Positive, Dso::Slope::Both > SlopeEnum;
99
Enum< Dso::GraphFormat, Dso::GraphFormat::TY, Dso::GraphFormat::XY > GraphFormatEnum;
1010

@@ -42,12 +42,12 @@ QString couplingString( Coupling coupling ) {
4242
/// \return The string that should be used in labels etc.
4343
QString triggerModeString( TriggerMode mode ) {
4444
switch ( mode ) {
45+
case TriggerMode::ROLL:
46+
return QCoreApplication::tr( "Roll" );
4547
case TriggerMode::AUTO:
4648
return QCoreApplication::tr( "Auto" );
4749
case TriggerMode::NORMAL:
4850
return QCoreApplication::tr( "Normal" );
49-
case TriggerMode::NONE:
50-
return QCoreApplication::tr( "None" );
5151
case TriggerMode::SINGLE:
5252
return QCoreApplication::tr( "Single" );
5353
}

openhantek/src/hantekdso/enums.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ enum class Coupling {
3333
/// \enum TriggerMode
3434
/// \brief The different triggering modes.
3535
enum class TriggerMode {
36-
NONE, ///< Free running without any trigger
36+
ROLL, ///< Free running without any trigger
3737
AUTO, ///< Automatic without trigger event
3838
NORMAL, ///< Normal hardware trigger (or software trigger) mode
3939
SINGLE ///< Stop after the first trigger event
4040
}; // <class T, T first, T last>
41-
extern Enum< Dso::TriggerMode, Dso::TriggerMode::NONE, Dso::TriggerMode::SINGLE > TriggerModeEnum;
41+
extern Enum< Dso::TriggerMode, Dso::TriggerMode::ROLL, Dso::TriggerMode::SINGLE > TriggerModeEnum;
4242

4343
/// \enum Slope
4444
/// \brief The slope that causes a trigger.

0 commit comments

Comments
 (0)