diff options
author | Sven Wegener <sven.wegener@stealer.net> | 2014-06-30 09:38:31 +0200 |
---|---|---|
committer | Sven Wegener <sven.wegener@stealer.net> | 2014-06-30 09:38:31 +0200 |
commit | 79de83205964ee0182940ef7cec86b46896ed0e6 (patch) | |
tree | ccf532205a550ac926e52069649a1cc41aa555a6 /DSLogic-gui/pv/dock | |
parent | 3de7dbb24c71c0d894dbd734ddf9258683d9e2e1 (diff) |
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Diffstat (limited to 'DSLogic-gui/pv/dock')
-rw-r--r-- | DSLogic-gui/pv/dock/dsotriggerdock.cpp | 196 | ||||
-rw-r--r-- | DSLogic-gui/pv/dock/dsotriggerdock.h | 76 | ||||
-rw-r--r-- | DSLogic-gui/pv/dock/measuredock.cpp | 2 | ||||
-rw-r--r-- | DSLogic-gui/pv/dock/triggerdock.cpp | 24 |
4 files changed, 287 insertions, 11 deletions
diff --git a/DSLogic-gui/pv/dock/dsotriggerdock.cpp b/DSLogic-gui/pv/dock/dsotriggerdock.cpp new file mode 100644 index 0000000..d8f8277 --- /dev/null +++ b/DSLogic-gui/pv/dock/dsotriggerdock.cpp @@ -0,0 +1,196 @@ +/*
+ * This file is part of the DSLogic-gui project.
+ * DSLogic-gui is based on PulseView.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ * Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "dsotriggerdock.h"
+#include "../sigsession.h"
+
+#include <QObject>
+#include <QLabel>
+#include <QRadioButton>
+#include <QPainter>
+#include <QStyleOption>
+#include <QMessageBox>
+
+#include <QVector>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+
+#include "libsigrok4DSLogic/libsigrok.h"
+
+namespace pv {
+namespace dock {
+
+DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) :
+ QWidget(parent),
+ _session(session)
+{
+ QLabel *position_label = new QLabel("Trigger Position: ", this);
+ position_spinBox = new QSpinBox(this);
+ position_spinBox->setRange(0, 99);
+ position_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
+ position_slider = new QSlider(Qt::Horizontal, this);
+ position_slider->setRange(0, 99);
+ connect(position_slider, SIGNAL(valueChanged(int)), position_spinBox, SLOT(setValue(int)));
+ connect(position_spinBox, SIGNAL(valueChanged(int)), position_slider, SLOT(setValue(int)));
+ connect(position_slider, SIGNAL(valueChanged(int)), this, SLOT(pos_changed(int)));
+
+ QLabel *tSource_labe = new QLabel("Trigger Sources: ", this);
+ QRadioButton *auto_radioButton = new QRadioButton("Auto");
+ auto_radioButton->setChecked(true);
+ QRadioButton *ch0_radioButton = new QRadioButton("Channel 0");
+ QRadioButton *ch1_radioButton = new QRadioButton("Channel 1");
+ QRadioButton *ch0a1_radioButton = new QRadioButton("Channel 0 && Channel 1");
+ QRadioButton *ch0o1_radioButton = new QRadioButton("Channel 0 | Channel 1");
+ connect(auto_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
+ connect(ch0_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
+ connect(ch1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
+ connect(ch0a1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
+ connect(ch0o1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
+
+ QLabel *tType_labe = new QLabel("Trigger Types: ", this);
+ QRadioButton *rising_radioButton = new QRadioButton("Rising Edge");
+ rising_radioButton->setChecked(true);
+ QRadioButton *falling_radioButton = new QRadioButton("Falling Edge");
+ connect(rising_radioButton, SIGNAL(clicked()), this, SLOT(type_changed()));
+ connect(falling_radioButton, SIGNAL(clicked()), this, SLOT(type_changed()));
+
+ source_group=new QButtonGroup(this);
+ type_group=new QButtonGroup(this);
+
+ source_group->addButton(auto_radioButton);
+ source_group->addButton(ch0_radioButton);
+ source_group->addButton(ch1_radioButton);
+ source_group->addButton(ch0a1_radioButton);
+ source_group->addButton(ch0o1_radioButton);
+ source_group->setId(auto_radioButton, DSO_TRIGGER_AUTO);
+ source_group->setId(ch0_radioButton, DSO_TRIGGER_CH0);
+ source_group->setId(ch1_radioButton, DSO_TRIGGER_CH1);
+ source_group->setId(ch0a1_radioButton, DSO_TRIGGER_CH0A1);
+ source_group->setId(ch0o1_radioButton, DSO_TRIGGER_CH0O1);
+
+ type_group->addButton(rising_radioButton);
+ type_group->addButton(falling_radioButton);
+ type_group->setId(rising_radioButton, DSO_TRIGGER_RISING);
+ type_group->setId(falling_radioButton, DSO_TRIGGER_FALLING);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QGridLayout *gLayout = new QGridLayout();
+ gLayout->addWidget(position_label, 0, 0);
+ gLayout->addWidget(position_spinBox, 0, 1);
+ gLayout->addWidget(new QLabel(this), 0, 2);
+ gLayout->addWidget(position_slider, 1, 0, 1, 3);
+
+ gLayout->addWidget(new QLabel(this), 2, 0);
+ gLayout->addWidget(tSource_labe, 3, 0);
+ gLayout->addWidget(auto_radioButton, 4, 0);
+ gLayout->addWidget(ch0_radioButton, 5, 0);
+ gLayout->addWidget(ch1_radioButton, 5, 1);
+ gLayout->addWidget(ch0a1_radioButton, 6, 0);
+ gLayout->addWidget(ch0o1_radioButton, 6, 1);
+
+ gLayout->addWidget(new QLabel(this), 7, 0);
+ gLayout->addWidget(tType_labe, 8, 0);
+ gLayout->addWidget(rising_radioButton, 9, 0);
+ gLayout->addWidget(falling_radioButton, 10, 0);
+
+ gLayout->setColumnStretch(3, 1);
+
+ layout->addLayout(gLayout);
+ layout->addStretch(1);
+ setLayout(layout);
+}
+
+DsoTriggerDock::~DsoTriggerDock()
+{
+}
+
+void DsoTriggerDock::paintEvent(QPaintEvent *)
+{
+ QStyleOption opt;
+ opt.init(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+}
+
+void DsoTriggerDock::pos_changed(int pos)
+{
+ int ret;
+ quint32 real_pos;
+ real_pos = pos*_session.get_total_sample_len()/100.0f;
+ real_pos = (_session.get_last_sample_rate() > SR_MHZ(100)) ? real_pos/2 : real_pos;
+ ret = sr_config_set(_session.get_device(), SR_CONF_HORIZ_TRIGGERPOS, g_variant_new_uint32(real_pos));
+ if (ret != SR_OK) {
+ QMessageBox msg(this);
+ msg.setText("Trigger Setting Issue");
+ msg.setInformativeText("Change horiz trigger position failed!");
+ msg.setStandardButtons(QMessageBox::Ok);
+ msg.setIcon(QMessageBox::Warning);
+ msg.exec();
+ }
+}
+
+void DsoTriggerDock::source_changed()
+{
+ int id = source_group->checkedId();
+ int ret;
+
+ ret = sr_config_set(_session.get_device(), SR_CONF_TRIGGER_SOURCE, g_variant_new_byte(id));
+ if (ret != SR_OK) {
+ QMessageBox msg(this);
+ msg.setText("Trigger Setting Issue");
+ msg.setInformativeText("Change trigger source failed!");
+ msg.setStandardButtons(QMessageBox::Ok);
+ msg.setIcon(QMessageBox::Warning);
+ msg.exec();
+ }
+}
+
+void DsoTriggerDock::type_changed()
+{
+ int id = type_group->checkedId();
+ int ret;
+
+ ret = sr_config_set(_session.get_device(), SR_CONF_TRIGGER_SLOPE, g_variant_new_byte(id));
+ if (ret != SR_OK) {
+ QMessageBox msg(this);
+ msg.setText("Trigger Setting Issue");
+ msg.setInformativeText("Change trigger type failed!");
+ msg.setStandardButtons(QMessageBox::Ok);
+ msg.setIcon(QMessageBox::Warning);
+ msg.exec();
+ }
+}
+
+void DsoTriggerDock::device_change()
+{
+ if (strcmp(_session.get_device()->driver->name, "DSLogic") != 0) {
+ position_spinBox->setDisabled(true);
+ position_slider->setDisabled(true);
+ } else {
+ position_spinBox->setDisabled(false);
+ position_slider->setDisabled(false);
+ }
+}
+
+} // namespace dock
+} // namespace pv
diff --git a/DSLogic-gui/pv/dock/dsotriggerdock.h b/DSLogic-gui/pv/dock/dsotriggerdock.h new file mode 100644 index 0000000..5c135c4 --- /dev/null +++ b/DSLogic-gui/pv/dock/dsotriggerdock.h @@ -0,0 +1,76 @@ +/*
+ * This file is part of the DSLogic-gui project.
+ * DSLogic-gui is based on PulseView.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ * Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef DSLOGIC_PV_DSOTRIGGERDOCK_H
+#define DSLOGIC_PV_DSOTRIGGERDOCK_H
+
+#include <QDockWidget>
+#include <QSlider>
+#include <QSpinBox>
+#include <QButtonGroup>
+
+#include <vector>
+
+#include <libsigrok4DSLogic/libsigrok.h>
+
+namespace pv {
+
+class SigSession;
+
+namespace dock {
+
+class DsoTriggerDock : public QWidget
+{
+ Q_OBJECT
+
+public:
+ DsoTriggerDock(QWidget *parent, SigSession &session);
+ ~DsoTriggerDock();
+
+ void paintEvent(QPaintEvent *);
+
+ void device_change();
+
+signals:
+
+private slots:
+ void pos_changed(int pos);
+ void source_changed();
+ void type_changed();
+
+private:
+
+private:
+ SigSession &_session;
+
+ QSpinBox *position_spinBox;
+ QSlider *position_slider;
+
+ QButtonGroup *source_group;
+ QButtonGroup *type_group;
+};
+
+} // namespace dock
+} // namespace pv
+
+#endif // DSLOGIC_PV_DSOTRIGGERDOCK_H
diff --git a/DSLogic-gui/pv/dock/measuredock.cpp b/DSLogic-gui/pv/dock/measuredock.cpp index e2ab59d..43c43cf 100644 --- a/DSLogic-gui/pv/dock/measuredock.cpp +++ b/DSLogic-gui/pv/dock/measuredock.cpp @@ -32,6 +32,8 @@ #include <QPainter>
#include <QRegExpValidator>
+#include "libsigrok4DSLogic/libsigrok.h"
+
namespace pv {
namespace dock {
diff --git a/DSLogic-gui/pv/dock/triggerdock.cpp b/DSLogic-gui/pv/dock/triggerdock.cpp index 38e89b8..d5fc890 100644 --- a/DSLogic-gui/pv/dock/triggerdock.cpp +++ b/DSLogic-gui/pv/dock/triggerdock.cpp @@ -31,6 +31,8 @@ #include <QRegExpValidator>
#include <QMessageBox>
+#include "libsigrok4DSLogic/libsigrok.h"
+
namespace pv {
namespace dock {
@@ -40,6 +42,10 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) : {
int i;
+ QFont font("Monaco");
+ font.setStyleHint(QFont::Monospace);
+ font.setFixedPitch(true);
+
simple_radioButton = new QRadioButton("Simple Trigger", this);
simple_radioButton->setChecked(true);
adv_radioButton = new QRadioButton("Advanced Trigger", this);
@@ -75,6 +81,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) : _logic_comboBox_list.push_back(_logic_comboBox);
QLineEdit *_value0_lineEdit = new QLineEdit("X X X X X X X X X X X X X X X X", this);
+ _value0_lineEdit->setFont(font);
_value0_lineEdit->setValidator(value_validator);
_value0_lineEdit->setMaxLength(TriggerProbes * 2 - 1);
_value0_lineEdit->setInputMask("X X X X X X X X X X X X X X X X");
@@ -89,6 +96,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) : _inv0_comboBox_list.push_back(_inv0_comboBox);
QLineEdit *_value1_lineEdit = new QLineEdit("X X X X X X X X X X X X X X X X", this);
+ _value1_lineEdit->setFont(font);
_value1_lineEdit->setValidator(value_validator);
_value1_lineEdit->setMaxLength(TriggerProbes * 2 - 1);
_value1_lineEdit->setInputMask("X X X X X X X X X X X X X X X X");
@@ -102,15 +110,14 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) : _inv1_comboBox->addItem(tr("!="));
_inv1_comboBox_list.push_back(_inv1_comboBox);
- QLabel *value_exp0_label = new QLabel("1 1 1 1 1 1", this);
- QLabel *value_exp1_label = new QLabel("5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0", this);
+ QLabel *value_exp_label = new QLabel("1 1 1 1 1 1\n5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0", this);
QLabel *inv_exp_label = new QLabel("Inv", this);
QLabel *count_exp_label = new QLabel("Counter", this);
+ value_exp_label->setFont(font);
QVBoxLayout *stage_layout = new QVBoxLayout();
QGridLayout *stage_glayout = new QGridLayout();
- stage_glayout->addWidget(value_exp0_label, 0, 0);
- stage_glayout->addWidget(value_exp1_label, 1, 0);
+ stage_glayout->addWidget(value_exp_label, 1, 0);
stage_glayout->addWidget(inv_exp_label, 1, 1);
stage_glayout->addWidget(count_exp_label, 1, 2);
stage_glayout->addWidget(_value0_lineEdit, 2, 0);
@@ -121,13 +128,8 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession &session) : stage_glayout->addWidget(_inv1_comboBox, 3, 1);
stage_glayout->addWidget(_count1_spinBox, 3, 2);
stage_layout->addLayout(stage_glayout);
- stage_layout->addSpacing(124);
- stage_layout->addWidget(new QLabel("X: Don't care"));
- stage_layout->addWidget(new QLabel("0: Low level"));
- stage_layout->addWidget(new QLabel("1: High level"));
- stage_layout->addWidget(new QLabel("R: Rising edge"));
- stage_layout->addWidget(new QLabel("F: Falling edge"));
- stage_layout->addWidget(new QLabel("C: Rising/Falling edge"));
+ stage_layout->addSpacing(160);
+ stage_layout->addWidget(new QLabel("X: Don't care\n0: Low level\n1: High level\nR: Rising edge\nF: Falling edge\nC: Rising/Falling edge"));
stage_layout->addStretch(1);
QGroupBox *_stage_groupBox = new QGroupBox("Stage"+QString::number(i), this);
|