X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsignalbase.cpp;h=797bd456817e9e1cb0ef2d4c39e193acbe33b165;hp=514459d283449b9617fbf0353962ff18cc974de5;hb=8e15445ccd6994348eb74b24b5324d26c9be0cce;hpb=52c900ac8626b33cfd55485b4474fb5160524d33 diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 514459d2..797bd456 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -140,6 +140,14 @@ void SignalBase::set_data(shared_ptr data) this, SLOT(on_samples_cleared())); disconnect(data.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t))); + + if (channel_type_ == AnalogChannel) { + shared_ptr analog = analog_data(); + assert(analog); + + disconnect(analog.get(), SIGNAL(min_max_changed(float, float)), + this, SLOT(on_min_max_changed(float, float))); + } } data_ = data; @@ -149,6 +157,14 @@ void SignalBase::set_data(shared_ptr data) this, SLOT(on_samples_cleared())); connect(data.get(), SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), this, SLOT(on_samples_added(QObject*, uint64_t, uint64_t))); + + if (channel_type_ == AnalogChannel) { + shared_ptr analog = analog_data(); + assert(analog); + + connect(analog.get(), SIGNAL(min_max_changed(float, float)), + this, SLOT(on_min_max_changed(float, float))); + } } } @@ -169,7 +185,7 @@ shared_ptr SignalBase::logic_data() const if (channel_type_ == LogicChannel) result = dynamic_pointer_cast(data_); - if (((conversion_type_ == A2LConversionByTreshold) || + if (((conversion_type_ == A2LConversionByThreshold) || (conversion_type_ == A2LConversionBySchmittTrigger))) result = dynamic_pointer_cast(converted_data_); @@ -239,7 +255,7 @@ vector SignalBase::get_conversion_thresholds(const ConversionType t, else preset = get_current_conversion_preset(); - if (conv_type == A2LConversionByTreshold) { + if (conv_type == A2LConversionByThreshold) { double thr = 0; if (preset == -1) { @@ -295,7 +311,7 @@ vector< pair > SignalBase::get_conversion_presets() const { vector< pair > presets; - if (conversion_type_ == A2LConversionByTreshold) { + if (conversion_type_ == A2LConversionByThreshold) { // Source: http://www.interfacebus.com/voltage_threshold.html presets.emplace_back(tr("Signal average"), 0); presets.emplace_back(tr("0.9V (for 1.8V CMOS)"), 1); @@ -373,7 +389,7 @@ void SignalBase::restore_settings(QSettings &settings) bool SignalBase::conversion_is_a2l() const { return ((channel_type_ == AnalogChannel) && - ((conversion_type_ == A2LConversionByTreshold) || + ((conversion_type_ == A2LConversionByThreshold) || (conversion_type_ == A2LConversionBySchmittTrigger))); } @@ -427,7 +443,7 @@ void SignalBase::conversion_thread_proc(QObject* segment) // Convert uint64_t i = start_sample; - if (conversion_type_ == A2LConversionByTreshold) { + if (conversion_type_ == A2LConversionByThreshold) { const double threshold = get_conversion_thresholds()[0]; // Convert as many sample blocks as we can @@ -560,14 +576,23 @@ void SignalBase::on_samples_added(QObject* segment, uint64_t start_sample, samples_added(segment, start_sample, end_sample); } +void SignalBase::on_min_max_changed(float min, float max) +{ + (void)min; + (void)max; + + // Restart conversion if one is enabled and uses an automatic threshold + if ((conversion_type_ != NoConversion) && + (get_current_conversion_preset() == 0)) + start_conversion(); +} + void SignalBase::on_capture_state_changed(int state) { if (state == Session::Running) { - if (conversion_type_ != NoConversion) { - // Restart conversion - stop_conversion(); + // Restart conversion if one is enabled + if (conversion_type_ != NoConversion) start_conversion(); - } } }