Commit 95f2bf89 authored by DreamSourceLab's avatar DreamSourceLab

v0.3

parent a6a3024d
This diff is collapsed.
......@@ -85,8 +85,8 @@ set(DS_TITLE DSLogic)
set(DS_DESCRIPTION "A GUI for DSLogic")
set(DS_VERSION_MAJOR 0)
set(DS_VERSION_MINOR 2)
set(DS_VERSION_MICRO 1)
set(DS_VERSION_MINOR 3)
set(DS_VERSION_MICRO 0)
set(DS_VERSION_STRING
${DS_VERSION_MAJOR}.${DS_VERSION_MINOR}.${DS_VERSION_MICRO}
)
......@@ -156,6 +156,8 @@ set(DSLogic_SOURCES
pv/view/view.cpp
pv/view/viewport.cpp
pv/view/dsosignal.cpp
pv/view/dsldial.cpp
pv/dock/dsotriggerdock.cpp
)
set(DSLogic_HEADERS
......@@ -187,6 +189,8 @@ set(DSLogic_HEADERS
pv/view/view.h
pv/view/dsosignal.h
pv/view/viewport.h
pv/view/dsldial.h
pv/dock/dsotriggerdock.h
)
set(DSLogic_FORMS
......
-------------------------------------------------------------------------------
INSTALL
-------------------------------------------------------------------------------
Requirements
------------
- git
- g++
- make
- libtool
- pkg-config >= 0.22
- cmake >= 2.6
- libglib >= 2.28.0
- Qt >= 4.5
- libboost >= 1.42 (including the following libs):
- libboost-system
- libboost-thread
- libsigrok4DSLogic >= 0.2.0
Building and installing
-----------------------
Get the DSLogic-gui source code from: www.dreamsourcelab.com/download.html
In order to build it, run:
$ cd DSLogic-gui
$ cmake .
$ make
For installing PulseView:
$ make install
See the following wiki page for more (OS-specific) instructions:
http://sigrok.org/wiki/Building
Creating a source distribution package
--------------------------------------
In order to build a source package begin with an unconfigured source tree.
$ mkdir dist
$ cd dist
$ cmake ..
$ make package_source
-------------------------------------------------------------------------------
INSTALL
-------------------------------------------------------------------------------
Requirements
------------
- git
- g++
- make
- libtool
- pkg-config >= 0.22
- cmake >= 2.6
- libglib >= 2.28.0
- Qt >= 4.5
- libboost >= 1.42 (including the following libs):
- libboost-system
- libboost-thread
- libsigrok4DSLogic >= 0.2.0
Building and installing
-----------------------
Get the DSLogic-gui source code from: www.dreamsourcelab.com/download.html
In order to build it, run:
$ cd DSLogic-gui
$ cmake .
$ make
For installing PulseView:
$ make install
See the following wiki page for more (OS-specific) instructions:
http://sigrok.org/wiki/Building
Creating a source distribution package
--------------------------------------
In order to build a source package begin with an unconfigured source tree.
$ mkdir dist
$ cd dist
$ cmake ..
$ make package_source
0.1.0 (2013-12-15)
------------------
* Initial release.
0.1.0 (2013-12-15)
------------------
* Initial release.
/usr/local/bin/DSLogic
/usr/local/bin/res/DSLogic.fw
/usr/local/bin/res/DSLogic.bin
This diff is collapsed.
......@@ -70,8 +70,8 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso)
append_payload_to_envelope_levels();
}
const uint16_t* DsoSnapshot::get_samples(
int64_t start_sample, int64_t end_sample) const
const uint8_t *DsoSnapshot::get_samples(
int64_t start_sample, int64_t end_sample, uint16_t index) const
{
assert(start_sample >= 0);
assert(start_sample < (int64_t)get_sample_count());
......@@ -85,7 +85,7 @@ const uint16_t* DsoSnapshot::get_samples(
// memcpy(data, (uint16_t*)_data + start_sample, sizeof(uint16_t) *
// (end_sample - start_sample));
// return data;
return (uint16_t*)_data + start_sample;
return (uint8_t*)_data + start_sample * _channel_num + index;
}
void DsoSnapshot::get_envelope_section(EnvelopeSection &s,
......@@ -150,7 +150,7 @@ void DsoSnapshot::append_payload_to_envelope_levels()
dest_ptr = e0.samples + prev_length;
// Iterate through the samples to populate the first level mipmap
const uint16_t *const stop_src_ptr = (uint16_t*)_data +
const uint8_t *const stop_src_ptr = (uint8_t*)_data +
e0.length * EnvelopeScaleFactor * _channel_num;
// for (const uint16_t *src_ptr = (uint16_t*)_data +
// prev_length * EnvelopeScaleFactor;
......@@ -163,13 +163,13 @@ void DsoSnapshot::append_payload_to_envelope_levels()
// *dest_ptr++ = sub_sample;
// }
for (const uint16_t *src_ptr = (uint16_t*)_data +
for (const uint8_t *src_ptr = (uint8_t*)_data +
prev_length * EnvelopeScaleFactor * _channel_num + i;
src_ptr < stop_src_ptr; src_ptr += EnvelopeScaleFactor * _channel_num)
{
const uint16_t * begin_src_ptr =
const uint8_t * begin_src_ptr =
src_ptr;
const uint16_t *const end_src_ptr =
const uint8_t *const end_src_ptr =
src_ptr + EnvelopeScaleFactor * _channel_num;
EnvelopeSample sub_sample;
......
......@@ -40,8 +40,8 @@ class DsoSnapshot : public Snapshot
public:
struct EnvelopeSample
{
uint16_t min;
uint16_t max;
uint8_t min;
uint8_t max;
};
struct EnvelopeSection
......@@ -74,8 +74,8 @@ public:
void append_payload(const sr_datafeed_dso &dso);
const uint16_t* get_samples(int64_t start_sample,
int64_t end_sample) const;
const uint8_t* get_samples(int64_t start_sample,
int64_t end_sample, uint16_t index) const;
void get_envelope_section(EnvelopeSection &s,
uint64_t start, uint64_t end, float min_length, int probe_index) const;
......
......@@ -194,6 +194,7 @@ void DeviceOptions::disable_all_probes()
void DeviceOptions::mode_changed(QString mode)
{
(void)mode;
// Commit mode
sr_config_set(_sdi, SR_CONF_DEVICE_MODE, g_variant_new_string(_mode_comboBox.currentText().toLocal8Bit()));
setup_probes();
......
/*
* 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
/*
* 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
......@@ -57,6 +57,7 @@
#include "dock/protocoldock.h"
#include "dock/triggerdock.h"
#include "dock/dsotriggerdock.h"
#include "dock/measuredock.h"
#include "dock/searchdock.h"
......@@ -235,6 +236,14 @@ void MainWindow::setup_ui()
_trigger_widget = new dock::TriggerDock(_trigger_dock, _session);
_trigger_dock->setWidget(_trigger_widget);
_dso_trigger_dock=new QDockWidget(tr("Trigger Setting..."),this);
_dso_trigger_dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
_dso_trigger_dock->setAllowedAreas(Qt::RightDockWidgetArea);
_dso_trigger_dock->setVisible(false);
_dso_trigger_widget = new dock::DsoTriggerDock(_dso_trigger_dock, _session);
_dso_trigger_dock->setWidget(_dso_trigger_widget);
// Setup _view widget
_view = new pv::view::View(_session, this);
_vertical_layout->addWidget(_view);
......@@ -250,9 +259,9 @@ void MainWindow::setup_ui()
SLOT(update()));
connect(_sampling_bar, SIGNAL(device_reload()), this,
SLOT(init()));
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
addToolBar(_sampling_bar);
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
addToolBar(_sampling_bar);
addToolBar(_trig_bar);
addToolBar(_device_bar);
addToolBar(_file_bar);
......@@ -296,6 +305,7 @@ void MainWindow::setup_ui()
_trigger_dock->setObjectName(tr("triggerDock"));
addDockWidget(Qt::RightDockWidgetArea,_protocol_dock);
addDockWidget(Qt::RightDockWidgetArea,_trigger_dock);
addDockWidget(Qt::RightDockWidgetArea,_dso_trigger_dock);
addDockWidget(Qt::RightDockWidgetArea, _measure_dock);
addDockWidget(Qt::BottomDockWidgetArea, _search_dock);
......@@ -312,6 +322,8 @@ void MainWindow::setup_ui()
SLOT(device_detach()));
connect(&_session, SIGNAL(test_data_error()), this,
SLOT(test_data_error()));
connect(&_session, SIGNAL(dso_ch_changed(uint16_t)), this,
SLOT(dso_ch_changed(uint16_t)));
connect(_view, SIGNAL(cursor_update()), _measure_widget,
SLOT(cursor_update()));
......@@ -327,6 +339,14 @@ void MainWindow::init()
_trigger_widget->device_change();
if (_session.get_device())
_session.init_signals(_session.get_device());
if (_session.get_device()->mode == DSO) {
_sampling_bar->set_record_length(DefaultDSODepth*2);
_sampling_bar->set_sample_rate(DefaultDSORate*2);
_sampling_bar->enable_toggle(false);
_view->hDial_changed(0);
} else if(_session.get_device()->mode == LOGIC) {
_sampling_bar->enable_toggle(true);
}
}
void MainWindow::update()
......@@ -377,6 +397,8 @@ void MainWindow::update_device_list(struct sr_dev_inst *selected_device)
// #ifdef HAVE_LA_DSLOGIC
_session.start_hotplug_proc(boost::bind(&MainWindow::session_error, this,
QString("Hotplug failed"), _1));
_session.start_dso_ctrl_proc(boost::bind(&MainWindow::session_error, this,
QString("Hotplug failed"), _1));
// #endif
}
......@@ -446,11 +468,39 @@ void MainWindow::device_selected()
_sampling_bar->set_device(_device_bar->get_selected_device());
_sampling_bar->update_sample_rate_selector();
_view->show_trig_cursor(false);
_trigger_dock->setVisible(false);
_dso_trigger_dock->setVisible(false);
_protocol_dock->setVisible(false);
_measure_dock->setVisible(false);
_search_dock->setVisible(false);
init();
} else {
show_session_error("Open Device Failed",
"the selected device can't be opened!");
}
if (_device_bar->get_selected_device()->mode == DSO) {
QMessageBox msg(this);
msg.setText("Zero Adjustment");
msg.setInformativeText("Please left both of channels unconnect for zero adjustment!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
int ret = sr_config_set(_device_bar->get_selected_device(), SR_CONF_ZERO, g_variant_new_boolean(TRUE));
if (ret != SR_OK) {
QMessageBox msg(this);
msg.setText("Zero Adjustment Issue");
msg.setInformativeText("Can't send out the command of zero adjustment!");
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
} else {
run_stop();
g_usleep(100000);
run_stop();
}
}
}
void MainWindow::device_attach()
......@@ -508,6 +558,31 @@ void MainWindow::run_stop()
_sampling_bar->enable_run_stop(true);
}
void MainWindow::dso_ch_changed(uint16_t num)
{
if(num == 1) {
_sampling_bar->set_record_length(DefaultDSODepth*2);
_sampling_bar->set_sample_rate(DefaultDSORate*2);
_session.set_total_sample_len(_sampling_bar->get_record_length());
if (_session.get_capture_state() == SigSession::Running) {
_session.stop_capture();
_session.start_capture(_sampling_bar->get_record_length(),
boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
}
} else {
_sampling_bar->set_record_length(DefaultDSODepth);
_sampling_bar->set_sample_rate(DefaultDSORate);
_session.set_total_sample_len(_sampling_bar->get_record_length());
if (_session.get_capture_state() == SigSession::Running) {
_session.stop_capture();
_session.start_capture(_sampling_bar->get_record_length(),
boost::bind(&MainWindow::session_error, this,
QString("Capture failed"), _1));
}
}
}
void MainWindow::test_data_error()
{
_session.stop_capture();
......@@ -521,12 +596,14 @@ void MainWindow::test_data_error()
void MainWindow::capture_state_changed(int state)
{
_sampling_bar->enable_toggle(state != SigSession::Running);
_trig_bar->enable_toggle(state != SigSession::Running);
if (_session.get_device()->mode != DSO) {
_sampling_bar->enable_toggle(state != SigSession::Running);
_trig_bar->enable_toggle(state != SigSession::Running);
_measure_dock->widget()->setEnabled(state != SigSession::Running);
}
_device_bar->enable_toggle(state != SigSession::Running);
_file_bar->enable_toggle(state != SigSession::Running);
_sampling_bar->set_sampling(state == SigSession::Running);
_measure_dock->widget()->setEnabled(state != SigSession::Running);
_view->on_state_changed(state != SigSession::Running);
}
......@@ -537,7 +614,10 @@ void MainWindow::on_protocol(bool visible)
void MainWindow::on_trigger(bool visible)
{
_trigger_dock->setVisible(visible);
if (_session.get_device()->mode != DSO)
_trigger_dock->setVisible(visible);
else
_dso_trigger_dock->setVisible(visible);
}
void MainWindow::on_measure(bool visible)
......
......@@ -54,6 +54,7 @@ class LogoBar;
namespace dock{
class ProtocolDock;
class TriggerDock;
class DsoTriggerDock;
class MeasureDock;
class SearchDock;
}
......@@ -66,6 +67,10 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
private: