From: Joel Holdsworth Date: Sun, 19 Jan 2014 14:49:45 +0000 (+0000) Subject: Show a 1-2-5 list for the sample count widget X-Git-Tag: pulseview-0.2.0~118 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b50ef520745ffb90eb32f27ac6c46c2d5e4baf82;p=pulseview.git Show a 1-2-5 list for the sample count widget --- diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 79dd7a1a..036294bc 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -35,12 +35,16 @@ #include #include +using std::max; +using std::min; using std::string; namespace pv { namespace toolbars { -const uint64_t SamplingBar::DefaultRecordLength = 1000000; +const uint64_t SamplingBar::MinSampleCount = 100ULL; +const uint64_t SamplingBar::MaxSampleCount = 1000000000000ULL; +const uint64_t SamplingBar::DefaultSampleCount = 1000000; SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : QToolBar("Sampling Bar", parent), @@ -223,24 +227,41 @@ void SamplingBar::update_sample_count_selector() { sr_dev_inst *const sdi = get_selected_device(); GVariant *gvar; - uint64_t samplecount = 0; assert(sdi); - if (_sample_count_supported) - _sample_count.show_min_max_step(0, UINT64_MAX, 1); - else - _sample_count.show_none(); + _updating_sample_count = true; - if (sr_config_get(sdi->driver, sdi, NULL, - SR_CONF_LIMIT_SAMPLES, &gvar) == SR_OK) + if (_sample_count_supported) { - samplecount = g_variant_get_uint64(gvar); - g_variant_unref(gvar); + uint64_t sample_count = DefaultSampleCount; + uint64_t max_sample_count = MaxSampleCount; + + if (sr_config_get(sdi->driver, sdi, NULL, + SR_CONF_MAX_UNCOMPRESSED_SAMPLES, &gvar) == SR_OK) { + max_sample_count = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } + + _sample_count.show_125_list(MinSampleCount, max_sample_count); + + if (sr_config_get(sdi->driver, sdi, NULL, + SR_CONF_LIMIT_SAMPLES, &gvar) == SR_OK) + { + sample_count = g_variant_get_uint64(gvar); + if (sample_count == 0) + sample_count = DefaultSampleCount; + sample_count = min(max(sample_count, MinSampleCount), + max_sample_count); + + g_variant_unref(gvar); + } + + _sample_count.set_value(sample_count); } + else + _sample_count.show_none(); - _updating_sample_count = true; - _sample_count.set_value(samplecount); _updating_sample_count = false; } @@ -328,11 +349,6 @@ void SamplingBar::on_device_selected() // Update sweep timing widgets. update_sample_count_selector(); update_sample_rate_selector(); - - if (_sample_count_supported && _sample_count.value() == 0) { - _sample_count.set_value(DefaultRecordLength); - commit_sample_count(); - } } void SamplingBar::on_sample_count_changed() @@ -349,6 +365,7 @@ void SamplingBar::on_sample_rate_changed() void SamplingBar::on_run_stop() { + commit_sample_count(); commit_sample_rate(); run_stop(); } diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index db4c10e4..6fc8abd3 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -48,7 +48,9 @@ class SamplingBar : public QToolBar Q_OBJECT private: - static const uint64_t DefaultRecordLength; + static const uint64_t MinSampleCount; + static const uint64_t MaxSampleCount; + static const uint64_t DefaultSampleCount; public: SamplingBar(SigSession &session, QWidget *parent);