Skip to content

Commit fa73a8d

Browse files
committed
slow mode finetuning
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
1 parent 03816f7 commit fa73a8d

File tree

6 files changed

+26
-37
lines changed

6 files changed

+26
-37
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 "20200614 build 703"
2+
#define OH_BUILD "20200615 build 704"

openhantek/src/hantekdso/capturing.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ unsigned Capturing::getDemoSamples() {
167167
static int counter = 0;
168168
unsigned received = 0;
169169
timestampDebug( QString( "Request dummy packet %1: %2" ).arg( tag ).arg( rawSamplesize ) );
170-
dp->resize( rawSamplesize, 0x80 );
171-
auto end = dp->end();
172170
int deltaT = 99;
173171
// deltaT (=99) defines the frequency of the dummy signals:
174172
// ch1 = 1 kHz and ch2 = 500 Hz
@@ -178,7 +176,11 @@ unsigned Capturing::getDemoSamples() {
178176
// adapt demo samples for high sample rates >10 MS/s
179177
if ( samplerate > 10e6 )
180178
deltaT = int( round( deltaT * samplerate / 10e6 ) );
181-
int block = 0;
179+
const unsigned packetLength = 512 * 78; // 50 blocks for one screen width of 20000
180+
unsigned block = 0;
181+
dp->resize( rawSamplesize, 0x80 );
182+
auto end = dp->end();
183+
unsigned packet = 0;
182184
for ( auto it = dp->begin(); it != end; ++it ) {
183185
if ( ++counter >= deltaT ) {
184186
counter = 0;
@@ -193,15 +195,16 @@ unsigned Capturing::getDemoSamples() {
193195
*++it = ch2;
194196
++received;
195197
}
196-
if ( ++block >= 1024 ) {
198+
if ( ( block += channels ) >= packetLength ) {
199+
++packet;
197200
block = 0;
198-
QThread::usleep( unsigned( 1024 * 1e6 / samplerate ) );
201+
if ( realSlow ) // clear next block as visible hint where we are
202+
std::for_each( it, qMin( it + packetLength, end ), []( uint8_t &d ) { d = 0x80; } );
203+
QThread::usleep( unsigned( 1e6 * packetLength / channels / samplerate ) );
199204
if ( !hdc->capturing || hdc->scopeDevice->hasStopped() )
200205
break;
201206
}
202207
}
203-
// qDebug() << unsigned( rawSamplesize * 1000.0 / samplerate / channels );
204-
// QThread::msleep( unsigned( rawSamplesize * 1000.0 / samplerate / channels ) );
205-
timestampDebug( QString( "Received dummy packet %1: %2" ).arg( tag ).arg( rawSamplesize ) );
208+
timestampDebug( QString( "Received dummy packet %1: %2" ).arg( packet ).arg( rawSamplesize ) );
206209
return received;
207210
}

openhantek/src/hantekdso/models/modelDSO6022.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ static void initSpecifications( Dso::ControlSpecification &specification ) {
107107

108108
specification.fixedSampleRates = {
109109
// samplerate, sampleId, downsampling
110-
{200, 102, 100}, // very slow! 100x downsampling from 20, 50 kS/s
111-
{500, 105, 100}, // very slow!
110+
{200, 102, 100}, // very slow! 100x downsampling from 20 kS/s
111+
{500, 105, 100}, // very slow! 100x downsampling from 50 kS/s
112112
{1e3, 110, 100}, // slow! 100x downsampling from 100, 200, 500 kS/s
113113
{2e3, 120, 100}, // slow!
114114
{5e3, 150, 100}, // slow!

openhantek/src/usb/scopedevice.cpp

+11-15
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,11 @@ int ScopeDevice::bulkTransfer( unsigned char endpoint, const unsigned char *data
220220
int ScopeDevice::bulkReadMulti( unsigned char *data, unsigned length, bool bigBlock, int attempts ) {
221221
if ( !handle )
222222
return LIBUSB_ERROR_NO_DEVICE;
223-
const unsigned packetLength = 512 * 128;
224223
int retCode = 0;
225224
// printf("USBDevice::bulkReadMulti( %d )\n", length );
226225
if ( bigBlock ) {
227226
// more stable if fast data is read as one big block (up to 4 MB)
228227
retCode = bulkTransfer( HANTEK_EP_IN, data, length, attempts, HANTEK_TIMEOUT_MULTI * length / inPacketLength );
229-
QWriteLocker locker( &lock );
230228
if ( retCode < 0 )
231229
received = 0;
232230
else
@@ -235,28 +233,26 @@ int ScopeDevice::bulkReadMulti( unsigned char *data, unsigned length, bool bigBl
235233
return retCode;
236234
} else {
237235
// slow data is read in smaller chunks -> quick screen update
236+
const unsigned packetLength = 512 * 78; // 50 blocks for one screen width of 20000
238237
retCode = int( packetLength );
239238
unsigned int packet;
240-
{
241-
QWriteLocker locker( &lock );
242-
received = 0;
243-
}
239+
received = 0;
244240
for ( packet = 0; unsigned( received ) < length && retCode == int( packetLength ); ++packet ) {
245241
if ( hasStopped() )
246242
break;
247243
retCode = bulkTransfer( HANTEK_EP_IN, data + packet * packetLength, qMin( length - unsigned( received ), packetLength ),
248244
attempts, HANTEK_TIMEOUT_MULTI * 10 );
249-
if ( ( packet + 1 ) * packetLength < length ) { // clear the next+1 packet
250-
unsigned char *dp = data + ( packet + 1 ) * packetLength;
251-
for ( unsigned iii = ( packet + 1 ) * packetLength; iii < qMin( ( packet + 2 ) * packetLength, length ); ++iii )
252-
*dp++ = 0x80;
253-
}
254-
if ( retCode > 0 ) {
255-
QWriteLocker locker( &lock );
245+
unsigned next = ( packet + 1 ) * packetLength;
246+
if ( next > length )
247+
next = 0;
248+
unsigned char *dp = data + next;
249+
unsigned end = qMin( next + packetLength, length );
250+
for ( unsigned iii = next; iii < end; ++iii )
251+
*dp++ = 0x80;
252+
if ( retCode > 0 )
256253
received += unsigned( retCode );
257-
}
258254
}
259-
// printf( "total packets: %d, received: %d\n", packet + 1, received );
255+
// printf( "total packets: %d, received: %d\n", packet, received );
260256
if ( received > 0 )
261257
retCode = int( received );
262258
return retCode;

openhantek/src/usb/scopedevice.h

-9
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ class ScopeDevice : public QObject {
4848
bool isRealHW() const { return realHW; }
4949
bool isDemoDevice() const { return !realHW; }
5050

51-
/// \brief the number of samples in the buffer
52-
unsigned hasReceived() const {
53-
QReadLocker locker( &lock );
54-
printf( "hasReceived: %u\n", received );
55-
return received;
56-
}
57-
5851
/// \brief Stop a long running (interruptable) bulk transfer
5952
void stopSampling() { stopTransfer = true; }
6053

@@ -193,8 +186,6 @@ class ScopeDevice : public QObject {
193186
bool realHW = true;
194187
bool stopTransfer = false;
195188
unsigned received = 0;
196-
mutable QReadWriteLock lock;
197-
198189

199190
signals:
200191
void deviceDisconnected(); ///< The device has been disconnected

openhantek/src/viewconstants.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
#pragma once
44

5-
#define DIVS_TIME 10.0 ///< Number of horizontal screen divs
6-
5+
#define DIVS_TIME 10.0 ///< Number of horizontal screen divs
76
#define DIVS_VOLTAGE 8.0 ///< Number of vertical screen divs
87
#define DIVS_SUB 5 ///< Number of sub-divisions per div
98

0 commit comments

Comments
 (0)