diff --git a/openhantek/ChangeLog b/openhantek/ChangeLog index d088cbf..6c28dd0 100644 --- a/openhantek/ChangeLog +++ b/openhantek/ChangeLog @@ -102,3 +102,6 @@ * Added spectrums to exported csv files * Using autocorrelation for frequency detection now * Some undefined value bugfixes + +2010-12-13 Oliver Haag +* Triggermode Auto working correctly now diff --git a/openhantek/src/hantek/control.cpp b/openhantek/src/hantek/control.cpp index 9e5ce71..5adba57 100644 --- a/openhantek/src/hantek/control.cpp +++ b/openhantek/src/hantek/control.cpp @@ -115,7 +115,7 @@ namespace Hantek { /// \brief Handles all USB things until the device gets disconnected. void Control::run() { - int errorCode; + int errorCode, waitCounter = 0; // The control loop is running until the device is disconnected int captureState = CAPTURE_WAITING; @@ -208,8 +208,24 @@ namespace Hantek { break; case CAPTURE_WAITING: - if(samplingStarted && lastTriggerMode == this->triggerMode) - break; + if(samplingStarted && lastTriggerMode == this->triggerMode) { + waitCounter++; + + if(this->triggerMode == Dso::TRIGGERMODE_AUTO) { + if(waitCounter > (double) this->samplerateDivider / this->samplerateMax * this->bufferSize * 20 + 2) { + // Force triggering + errorCode = this->device->bulkCommand(this->command[COMMAND_FORCETRIGGER]); + if(errorCode == LIBUSB_ERROR_NO_DEVICE) + captureState = LIBUSB_ERROR_NO_DEVICE; + #ifdef DEBUG + qDebug("Forcing trigger"); + #endif + } + } + + if(waitCounter < 80) + break; + } // Start capturing errorCode = this->device->bulkCommand(this->command[COMMAND_STARTSAMPLING]); @@ -233,16 +249,8 @@ namespace Hantek { qDebug("Enabling trigger"); #endif - if(this->triggerMode == Dso::TRIGGERMODE_AUTO) { - // Force triggering - errorCode = this->device->bulkCommand(this->command[COMMAND_FORCETRIGGER]); - if(errorCode == LIBUSB_ERROR_NO_DEVICE) - captureState = LIBUSB_ERROR_NO_DEVICE; -#ifdef DEBUG - qDebug("Forcing trigger"); -#endif - } samplingStarted = true; + waitCounter = 0; lastTriggerMode = this->triggerMode; break;