const int SignalBase::ColourBGAlpha = 8 * 256 / 100;
const uint64_t SignalBase::ConversionBlockSize = 4096;
+const uint32_t SignalBase::ConversionDelay = 1000; // 1 second
SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type) :
channel_(channel),
{
if (channel_)
internal_name_ = QString::fromStdString(channel_->name());
+
+ connect(&delayed_conversion_starter_, SIGNAL(timeout()),
+ this, SLOT(on_delayed_conversion_start()));
+ delayed_conversion_starter_.setSingleShot(true);
+ delayed_conversion_starter_.setInterval(ConversionDelay);
}
SignalBase::~SignalBase()
if (preset != conversion_options_.end())
return (ConversionPreset)((preset->second).toInt());
- return NoPreset;
+ return DynamicPreset;
}
void SignalBase::set_conversion_preset(ConversionPreset id)
} while (!conversion_interrupt_);
}
-void SignalBase::start_conversion()
+void SignalBase::start_conversion(bool delayed_start)
{
+ if (delayed_start) {
+ delayed_conversion_starter_.start();
+ return;
+ }
+
stop_conversion();
if (converted_data_)
// Notify the conversion thread since it's running
conversion_input_cond_.notify_one();
} else {
- // Start the conversion thread
- start_conversion();
+ // Start the conversion thread unless the delay timer is running
+ if (!delayed_conversion_starter_.isActive())
+ start_conversion();
}
}
void SignalBase::on_min_max_changed(float min, float max)
{
- (void)min;
- (void)max;
-
// Restart conversion if one is enabled and uses a calculated threshold
if ((conversion_type_ != NoConversion) &&
(get_current_conversion_preset() == DynamicPreset))
- start_conversion();
+ start_conversion(true);
+
+ min_max_changed(min, max);
}
void SignalBase::on_capture_state_changed(int state)
}
}
+void SignalBase::on_delayed_conversion_start()
+{
+ start_conversion();
+}
+
} // namespace data
} // namespace pv