Commit 90dc57b62056214ad695b15af60523dfa2eaad0c

Authored by David Graeff
Committed by David Gräff
1 parent 0fb7e43d

Use enum for scope.horizontal.samplerateSource. Remove softwaretriggersettings, …

…use dsotriggersettings. Move more comments from cpp to header
openhantek/src/docks/HorizontalDock.cpp
@@ -181,7 +181,7 @@ void HorizontalDock::frequencybaseSelected(double frequencybase) { @@ -181,7 +181,7 @@ void HorizontalDock::frequencybaseSelected(double frequencybase) {
181 /// \param samplerate The samplerate in samples/second. 181 /// \param samplerate The samplerate in samples/second.
182 void HorizontalDock::samplerateSelected(double samplerate) { 182 void HorizontalDock::samplerateSelected(double samplerate) {
183 scope->horizontal.samplerate = samplerate; 183 scope->horizontal.samplerate = samplerate;
184 - scope->horizontal.samplerateSet = true; 184 + scope->horizontal.samplerateSource = DsoSettingsScopeHorizontal::Samplerrate;
185 emit samplerateChanged(samplerate); 185 emit samplerateChanged(samplerate);
186 } 186 }
187 187
@@ -189,7 +189,7 @@ void HorizontalDock::samplerateSelected(double samplerate) { @@ -189,7 +189,7 @@ void HorizontalDock::samplerateSelected(double samplerate) {
189 /// \param timebase The timebase in seconds. 189 /// \param timebase The timebase in seconds.
190 void HorizontalDock::timebaseSelected(double timebase) { 190 void HorizontalDock::timebaseSelected(double timebase) {
191 scope->horizontal.timebase = timebase; 191 scope->horizontal.timebase = timebase;
192 - scope->horizontal.samplerateSet = false; 192 + scope->horizontal.samplerateSource = DsoSettingsScopeHorizontal::Duration;
193 emit timebaseChanged(timebase); 193 emit timebaseChanged(timebase);
194 } 194 }
195 195
openhantek/src/dsowidget.cpp
@@ -78,7 +78,6 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso:: @@ -78,7 +78,6 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::
78 markerSlider->setStep(marker, 0.2); 78 markerSlider->setStep(marker, 0.2);
79 markerSlider->setValue(marker, scope->horizontal.marker[marker]); 79 markerSlider->setValue(marker, scope->horizontal.marker[marker]);
80 markerSlider->setIndexVisible(marker, true); 80 markerSlider->setIndexVisible(marker, true);
81 - scope->horizontal.marker_visible[marker] = true;  
82 } 81 }
83 82
84 // The table for the settings 83 // The table for the settings
openhantek/src/hantekdso/controlsettings.h
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include "controlspecification.h" 3 #include "controlspecification.h"
4 #include "enums.h" 4 #include "enums.h"
5 -#include "softwaretriggersettings.h"  
6 5
7 namespace Dso { 6 namespace Dso {
8 7
@@ -31,13 +30,13 @@ struct ControlSettingsSamplerate { @@ -31,13 +30,13 @@ struct ControlSettingsSamplerate {
31 /// \struct ControlSettingsTrigger hantek/control.h 30 /// \struct ControlSettingsTrigger hantek/control.h
32 /// \brief Stores the current trigger settings of the device. 31 /// \brief Stores the current trigger settings of the device.
33 struct ControlSettingsTrigger { 32 struct ControlSettingsTrigger {
34 - std::vector<double> level; ///< The trigger level for each channel in V  
35 - double position = 0.0; ///< The current pretrigger position  
36 - unsigned int point = 0; ///< The trigger position in Hantek coding 33 + std::vector<double> level; ///< The trigger level for each channel in V
  34 + double position = 0.0; ///< The current pretrigger position
  35 + unsigned int point = 0; ///< The trigger position in Hantek coding
37 Dso::TriggerMode mode = Dso::TriggerMode::NORMAL; ///< The trigger mode 36 Dso::TriggerMode mode = Dso::TriggerMode::NORMAL; ///< The trigger mode
38 Dso::Slope slope = Dso::Slope::Positive; ///< The trigger slope 37 Dso::Slope slope = Dso::Slope::Positive; ///< The trigger slope
39 - bool special = false; ///< true, if the trigger source is special  
40 - unsigned int source = 0; ///< The trigger source 38 + bool special = false; ///< true, if the trigger source is special
  39 + unsigned int source = 0; ///< The trigger source
41 }; 40 };
42 41
43 ////////////////////////////////////////////////////////////////////////////// 42 //////////////////////////////////////////////////////////////////////////////
@@ -60,6 +59,6 @@ struct ControlSettings { @@ -60,6 +59,6 @@ struct ControlSettings {
60 ControlSettingsTrigger trigger; ///< The trigger settings 59 ControlSettingsTrigger trigger; ///< The trigger settings
61 RecordLengthID recordLengthId = 1; ///< The id in the record length array 60 RecordLengthID recordLengthId = 1; ///< The id in the record length array
62 unsigned usedChannels = 0; ///< Number of activated channels 61 unsigned usedChannels = 0; ///< Number of activated channels
63 - SoftwareTriggerSettings swTrigger; 62 + unsigned swSampleMargin = 2000; ///< Software trigger, sample margin
64 }; 63 };
65 } 64 }
openhantek/src/hantekdso/hantekdsocontrol.cpp
@@ -603,9 +603,6 @@ void HantekDsoControl::updateSamplerateLimits() { @@ -603,9 +603,6 @@ void HantekDsoControl::updateSamplerateLimits() {
603 limits->max / specification.bufferDividers[controlsettings.recordLengthId]); 603 limits->max / specification.bufferDividers[controlsettings.recordLengthId]);
604 } 604 }
605 605
606 -/// \brief Sets the size of the oscilloscopes sample buffer.  
607 -/// \param index The record length index that should be set.  
608 -/// \return The record length that has been set, 0 on error.  
609 Dso::ErrorCode HantekDsoControl::setRecordLength(unsigned index) { 606 Dso::ErrorCode HantekDsoControl::setRecordLength(unsigned index) {
610 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 607 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
611 608
@@ -618,10 +615,6 @@ Dso::ErrorCode HantekDsoControl::setRecordLength(unsigned index) { @@ -618,10 +615,6 @@ Dso::ErrorCode HantekDsoControl::setRecordLength(unsigned index) {
618 return Dso::ErrorCode::NONE; 615 return Dso::ErrorCode::NONE;
619 } 616 }
620 617
621 -/// \brief Sets the samplerate of the oscilloscope.  
622 -/// \param samplerate The samplerate that should be met (S/s), 0.0 to restore  
623 -/// current samplerate.  
624 -/// \return The samplerate that has been set, 0.0 on error.  
625 Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) { 618 Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) {
626 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 619 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
627 620
@@ -659,7 +652,7 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) { @@ -659,7 +652,7 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) {
659 652
660 // Check for Roll mode 653 // Check for Roll mode
661 if (!isRollMode()) 654 if (!isRollMode())
662 - emit recordTimeChanged((double)(getRecordLength() - controlsettings.swTrigger.sampleMargin) / 655 + emit recordTimeChanged((double)(getRecordLength() - controlsettings.swSampleMargin) /
663 controlsettings.samplerate.current); 656 controlsettings.samplerate.current);
664 emit samplerateChanged(controlsettings.samplerate.current); 657 emit samplerateChanged(controlsettings.samplerate.current);
665 658
@@ -667,10 +660,6 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) { @@ -667,10 +660,6 @@ Dso::ErrorCode HantekDsoControl::setSamplerate(double samplerate) {
667 } 660 }
668 } 661 }
669 662
670 -/// \brief Sets the time duration of one aquisition by adapting the samplerate.  
671 -/// \param duration The record time duration that should be met (s), 0.0 to  
672 -/// restore current record time.  
673 -/// \return The record time duration that has been set, 0.0 on error.  
674 Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { 663 Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) {
675 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 664 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
676 665
@@ -706,10 +695,10 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { @@ -706,10 +695,10 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) {
706 // For now - we go for the 10240 size sampling - the other seems not to be supported 695 // For now - we go for the 10240 size sampling - the other seems not to be supported
707 // Find highest samplerate using less than 10240 samples to obtain our duration. 696 // Find highest samplerate using less than 10240 samples to obtain our duration.
708 unsigned sampleCount = 10240; 697 unsigned sampleCount = 10240;
  698 + if (specification.isSoftwareTriggerDevice) sampleCount -= controlsettings.swSampleMargin;
709 unsigned sampleId; 699 unsigned sampleId;
710 for (sampleId = 0; sampleId < specification.fixedSampleRates.size(); ++sampleId) { 700 for (sampleId = 0; sampleId < specification.fixedSampleRates.size(); ++sampleId) {
711 - if (specification.fixedSampleRates[sampleId].samplerate * duration <  
712 - (sampleCount - controlsettings.swTrigger.sampleMargin)) 701 + if (specification.fixedSampleRates[sampleId].samplerate * duration < sampleCount)
713 break; 702 break;
714 } 703 }
715 // Usable sample value 704 // Usable sample value
@@ -722,10 +711,6 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) { @@ -722,10 +711,6 @@ Dso::ErrorCode HantekDsoControl::setRecordTime(double duration) {
722 } 711 }
723 } 712 }
724 713
725 -/// \brief Enables/disables filtering of the given channel.  
726 -/// \param channel The channel that should be set.  
727 -/// \param used true if the channel should be sampled.  
728 -/// \return See ::Dso::ErrorCode.  
729 Dso::ErrorCode HantekDsoControl::setChannelUsed(ChannelID channel, bool used) { 714 Dso::ErrorCode HantekDsoControl::setChannelUsed(ChannelID channel, bool used) {
730 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 715 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
731 716
@@ -783,10 +768,6 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(ChannelID channel, bool used) { @@ -783,10 +768,6 @@ Dso::ErrorCode HantekDsoControl::setChannelUsed(ChannelID channel, bool used) {
783 return Dso::ErrorCode::NONE; 768 return Dso::ErrorCode::NONE;
784 } 769 }
785 770
786 -/// \brief Set the coupling for the given channel.  
787 -/// \param channel The channel that should be set.  
788 -/// \param coupling The new coupling for the channel.  
789 -/// \return See ::Dso::ErrorCode.  
790 Dso::ErrorCode HantekDsoControl::setCoupling(ChannelID channel, Dso::Coupling coupling) { 771 Dso::ErrorCode HantekDsoControl::setCoupling(ChannelID channel, Dso::Coupling coupling) {
791 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 772 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
792 773
@@ -801,11 +782,6 @@ Dso::ErrorCode HantekDsoControl::setCoupling(ChannelID channel, Dso::Coupling co @@ -801,11 +782,6 @@ Dso::ErrorCode HantekDsoControl::setCoupling(ChannelID channel, Dso::Coupling co
801 return Dso::ErrorCode::NONE; 782 return Dso::ErrorCode::NONE;
802 } 783 }
803 784
804 -/// \brief Sets the gain for the given channel.  
805 -/// Get the actual gain by specification.gainSteps[gainId]  
806 -/// \param channel The channel that should be set.  
807 -/// \param gain The gain that should be met (V/div).  
808 -/// \return The gain that has been set, ::Dso::ErrorCode on error.  
809 Dso::ErrorCode HantekDsoControl::setGain(ChannelID channel, double gain) { 785 Dso::ErrorCode HantekDsoControl::setGain(ChannelID channel, double gain) {
810 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 786 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
811 787
@@ -842,10 +818,6 @@ Dso::ErrorCode HantekDsoControl::setGain(ChannelID channel, double gain) { @@ -842,10 +818,6 @@ Dso::ErrorCode HantekDsoControl::setGain(ChannelID channel, double gain) {
842 return Dso::ErrorCode::NONE; 818 return Dso::ErrorCode::NONE;
843 } 819 }
844 820
845 -/// \brief Set the offset for the given channel.  
846 -/// Get the actual offset for the channel from controlsettings.voltage[channel].offsetReal  
847 -/// \param channel The channel that should be set.  
848 -/// \param offset The new offset value (0.0 - 1.0).  
849 Dso::ErrorCode HantekDsoControl::setOffset(ChannelID channel, const double offset) { 821 Dso::ErrorCode HantekDsoControl::setOffset(ChannelID channel, const double offset) {
850 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 822 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
851 823
@@ -873,8 +845,6 @@ Dso::ErrorCode HantekDsoControl::setOffset(ChannelID channel, const double offse @@ -873,8 +845,6 @@ Dso::ErrorCode HantekDsoControl::setOffset(ChannelID channel, const double offse
873 return Dso::ErrorCode::NONE; 845 return Dso::ErrorCode::NONE;
874 } 846 }
875 847
876 -/// \brief Set the trigger mode.  
877 -/// \return See ::Dso::ErrorCode.  
878 Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) { 848 Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) {
879 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 849 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
880 850
@@ -882,10 +852,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) { @@ -882,10 +852,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerMode(Dso::TriggerMode mode) {
882 return Dso::ErrorCode::NONE; 852 return Dso::ErrorCode::NONE;
883 } 853 }
884 854
885 -/// \brief Set the trigger source.  
886 -/// \param special true for a special channel (EXT, ...) as trigger source.  
887 -/// \param id The number of the channel, that should be used as trigger.  
888 -/// \return See ::Dso::ErrorCode.  
889 Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) { 855 Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) {
890 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 856 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
891 if (specification.isSoftwareTriggerDevice) return Dso::ErrorCode::UNSUPPORTED; 857 if (specification.isSoftwareTriggerDevice) return Dso::ErrorCode::UNSUPPORTED;
@@ -932,10 +898,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) { @@ -932,10 +898,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerSource(bool special, unsigned id) {
932 return Dso::ErrorCode::NONE; 898 return Dso::ErrorCode::NONE;
933 } 899 }
934 900
935 -/// \brief Set the trigger level.  
936 -/// \param channel The channel that should be set.  
937 -/// \param level The new trigger level (V).  
938 -/// \return The trigger level that has been set, ::Dso::ErrorCode on error.  
939 Dso::ErrorCode HantekDsoControl::setTriggerLevel(ChannelID channel, double level) { 901 Dso::ErrorCode HantekDsoControl::setTriggerLevel(ChannelID channel, double level) {
940 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 902 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
941 903
@@ -977,9 +939,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerLevel(ChannelID channel, double level @@ -977,9 +939,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerLevel(ChannelID channel, double level
977 return Dso::ErrorCode::NONE; 939 return Dso::ErrorCode::NONE;
978 } 940 }
979 941
980 -/// \brief Set the trigger slope.  
981 -/// \param slope The Slope that should cause a trigger.  
982 -/// \return See ::Dso::ErrorCode.  
983 Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) { 942 Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) {
984 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 943 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
985 944
@@ -1009,9 +968,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) { @@ -1009,9 +968,6 @@ Dso::ErrorCode HantekDsoControl::setTriggerSlope(Dso::Slope slope) {
1009 968
1010 void HantekDsoControl::forceTrigger() { modifyCommand<BulkCommand>(BulkCode::FORCETRIGGER); } 969 void HantekDsoControl::forceTrigger() { modifyCommand<BulkCommand>(BulkCode::FORCETRIGGER); }
1011 970
1012 -/// \brief Set the trigger position.  
1013 -/// \param position The new trigger position (in s).  
1014 -/// \return The trigger position that has been set.  
1015 Dso::ErrorCode HantekDsoControl::setPretriggerPosition(double position) { 971 Dso::ErrorCode HantekDsoControl::setPretriggerPosition(double position) {
1016 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION; 972 if (!device->isConnected()) return Dso::ErrorCode::CONNECTION;
1017 973
openhantek/src/hantekdso/hantekdsocontrol.h
@@ -201,19 +201,63 @@ class HantekDsoControl : public QObject { @@ -201,19 +201,63 @@ class HantekDsoControl : public QObject {
201 void startSampling(); 201 void startSampling();
202 void stopSampling(); 202 void stopSampling();
203 203
  204 + /// \brief Sets the size of the oscilloscopes sample buffer.
  205 + /// \param index The record length index that should be set.
  206 + /// \return The record length that has been set, 0 on error.
204 Dso::ErrorCode setRecordLength(unsigned size); 207 Dso::ErrorCode setRecordLength(unsigned size);
  208 + /// \brief Sets the samplerate of the oscilloscope.
  209 + /// \param samplerate The samplerate that should be met (S/s), 0.0 to restore
  210 + /// current samplerate.
  211 + /// \return The samplerate that has been set, 0.0 on error.
205 Dso::ErrorCode setSamplerate(double samplerate = 0.0); 212 Dso::ErrorCode setSamplerate(double samplerate = 0.0);
  213 + /// \brief Sets the time duration of one aquisition by adapting the samplerate.
  214 + /// \param duration The record time duration that should be met (s), 0.0 to
  215 + /// restore current record time.
  216 + /// \return The record time duration that has been set, 0.0 on error.
206 Dso::ErrorCode setRecordTime(double duration = 0.0); 217 Dso::ErrorCode setRecordTime(double duration = 0.0);
207 218
  219 + /// \brief Enables/disables filtering of the given channel.
  220 + /// \param channel The channel that should be set.
  221 + /// \param used true if the channel should be sampled.
  222 + /// \return See ::Dso::ErrorCode.
208 Dso::ErrorCode setChannelUsed(ChannelID channel, bool used); 223 Dso::ErrorCode setChannelUsed(ChannelID channel, bool used);
  224 + /// \brief Set the coupling for the given channel.
  225 + /// \param channel The channel that should be set.
  226 + /// \param coupling The new coupling for the channel.
  227 + /// \return See ::Dso::ErrorCode.
209 Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling); 228 Dso::ErrorCode setCoupling(ChannelID channel, Dso::Coupling coupling);
  229 + /// \brief Sets the gain for the given channel.
  230 + /// Get the actual gain by specification.gainSteps[gainId]
  231 + /// \param channel The channel that should be set.
  232 + /// \param gain The gain that should be met (V/div).
  233 + /// \return The gain that has been set, ::Dso::ErrorCode on error.
210 Dso::ErrorCode setGain(ChannelID channel, double gain); 234 Dso::ErrorCode setGain(ChannelID channel, double gain);
  235 + /// \brief Set the offset for the given channel.
  236 + /// Get the actual offset for the channel from controlsettings.voltage[channel].offsetReal
  237 + /// \param channel The channel that should be set.
  238 + /// \param offset The new offset value (0.0 - 1.0).
211 Dso::ErrorCode setOffset(ChannelID channel, const double offset); 239 Dso::ErrorCode setOffset(ChannelID channel, const double offset);
212 240
  241 + /// \brief Set the trigger mode.
  242 + /// \return See ::Dso::ErrorCode.
213 Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode); 243 Dso::ErrorCode setTriggerMode(Dso::TriggerMode mode);
  244 + /// \brief Set the trigger source.
  245 + /// \param special true for a special channel (EXT, ...) as trigger source.
  246 + /// \param id The number of the channel, that should be used as trigger.
  247 + /// \return See ::Dso::ErrorCode.
214 Dso::ErrorCode setTriggerSource(bool special, unsigned id); 248 Dso::ErrorCode setTriggerSource(bool special, unsigned id);
  249 + /// \brief Set the trigger level.
  250 + /// \param channel The channel that should be set.
  251 + /// \param level The new trigger level (V).
  252 + /// \return The trigger level that has been set, ::Dso::ErrorCode on error.
215 Dso::ErrorCode setTriggerLevel(ChannelID channel, double level); 253 Dso::ErrorCode setTriggerLevel(ChannelID channel, double level);
  254 + /// \brief Set the trigger slope.
  255 + /// \param slope The Slope that should cause a trigger.
  256 + /// \return See ::Dso::ErrorCode.
216 Dso::ErrorCode setTriggerSlope(Dso::Slope slope); 257 Dso::ErrorCode setTriggerSlope(Dso::Slope slope);
  258 + /// \brief Set the trigger position.
  259 + /// \param position The new trigger position (in s).
  260 + /// \return The trigger position that has been set.
217 Dso::ErrorCode setPretriggerPosition(double position); 261 Dso::ErrorCode setPretriggerPosition(double position);
218 void forceTrigger(); 262 void forceTrigger();
219 263
openhantek/src/hantekdso/softwaretrigger.cpp
@@ -42,8 +42,6 @@ SoftwareTrigger::PrePostStartTriggerSamples SoftwareTrigger::computeTY(const Dat @@ -42,8 +42,6 @@ SoftwareTrigger::PrePostStartTriggerSamples SoftwareTrigger::computeTY(const Dat
42 preTrigSamples = (unsigned)(scope->trigger.position * samplesDisplay); 42 preTrigSamples = (unsigned)(scope->trigger.position * samplesDisplay);
43 postTrigSamples = (unsigned)sampleCount - ((unsigned)samplesDisplay - preTrigSamples); 43 postTrigSamples = (unsigned)sampleCount - ((unsigned)samplesDisplay - preTrigSamples);
44 44
45 - const int swTriggerThreshold = 7;  
46 - const int swTriggerSampleSet = 11;  
47 double prev; 45 double prev;
48 bool (*opcmp)(double,double,double); 46 bool (*opcmp)(double,double,double);
49 bool (*smplcmp)(double,double); 47 bool (*smplcmp)(double,double);
@@ -60,11 +58,11 @@ SoftwareTrigger::PrePostStartTriggerSamples SoftwareTrigger::computeTY(const Dat @@ -60,11 +58,11 @@ SoftwareTrigger::PrePostStartTriggerSamples SoftwareTrigger::computeTY(const Dat
60 for (unsigned int i = preTrigSamples; i < postTrigSamples; i++) { 58 for (unsigned int i = preTrigSamples; i < postTrigSamples; i++) {
61 double value = samples[i]; 59 double value = samples[i];
62 if (opcmp(value, level, prev)) { 60 if (opcmp(value, level, prev)) {
63 - int rising = 0;  
64 - for (unsigned int k = i + 1; k < i + swTriggerSampleSet && k < sampleCount; k++) { 61 + unsigned rising = 0;
  62 + for (unsigned int k = i + 1; k < i + scope->trigger.swTriggerSampleSet && k < sampleCount; k++) {
65 if (smplcmp(samples[k], value)) { rising++; } 63 if (smplcmp(samples[k], value)) { rising++; }
66 } 64 }
67 - if (rising > swTriggerThreshold) { 65 + if (rising > scope->trigger.swTriggerThreshold) {
68 swTriggerStart = i; 66 swTriggerStart = i;
69 break; 67 break;
70 } 68 }
openhantek/src/hantekdso/softwaretrigger.h
1 #pragma once 1 #pragma once
2 #include <tuple> 2 #include <tuple>
3 -#include "softwaretriggersettings.h"  
4 struct DsoSettingsScope; 3 struct DsoSettingsScope;
5 class DataAnalyzerResult; 4 class DataAnalyzerResult;
6 5
openhantek/src/hantekdso/softwaretriggersettings.h deleted
1 -#pragma once  
2 -  
3 -struct SoftwareTriggerSettings {  
4 - const unsigned sampleMargin = 2000;  
5 -};  
openhantek/src/main.cpp
@@ -33,7 +33,7 @@ void applySettingsToDevice(HantekDsoControl* dsoControl, DsoSettingsScope* scope @@ -33,7 +33,7 @@ void applySettingsToDevice(HantekDsoControl* dsoControl, DsoSettingsScope* scope
33 dsoControl->setChannelUsed(channel, mathUsed | scope->anyUsed(channel)); 33 dsoControl->setChannelUsed(channel, mathUsed | scope->anyUsed(channel));
34 } 34 }
35 35
36 - if (scope->horizontal.samplerateSet) 36 + if (scope->horizontal.samplerateSource == DsoSettingsScopeHorizontal::Samplerrate)
37 dsoControl->setSamplerate(scope->horizontal.samplerate); 37 dsoControl->setSamplerate(scope->horizontal.samplerate);
38 else 38 else
39 dsoControl->setRecordTime(scope->horizontal.timebase * DIVS_TIME); 39 dsoControl->setRecordTime(scope->horizontal.timebase * DIVS_TIME);
openhantek/src/mainwindow.cpp
@@ -93,7 +93,8 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser, @@ -93,7 +93,8 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser,
93 }); 93 });
94 94
95 connect(dsoControl, &HantekDsoControl::recordTimeChanged, [this](double duration) { 95 connect(dsoControl, &HantekDsoControl::recordTimeChanged, [this](double duration) {
96 - if (this->settings->scope.horizontal.samplerateSet && this->settings->scope.horizontal.recordLength != UINT_MAX) { 96 + if (this->settings->scope.horizontal.samplerateSource == DsoSettingsScopeHorizontal::Samplerrate &&
  97 + this->settings->scope.horizontal.recordLength != UINT_MAX) {
97 // The samplerate was set, let's adapt the timebase accordingly 98 // The samplerate was set, let's adapt the timebase accordingly
98 this->settings->scope.horizontal.timebase = horizontalDock->setTimebase(duration / DIVS_TIME); 99 this->settings->scope.horizontal.timebase = horizontalDock->setTimebase(duration / DIVS_TIME);
99 } 100 }
@@ -106,7 +107,8 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser, @@ -106,7 +107,8 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser,
106 dsoWidget->updateTimebase(this->settings->scope.horizontal.timebase); 107 dsoWidget->updateTimebase(this->settings->scope.horizontal.timebase);
107 }); 108 });
108 connect(dsoControl, &HantekDsoControl::samplerateChanged, [this](double samplerate) { 109 connect(dsoControl, &HantekDsoControl::samplerateChanged, [this](double samplerate) {
109 - if (!this->settings->scope.horizontal.samplerateSet && this->settings->scope.horizontal.recordLength != UINT_MAX) { 110 + if (this->settings->scope.horizontal.samplerateSource == DsoSettingsScopeHorizontal::Duration &&
  111 + this->settings->scope.horizontal.recordLength != UINT_MAX) {
110 // The timebase was set, let's adapt the samplerate accordingly 112 // The timebase was set, let's adapt the samplerate accordingly
111 this->settings->scope.horizontal.samplerate = samplerate; 113 this->settings->scope.horizontal.samplerate = samplerate;
112 horizontalDock->setSamplerate(samplerate); 114 horizontalDock->setSamplerate(samplerate);
@@ -259,7 +261,7 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser, @@ -259,7 +261,7 @@ MainWindow::MainWindow(HantekDsoControl *dsoControl, DataAnalyzer *dataAnalyser,
259 261
260 }); 262 });
261 263
262 - if (settings->scope.horizontal.samplerateSet) 264 + if (settings->scope.horizontal.samplerateSource == DsoSettingsScopeHorizontal::Samplerrate)
263 dsoWidget->updateSamplerate(settings->scope.horizontal.samplerate); 265 dsoWidget->updateSamplerate(settings->scope.horizontal.samplerate);
264 else 266 else
265 dsoWidget->updateTimebase(settings->scope.horizontal.timebase); 267 dsoWidget->updateTimebase(settings->scope.horizontal.timebase);
openhantek/src/scopesettings.h
@@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
5 #include <QString> 5 #include <QString>
6 6
7 #include "analyse/enums.h" 7 #include "analyse/enums.h"
  8 +#include "hantekdso/controlspecification.h"
8 #include "hantekdso/enums.h" 9 #include "hantekdso/enums.h"
9 #include "hantekprotocol/definitions.h" 10 #include "hantekprotocol/definitions.h"
10 -#include "hantekdso/controlspecification.h"  
11 #include <vector> 11 #include <vector>
12 12
13 #define MARKER_COUNT 2 ///< Number of markers 13 #define MARKER_COUNT 2 ///< Number of markers
@@ -15,23 +15,28 @@ @@ -15,23 +15,28 @@
15 /// \brief Holds the settings for the horizontal axis. 15 /// \brief Holds the settings for the horizontal axis.
16 struct DsoSettingsScopeHorizontal { 16 struct DsoSettingsScopeHorizontal {
17 Dso::GraphFormat format = Dso::GraphFormat::TY; ///< Graph drawing mode of the scope 17 Dso::GraphFormat format = Dso::GraphFormat::TY; ///< Graph drawing mode of the scope
18 - double frequencybase = 1e3; ///< Frequencybase in Hz/div  
19 - double marker[MARKER_COUNT] = {-1.0, 1.0}; ///< Marker positions in div  
20 - bool marker_visible[MARKER_COUNT];  
21 - double timebase = 1e-3; ///< Timebase in s/div 18 + double frequencybase = 1e3; ///< Frequencybase in Hz/div
  19 + double marker[MARKER_COUNT] = {-1.0, 1.0}; ///< Marker positions in div
  20 + bool marker_visible[MARKER_COUNT] = {true, true};
  21 +
22 unsigned int recordLength = 0; ///< Sample count 22 unsigned int recordLength = 0; ///< Sample count
  23 +
  24 + ///TODO Use ControlSettingsSamplerateTarget
  25 + double timebase = 1e-3; ///< Timebase in s/div
23 double samplerate = 1e6; ///< The samplerate of the oscilloscope in S 26 double samplerate = 1e6; ///< The samplerate of the oscilloscope in S
24 - bool samplerateSet = false; ///< The samplerate was set by the user, not the timebase 27 + enum SamplerateSource { Samplerrate, Duration } samplerateSource = Samplerrate;
25 }; 28 };
26 29
27 /// \brief Holds the settings for the trigger. 30 /// \brief Holds the settings for the trigger.
  31 +/// TODO Use ControlSettingsTrigger
28 struct DsoSettingsScopeTrigger { 32 struct DsoSettingsScopeTrigger {
29 - bool filter = true; ///< Not sure what this is good for...  
30 Dso::TriggerMode mode = Dso::TriggerMode::NORMAL; ///< Automatic, normal or single trigger 33 Dso::TriggerMode mode = Dso::TriggerMode::NORMAL; ///< Automatic, normal or single trigger
31 - double position = 0.0; ///< Horizontal position for pretrigger 34 + double position = 0.0; ///< Horizontal position for pretrigger
32 Dso::Slope slope = Dso::Slope::Positive; ///< Rising or falling edge causes trigger 35 Dso::Slope slope = Dso::Slope::Positive; ///< Rising or falling edge causes trigger
33 - unsigned int source = 0; ///< Channel that is used as trigger source  
34 - bool special = false; ///< true if the trigger source is not a standard channel 36 + unsigned int source = 0; ///< Channel that is used as trigger source
  37 + bool special = false; ///< true if the trigger source is not a standard channel
  38 + unsigned swTriggerThreshold = 7; ///< Software trigger, threshold
  39 + unsigned swTriggerSampleSet = 11; ///< Software trigger, sample set
35 }; 40 };
36 41
37 /// \brief Holds the settings for the spectrum analysis. 42 /// \brief Holds the settings for the spectrum analysis.
@@ -44,6 +49,7 @@ struct DsoSettingsScopeSpectrum { @@ -44,6 +49,7 @@ struct DsoSettingsScopeSpectrum {
44 }; 49 };
45 50
46 /// \brief Holds the settings for the normal voltage graphs. 51 /// \brief Holds the settings for the normal voltage graphs.
  52 +/// TODO Use ControlSettingsVoltage
47 struct DsoSettingsScopeVoltage { 53 struct DsoSettingsScopeVoltage {
48 unsigned gainStepIndex = 6; ///< The vertical resolution in V/div (default = 1.0) 54 unsigned gainStepIndex = 6; ///< The vertical resolution in V/div (default = 1.0)
49 bool inverted = false; ///< true if the channel is inverted (mirrored on cross-axis) 55 bool inverted = false; ///< true if the channel is inverted (mirrored on cross-axis)
@@ -70,15 +76,10 @@ struct DsoSettingsScope { @@ -70,15 +76,10 @@ struct DsoSettingsScope {
70 double spectrumReference = 0.0; ///< Reference level for spectrum in dBm 76 double spectrumReference = 0.0; ///< Reference level for spectrum in dBm
71 double spectrumLimit = -20.0; ///< Minimum magnitude of the spectrum (Avoids peaks) 77 double spectrumLimit = -20.0; ///< Minimum magnitude of the spectrum (Avoids peaks)
72 78
73 - double gain(unsigned channel) const {  
74 - return gainSteps[voltage[channel].gainStepIndex];  
75 - }  
76 - bool anyUsed(ChannelID channel) {  
77 - return voltage[channel].used | spectrum[channel].used;  
78 - } 79 + double gain(unsigned channel) const { return gainSteps[voltage[channel].gainStepIndex]; }
  80 + bool anyUsed(ChannelID channel) { return voltage[channel].used | spectrum[channel].used; }
79 81
80 - Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification* deviceSpecification) { 82 + Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification *deviceSpecification) {
81 return deviceSpecification->couplings[voltage[channel].couplingIndex]; 83 return deviceSpecification->couplings[voltage[channel].couplingIndex];
82 } 84 }
83 -  
84 }; 85 };
openhantek/src/settings.cpp
@@ -84,11 +84,10 @@ void DsoSettings::load() { @@ -84,11 +84,10 @@ void DsoSettings::load() {
84 if (store->contains("timebase")) scope.horizontal.timebase = store->value("timebase").toDouble(); 84 if (store->contains("timebase")) scope.horizontal.timebase = store->value("timebase").toDouble();
85 if (store->contains("recordLength")) scope.horizontal.recordLength = store->value("recordLength").toUInt(); 85 if (store->contains("recordLength")) scope.horizontal.recordLength = store->value("recordLength").toUInt();
86 if (store->contains("samplerate")) scope.horizontal.samplerate = store->value("samplerate").toDouble(); 86 if (store->contains("samplerate")) scope.horizontal.samplerate = store->value("samplerate").toDouble();
87 - if (store->contains("samplerateSet")) scope.horizontal.samplerateSet = store->value("samplerateSet").toBool(); 87 + if (store->contains("samplerateSet")) scope.horizontal.samplerateSource = (DsoSettingsScopeHorizontal::SamplerateSource)store->value("samplerateSet").toInt();
88 store->endGroup(); 88 store->endGroup();
89 // Trigger 89 // Trigger
90 store->beginGroup("trigger"); 90 store->beginGroup("trigger");
91 - if (store->contains("filter")) scope.trigger.filter = store->value("filter").toBool();  
92 if (store->contains("mode")) scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toUInt(); 91 if (store->contains("mode")) scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toUInt();
93 if (store->contains("position")) scope.trigger.position = store->value("position").toDouble(); 92 if (store->contains("position")) scope.trigger.position = store->value("position").toDouble();
94 if (store->contains("slope")) scope.trigger.slope = (Dso::Slope)store->value("slope").toUInt(); 93 if (store->contains("slope")) scope.trigger.slope = (Dso::Slope)store->value("slope").toUInt();
@@ -186,11 +185,10 @@ void DsoSettings::save() { @@ -186,11 +185,10 @@ void DsoSettings::save() {
186 store->setValue("timebase", scope.horizontal.timebase); 185 store->setValue("timebase", scope.horizontal.timebase);
187 store->setValue("recordLength", scope.horizontal.recordLength); 186 store->setValue("recordLength", scope.horizontal.recordLength);
188 store->setValue("samplerate", scope.horizontal.samplerate); 187 store->setValue("samplerate", scope.horizontal.samplerate);
189 - store->setValue("samplerateSet", scope.horizontal.samplerateSet); 188 + store->setValue("samplerateSet", (int)scope.horizontal.samplerateSource);
190 store->endGroup(); 189 store->endGroup();
191 // Trigger 190 // Trigger
192 store->beginGroup("trigger"); 191 store->beginGroup("trigger");
193 - store->setValue("filter", scope.trigger.filter);  
194 store->setValue("mode", (unsigned)scope.trigger.mode); 192 store->setValue("mode", (unsigned)scope.trigger.mode);
195 store->setValue("position", scope.trigger.position); 193 store->setValue("position", scope.trigger.position);
196 store->setValue("slope", (unsigned)scope.trigger.slope); 194 store->setValue("slope", (unsigned)scope.trigger.slope);