8
8
#include < cmath>
9
9
10
10
11
- // static std::vector< QString > controlNames = {"SETGAIN_CH1", "SETGAIN_CH2", "SETSAMPLERATE", "STARTSAMPLING",
12
- // "SETNUMCHANNELS", "SETCOUPLING", "SETCALFREQ"};
13
-
14
11
Capturing::Capturing ( HantekDsoControl *hdc ) : hdc( hdc ) { hdc->capturing = true ; }
15
12
16
13
@@ -39,7 +36,7 @@ double id2sr( uint8_t timediv ) {
39
36
40
37
void Capturing::xferSamples () {
41
38
QWriteLocker locker ( &hdc->raw .lock );
42
- if ( !rollMode )
39
+ if ( !freeRun )
43
40
swap ( data, hdc->raw .data );
44
41
hdc->raw .channels = channels;
45
42
hdc->raw .samplerate = samplerate;
@@ -48,7 +45,7 @@ void Capturing::xferSamples() {
48
45
hdc->raw .gainValue [ 1 ] = gainValue[ 1 ];
49
46
hdc->raw .gainIndex [ 0 ] = gainIndex[ 0 ];
50
47
hdc->raw .gainIndex [ 1 ] = gainIndex[ 1 ];
51
- hdc->raw .rollMode = rollMode ;
48
+ hdc->raw .freeRun = freeRun ;
52
49
hdc->raw .valid = valid;
53
50
hdc->raw .tag = tag;
54
51
}
@@ -72,8 +69,12 @@ void Capturing::capture() {
72
69
gainIndex[ 1 ] = controlCommand->data ()[ 1 ];
73
70
break ;
74
71
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
+ }
77
78
channels = *controlCommand->data ();
78
79
break ;
79
80
case uint8_t ( ControlCode::CONTROL_SETSAMPLERATE ):
@@ -82,7 +83,7 @@ void Capturing::capture() {
82
83
oversampling = uint8_t ( hdc->specification ->fixedSampleRates [ sampleIndex ].oversampling );
83
84
effectiveSamplerate = hdc->specification ->fixedSampleRates [ sampleIndex ].samplerate ;
84
85
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
86
87
hdc->modifyCommand < ControlSetNumChannels >( ControlCode::CONTROL_SETNUMCHANNELS )->setNumChannels ( 2 );
87
88
break ;
88
89
}
@@ -111,12 +112,12 @@ void Capturing::capture() {
111
112
controlCommand = controlCommand->next ;
112
113
}
113
114
valid = true ;
114
- rollMode = hdc->triggerModeNONE () && realSlow;
115
+ freeRun = hdc->triggerModeNONE () && realSlow;
115
116
// 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;
117
118
rawSamplesize = hdc->grossSampleCount ( hdc->getSamplesize () * oversampling ) * channels;
118
119
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
120
121
xferSamples ();
121
122
++tag;
122
123
if ( hdc->scopeDevice ->isRealHW () ) {
@@ -130,8 +131,10 @@ void Capturing::capture() {
130
131
for ( auto it = dp->begin (); it != end; ++it )
131
132
*it = 0x80 ; // fill with "zeros"
132
133
valid = false ;
134
+ } else {
135
+ hdc->raw .rollMode = true ; // one complete buffer available, start to roll
133
136
}
134
- if ( !rollMode ) // in normal capturing mode transfer after capturing one block
137
+ if ( !freeRun ) // in normal capturing mode transfer after capturing one block
135
138
xferSamples ();
136
139
}
137
140
0 commit comments