From: Joel Holdsworth Date: Mon, 27 May 2013 11:06:06 +0000 (+0100) Subject: Added trigger selection handlers X-Git-Tag: pulseview-0.2.0~336 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b08d7222556b0a56b4fc61782faa4664a0368d59;p=pulseview.git Added trigger selection handlers --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ad226931..bc30c30e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,7 @@ set(pulseview_HEADERS pv/toolbars/samplingbar.h pv/view/cursor.h pv/view/header.h + pv/view/logicsignal.h pv/view/marginwidget.h pv/view/ruler.h pv/view/selectableitem.h diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 813bb29e..ea138fa7 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -80,6 +80,19 @@ LogicSignal::LogicSignal(pv::SigSession &session, const sr_probe *const probe, _colour = SignalColours[probe->index % countof(SignalColours)]; _separator.setSeparator(true); + + connect(&_trigger_none, SIGNAL(triggered()), + this, SLOT(on_trigger_none())); + connect(&_trigger_rising, SIGNAL(triggered()), + this, SLOT(on_trigger_rising())); + connect(&_trigger_high, SIGNAL(triggered()), + this, SLOT(on_trigger_high())); + connect(&_trigger_falling, SIGNAL(triggered()), + this, SLOT(on_trigger_falling())); + connect(&_trigger_low, SIGNAL(triggered()), + this, SLOT(on_trigger_low())); + connect(&_trigger_change, SIGNAL(triggered()), + this, SLOT(on_trigger_change())); } LogicSignal::~LogicSignal() @@ -233,5 +246,53 @@ void LogicSignal::add_trigger_action(const char *trig_types, char type, } } +void LogicSignal::set_trigger(char type) +{ + const char trigger_type_string[2] = {type, 0}; + const char *const trigger_string = + (type != 0) ? trigger_type_string : NULL; + + const sr_dev_inst *const sdi = _session.get_device(); + const int probe_count = g_slist_length(sdi->probes); + assert(probe_count > 0); + + assert(_probe && _probe->index < probe_count); + + for (int i = 0; i < probe_count; i++) { + sr_dev_trigger_set(sdi, i, (i == _probe->index) ? + trigger_string : NULL); + } +} + +void LogicSignal::on_trigger_none() +{ + set_trigger('\0'); +} + +void LogicSignal::on_trigger_rising() +{ + set_trigger('r'); +} + +void LogicSignal::on_trigger_high() +{ + set_trigger('1'); +} + +void LogicSignal::on_trigger_falling() +{ + set_trigger('f'); +} + +void LogicSignal::on_trigger_low() +{ + set_trigger('0'); +} + +void LogicSignal::on_trigger_change() +{ + set_trigger('c'); +} + } // namespace view } // namespace pv diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h index 40babbca..81a6e7c0 100644 --- a/pv/view/logicsignal.h +++ b/pv/view/logicsignal.h @@ -35,6 +35,8 @@ namespace view { class LogicSignal : public Signal { + Q_OBJECT + private: static const float Oversampling; @@ -75,6 +77,16 @@ private: static void add_trigger_action(const char *trig_types, char type, QAction *action, std::list &actions); + void set_trigger(char type); + +private slots: + void on_trigger_none(); + void on_trigger_rising(); + void on_trigger_high(); + void on_trigger_falling(); + void on_trigger_low(); + void on_trigger_change(); + private: boost::shared_ptr _data;