]> sigrok.org Git - pulseview.git/commitdiff
Added trigger selection handlers
authorJoel Holdsworth <redacted>
Mon, 27 May 2013 11:06:06 +0000 (12:06 +0100)
committerJoel Holdsworth <redacted>
Mon, 27 May 2013 11:06:06 +0000 (12:06 +0100)
CMakeLists.txt
pv/view/logicsignal.cpp
pv/view/logicsignal.h

index ad226931dafdd978760b7fc0978e6ffd3ea27aae..bc30c30ea3800a4c267a7be0cf4be92d246b2883 100644 (file)
@@ -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
index 813bb29eedd94b5af04b3a73a297e3ef2e41f8d8..ea138fa76d2b2285e50c588ed26b833c4e1df170 100644 (file)
@@ -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
index 40babbcaf69a4d6a524101cc6f1e445c78fcca6d..81a6e7c0c2b3e735c2725c05bb6cd82cda780ad1 100644 (file)
@@ -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<QAction*> &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<pv::data::Logic> _data;