Commit 3c06156de6de6302ddc3390c5225d7deefb53b07
1 parent
d0656b15
Implemented Triggermode Auto properly
Showing
2 changed files
with
23 additions
and
12 deletions
openhantek/ChangeLog
| @@ -102,3 +102,6 @@ | @@ -102,3 +102,6 @@ | ||
| 102 | * Added spectrums to exported csv files | 102 | * Added spectrums to exported csv files |
| 103 | * Using autocorrelation for frequency detection now | 103 | * Using autocorrelation for frequency detection now |
| 104 | * Some undefined value bugfixes | 104 | * Some undefined value bugfixes |
| 105 | + | ||
| 106 | +2010-12-13 Oliver Haag <oliver.haag@gmail.com> | ||
| 107 | +* Triggermode Auto working correctly now |
openhantek/src/hantek/control.cpp
| @@ -115,7 +115,7 @@ namespace Hantek { | @@ -115,7 +115,7 @@ namespace Hantek { | ||
| 115 | 115 | ||
| 116 | /// \brief Handles all USB things until the device gets disconnected. | 116 | /// \brief Handles all USB things until the device gets disconnected. |
| 117 | void Control::run() { | 117 | void Control::run() { |
| 118 | - int errorCode; | 118 | + int errorCode, waitCounter = 0; |
| 119 | 119 | ||
| 120 | // The control loop is running until the device is disconnected | 120 | // The control loop is running until the device is disconnected |
| 121 | int captureState = CAPTURE_WAITING; | 121 | int captureState = CAPTURE_WAITING; |
| @@ -208,8 +208,24 @@ namespace Hantek { | @@ -208,8 +208,24 @@ namespace Hantek { | ||
| 208 | break; | 208 | break; |
| 209 | 209 | ||
| 210 | case CAPTURE_WAITING: | 210 | case CAPTURE_WAITING: |
| 211 | - if(samplingStarted && lastTriggerMode == this->triggerMode) | ||
| 212 | - break; | 211 | + if(samplingStarted && lastTriggerMode == this->triggerMode) { |
| 212 | + waitCounter++; | ||
| 213 | + | ||
| 214 | + if(this->triggerMode == Dso::TRIGGERMODE_AUTO) { | ||
| 215 | + if(waitCounter > (double) this->samplerateDivider / this->samplerateMax * this->bufferSize * 20 + 2) { | ||
| 216 | + // Force triggering | ||
| 217 | + errorCode = this->device->bulkCommand(this->command[COMMAND_FORCETRIGGER]); | ||
| 218 | + if(errorCode == LIBUSB_ERROR_NO_DEVICE) | ||
| 219 | + captureState = LIBUSB_ERROR_NO_DEVICE; | ||
| 220 | + #ifdef DEBUG | ||
| 221 | + qDebug("Forcing trigger"); | ||
| 222 | + #endif | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + if(waitCounter < 80) | ||
| 227 | + break; | ||
| 228 | + } | ||
| 213 | 229 | ||
| 214 | // Start capturing | 230 | // Start capturing |
| 215 | errorCode = this->device->bulkCommand(this->command[COMMAND_STARTSAMPLING]); | 231 | errorCode = this->device->bulkCommand(this->command[COMMAND_STARTSAMPLING]); |
| @@ -233,16 +249,8 @@ namespace Hantek { | @@ -233,16 +249,8 @@ namespace Hantek { | ||
| 233 | qDebug("Enabling trigger"); | 249 | qDebug("Enabling trigger"); |
| 234 | #endif | 250 | #endif |
| 235 | 251 | ||
| 236 | - if(this->triggerMode == Dso::TRIGGERMODE_AUTO) { | ||
| 237 | - // Force triggering | ||
| 238 | - errorCode = this->device->bulkCommand(this->command[COMMAND_FORCETRIGGER]); | ||
| 239 | - if(errorCode == LIBUSB_ERROR_NO_DEVICE) | ||
| 240 | - captureState = LIBUSB_ERROR_NO_DEVICE; | ||
| 241 | -#ifdef DEBUG | ||
| 242 | - qDebug("Forcing trigger"); | ||
| 243 | -#endif | ||
| 244 | - } | ||
| 245 | samplingStarted = true; | 252 | samplingStarted = true; |
| 253 | + waitCounter = 0; | ||
| 246 | lastTriggerMode = this->triggerMode; | 254 | lastTriggerMode = this->triggerMode; |
| 247 | break; | 255 | break; |
| 248 | 256 |