Improve autoset function under DSO mode

This commit is contained in:
DreamSourceLab 2018-05-26 21:53:53 +08:00
parent 62967edf88
commit e82536c7b1
12 changed files with 108 additions and 29 deletions

View File

@ -178,6 +178,14 @@ void DsoTriggerDock::paintEvent(QPaintEvent *)
// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void DsoTriggerDock::auto_trig(int index)
{
source_group->button(DSO_TRIGGER_AUTO)->setChecked(true);
channel_comboBox->setCurrentIndex(index);
source_changed();
channel_changed(index);
}
void DsoTriggerDock::pos_changed(int pos)
{
int ret;

View File

@ -54,6 +54,9 @@ public:
signals:
void set_trig_pos(int percent);
public slots:
void auto_trig(int index);
private slots:
void pos_changed(int pos);
void hold_changed(int hold);

View File

@ -184,6 +184,8 @@ void MainWindow::setup_ui()
SLOT(hide_calibration()));
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view,
SLOT(set_trig_pos(int)));
connect(_view, SIGNAL(auto_trig(int)), _dso_trigger_widget,
SLOT(auto_trig(int)));
setIconSize(QSize(40,40));
addToolBar(_sampling_bar);

View File

@ -578,6 +578,11 @@ void SamplingBar::on_samplecount_sel(int index)
sample_count_changed();
}
double SamplingBar::get_hori_res()
{
return _sample_count.itemData(_sample_count.currentIndex()).value<double>();
}
double SamplingBar::hori_knob(int dir)
{
double hori_res = -1;

View File

@ -90,6 +90,7 @@ public:
double hori_knob(int dir);
double commit_hori_res();
double get_hori_res();
public slots:
void set_sample_rate(uint64_t sample_rate);

View File

@ -33,6 +33,7 @@
#include <boost/foreach.hpp>
#include <QDebug>
#include <QTimer>
using namespace boost;
using namespace std;
@ -201,11 +202,11 @@ bool DsoSignal::go_vDialPre()
_scale *= pre_vdiv/_vDial->get_value();
update_vpos();
_view->update_calibration();
_view->set_update(_viewport, true);
_view->update();
//_view->set_update(_viewport, true);
//_view->update();
return true;
} else {
_autoV = false;
autoV_end();
return false;
}
}
@ -223,11 +224,11 @@ bool DsoSignal::go_vDialNext()
_scale *= pre_vdiv/_vDial->get_value();
update_vpos();
_view->update_calibration();
_view->set_update(_viewport, true);
_view->update();
//_view->set_update(_viewport, true);
//_view->update();
return true;
} else {
_autoV = false;
autoV_end();
return false;
}
}
@ -947,23 +948,13 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
p.drawText(x1_rect, Qt::AlignCenter | Qt::AlignVCenter, "x1");
}
bool DsoSignal::mouse_double_click(int right, const QPoint pt)
{
int y = get_zero_vpos();
const QRectF label_rect = Trace::get_rect("label", y, right);
if (label_rect.contains(pt)) {
this->auto_set();
return true;
}
return false;
}
bool DsoSignal::mouse_press(int right, const QPoint pt)
{
int y = get_y();
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
const QRectF acdc_rect = get_rect(DSO_ACDC, y, right);
const QRectF auto_rect = get_rect(DSO_AUTO, y, right);
const QRectF x1_rect = get_rect(DSO_X1, y, right);
const QRectF x10_rect = get_rect(DSO_X10, y, right);
const QRectF x100_rect = get_rect(DSO_X100, y, right);
@ -985,6 +976,8 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
set_acCoupling((get_acCoupling()+1)%2);
else
set_acCoupling((get_acCoupling()+1)%2);
} else if (auto_rect.contains(pt)) {
auto_start();
} else if (x1_rect.contains(pt)) {
set_factor(1);
} else if (x10_rect.contains(pt)) {
@ -1160,26 +1153,70 @@ void DsoSignal::paint_measure(QPainter &p)
}
p.setRenderHint(QPainter::Antialiasing, antialiasing);
if (_autoV) {
if (_view->session().get_capture_state() == SigSession::Stopped) {
if (_autoV)
autoV_end();
if (_autoH)
autoH_end();
}
if (_autoV && !_view->session().get_data_lock()) {
set_zero_vrate(0.5, true);
const uint8_t vscale = abs(_max - _min);
if (_max == 0xff || _min == 0x00 || vscale > 0xCC) {
go_vDialNext();
} else if (vscale > 0x33) {
_autoV = false;
autoV_end();
} else {
go_vDialPre();
}
}
if (_autoH && !_view->session().get_data_lock()) {
const double hori_res = _view->get_hori_res();
if (_period < 1.5*hori_res) {
_view->zoom(1);
} else if (_period > 6*hori_res) {
_view->zoom(-1);
} else {
autoH_end();
}
}
}
void DsoSignal::auto_set()
void DsoSignal::autoV_end()
{
if (_autoV | _autoH) {
_autoV = false;
_autoH = false;
} else {
_autoV = false;
_view->auto_trig(get_index());
_trig_value = (_min+_max)/2;
set_trig_vpos(get_trig_vpos(), true);
_view->set_update(_viewport, true);
_view->update();
}
void DsoSignal::autoH_end()
{
_autoH = false;
_view->set_update(_viewport, true);
_view->update();
}
void DsoSignal::auto_end()
{
if (_autoV)
autoV_end();
if (_autoH)
autoH_end();
}
void DsoSignal::auto_start()
{
if (_autoV || _autoH)
return;
if (_view->session().get_capture_state() == SigSession::Running) {
_autoV = true;
_autoH = true;
QTimer::singleShot(AutoTime, this, SLOT(auto_end()));
}
}

View File

@ -40,7 +40,7 @@ namespace view {
class DsoSignal : public Signal
{
//Q_OBJECT
Q_OBJECT
private:
static const QColor SignalColours[4];
@ -61,6 +61,7 @@ private:
static const int TrigMargin = 16;
static const int RefreshShort = 200;
static const int RefreshLong = 800;
static const int AutoTime = 10000;
public:
enum DsoSetRegions {
@ -129,7 +130,9 @@ public:
/**
* auto set the vertical and Horizontal scale
*/
void auto_set();
void auto_start();
void autoV_end();
void autoH_end();
/**
* Gets the mid-Y position of this signal.
@ -182,12 +185,13 @@ public:
QRectF get_rect(DsoSetRegions type, int y, int right);
bool mouse_double_click(int right, const QPoint pt);
bool mouse_press(int right, const QPoint pt);
bool mouse_wheel(int right, const QPoint pt, const int shift);
public slots:
void auto_end();
protected:
void paint_type_options(QPainter &p, int right, const QPoint pt);

View File

@ -52,6 +52,8 @@ namespace view {
class Signal : public Trace
{
Q_OBJECT
private:

View File

@ -252,6 +252,11 @@ void View::set_all_update(bool need_update)
viewport->set_need_update(need_update);
}
double View::get_hori_res()
{
return _sampling_bar->get_hori_res();
}
void View::update_hori_res()
{
if (_session.get_device()->dev_inst()->mode == DSO)

View File

@ -184,6 +184,7 @@ public:
int get_view_height();
void update_hori_res();
double get_hori_res();
QString get_measure(QString option);
@ -209,6 +210,8 @@ signals:
void resize();
void auto_trig(int index);
private:
void get_scroll_layout(int64_t &length, int64_t &offset) const;

View File

@ -902,6 +902,15 @@ void Viewport::wheelEvent(QWheelEvent *event)
}
}
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
assert(s);
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
dsoSig->auto_end();
}
}
measure();
}

View File

@ -187,7 +187,7 @@
#define DSCOPEC20_DEFAULT_VGAIN3 0x143D00
#define DSCOPEC20_DEFAULT_VGAIN4 0xAFC00
#define DSCOPEC20_DEFAULT_VGAIN5 0x7C000
#define DSCOPEC20_DEFAULT_VGAIN6 0x55000
#define DSCOPEC20_DEFAULT_VGAIN6 0x54E00
#define DSCOPEC20_DEFAULT_VGAIN7 0x2DD00
#define CALI_VGAIN_RANGE 100