Skip to content

Commit e82536c

Browse files
Improve autoset function under DSO mode
1 parent 62967ed commit e82536c

File tree

12 files changed

+108
-29
lines changed

12 files changed

+108
-29
lines changed

DSView/pv/dock/dsotriggerdock.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ void DsoTriggerDock::paintEvent(QPaintEvent *)
178178
// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
179179
}
180180

181+
void DsoTriggerDock::auto_trig(int index)
182+
{
183+
source_group->button(DSO_TRIGGER_AUTO)->setChecked(true);
184+
channel_comboBox->setCurrentIndex(index);
185+
source_changed();
186+
channel_changed(index);
187+
}
188+
181189
void DsoTriggerDock::pos_changed(int pos)
182190
{
183191
int ret;

DSView/pv/dock/dsotriggerdock.h

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class DsoTriggerDock : public QScrollArea
5454
signals:
5555
void set_trig_pos(int percent);
5656

57+
public slots:
58+
void auto_trig(int index);
59+
5760
private slots:
5861
void pos_changed(int pos);
5962
void hold_changed(int hold);

DSView/pv/mainwindow.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ void MainWindow::setup_ui()
184184
SLOT(hide_calibration()));
185185
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view,
186186
SLOT(set_trig_pos(int)));
187+
connect(_view, SIGNAL(auto_trig(int)), _dso_trigger_widget,
188+
SLOT(auto_trig(int)));
187189

188190
setIconSize(QSize(40,40));
189191
addToolBar(_sampling_bar);

DSView/pv/toolbars/samplingbar.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ void SamplingBar::on_samplecount_sel(int index)
578578
sample_count_changed();
579579
}
580580

581+
double SamplingBar::get_hori_res()
582+
{
583+
return _sample_count.itemData(_sample_count.currentIndex()).value<double>();
584+
}
585+
581586
double SamplingBar::hori_knob(int dir)
582587
{
583588
double hori_res = -1;

DSView/pv/toolbars/samplingbar.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class SamplingBar : public QToolBar
9090

9191
double hori_knob(int dir);
9292
double commit_hori_res();
93+
double get_hori_res();
9394

9495
public slots:
9596
void set_sample_rate(uint64_t sample_rate);

DSView/pv/view/dsosignal.cpp

+61-24
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <boost/foreach.hpp>
3434

3535
#include <QDebug>
36+
#include <QTimer>
3637

3738
using namespace boost;
3839
using namespace std;
@@ -201,11 +202,11 @@ bool DsoSignal::go_vDialPre()
201202
_scale *= pre_vdiv/_vDial->get_value();
202203
update_vpos();
203204
_view->update_calibration();
204-
_view->set_update(_viewport, true);
205-
_view->update();
205+
//_view->set_update(_viewport, true);
206+
//_view->update();
206207
return true;
207208
} else {
208-
_autoV = false;
209+
autoV_end();
209210
return false;
210211
}
211212
}
@@ -223,11 +224,11 @@ bool DsoSignal::go_vDialNext()
223224
_scale *= pre_vdiv/_vDial->get_value();
224225
update_vpos();
225226
_view->update_calibration();
226-
_view->set_update(_viewport, true);
227-
_view->update();
227+
//_view->set_update(_viewport, true);
228+
//_view->update();
228229
return true;
229230
} else {
230-
_autoV = false;
231+
autoV_end();
231232
return false;
232233
}
233234
}
@@ -947,23 +948,13 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
947948
p.drawText(x1_rect, Qt::AlignCenter | Qt::AlignVCenter, "x1");
948949
}
949950

950-
bool DsoSignal::mouse_double_click(int right, const QPoint pt)
951-
{
952-
int y = get_zero_vpos();
953-
const QRectF label_rect = Trace::get_rect("label", y, right);
954-
if (label_rect.contains(pt)) {
955-
this->auto_set();
956-
return true;
957-
}
958-
return false;
959-
}
960-
961951
bool DsoSignal::mouse_press(int right, const QPoint pt)
962952
{
963953
int y = get_y();
964954
const QRectF vDial_rect = get_rect(DSO_VDIAL, y, right);
965955
const QRectF chEn_rect = get_rect(DSO_CHEN, y, right);
966956
const QRectF acdc_rect = get_rect(DSO_ACDC, y, right);
957+
const QRectF auto_rect = get_rect(DSO_AUTO, y, right);
967958
const QRectF x1_rect = get_rect(DSO_X1, y, right);
968959
const QRectF x10_rect = get_rect(DSO_X10, y, right);
969960
const QRectF x100_rect = get_rect(DSO_X100, y, right);
@@ -985,6 +976,8 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
985976
set_acCoupling((get_acCoupling()+1)%2);
986977
else
987978
set_acCoupling((get_acCoupling()+1)%2);
979+
} else if (auto_rect.contains(pt)) {
980+
auto_start();
988981
} else if (x1_rect.contains(pt)) {
989982
set_factor(1);
990983
} else if (x10_rect.contains(pt)) {
@@ -1160,26 +1153,70 @@ void DsoSignal::paint_measure(QPainter &p)
11601153
}
11611154
p.setRenderHint(QPainter::Antialiasing, antialiasing);
11621155

1163-
if (_autoV) {
1156+
if (_view->session().get_capture_state() == SigSession::Stopped) {
1157+
if (_autoV)
1158+
autoV_end();
1159+
if (_autoH)
1160+
autoH_end();
1161+
}
1162+
1163+
if (_autoV && !_view->session().get_data_lock()) {
1164+
set_zero_vrate(0.5, true);
11641165
const uint8_t vscale = abs(_max - _min);
11651166
if (_max == 0xff || _min == 0x00 || vscale > 0xCC) {
11661167
go_vDialNext();
11671168
} else if (vscale > 0x33) {
1168-
_autoV = false;
1169+
autoV_end();
11691170
} else {
11701171
go_vDialPre();
11711172
}
11721173
}
1174+
1175+
if (_autoH && !_view->session().get_data_lock()) {
1176+
const double hori_res = _view->get_hori_res();
1177+
if (_period < 1.5*hori_res) {
1178+
_view->zoom(1);
1179+
} else if (_period > 6*hori_res) {
1180+
_view->zoom(-1);
1181+
} else {
1182+
autoH_end();
1183+
}
1184+
}
11731185
}
11741186

1175-
void DsoSignal::auto_set()
1187+
void DsoSignal::autoV_end()
11761188
{
1177-
if (_autoV | _autoH) {
1178-
_autoV = false;
1179-
_autoH = false;
1180-
} else {
1189+
_autoV = false;
1190+
_view->auto_trig(get_index());
1191+
_trig_value = (_min+_max)/2;
1192+
set_trig_vpos(get_trig_vpos(), true);
1193+
_view->set_update(_viewport, true);
1194+
_view->update();
1195+
}
1196+
1197+
void DsoSignal::autoH_end()
1198+
{
1199+
_autoH = false;
1200+
_view->set_update(_viewport, true);
1201+
_view->update();
1202+
}
1203+
1204+
void DsoSignal::auto_end()
1205+
{
1206+
if (_autoV)
1207+
autoV_end();
1208+
if (_autoH)
1209+
autoH_end();
1210+
}
1211+
1212+
void DsoSignal::auto_start()
1213+
{
1214+
if (_autoV || _autoH)
1215+
return;
1216+
if (_view->session().get_capture_state() == SigSession::Running) {
11811217
_autoV = true;
11821218
_autoH = true;
1219+
QTimer::singleShot(AutoTime, this, SLOT(auto_end()));
11831220
}
11841221
}
11851222

DSView/pv/view/dsosignal.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace view {
4040

4141
class DsoSignal : public Signal
4242
{
43-
//Q_OBJECT
43+
Q_OBJECT
4444

4545
private:
4646
static const QColor SignalColours[4];
@@ -61,6 +61,7 @@ class DsoSignal : public Signal
6161
static const int TrigMargin = 16;
6262
static const int RefreshShort = 200;
6363
static const int RefreshLong = 800;
64+
static const int AutoTime = 10000;
6465

6566
public:
6667
enum DsoSetRegions {
@@ -129,7 +130,9 @@ class DsoSignal : public Signal
129130
/**
130131
* auto set the vertical and Horizontal scale
131132
*/
132-
void auto_set();
133+
void auto_start();
134+
void autoV_end();
135+
void autoH_end();
133136

134137
/**
135138
* Gets the mid-Y position of this signal.
@@ -182,12 +185,13 @@ class DsoSignal : public Signal
182185

183186
QRectF get_rect(DsoSetRegions type, int y, int right);
184187

185-
bool mouse_double_click(int right, const QPoint pt);
186-
187188
bool mouse_press(int right, const QPoint pt);
188189

189190
bool mouse_wheel(int right, const QPoint pt, const int shift);
190191

192+
public slots:
193+
void auto_end();
194+
191195
protected:
192196
void paint_type_options(QPainter &p, int right, const QPoint pt);
193197

DSView/pv/view/signal.h

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ namespace view {
5252

5353
class Signal : public Trace
5454
{
55+
Q_OBJECT
56+
5557
private:
5658

5759

DSView/pv/view/view.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ void View::set_all_update(bool need_update)
252252
viewport->set_need_update(need_update);
253253
}
254254

255+
double View::get_hori_res()
256+
{
257+
return _sampling_bar->get_hori_res();
258+
}
259+
255260
void View::update_hori_res()
256261
{
257262
if (_session.get_device()->dev_inst()->mode == DSO)

DSView/pv/view/view.h

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class View : public QScrollArea {
184184
int get_view_height();
185185

186186
void update_hori_res();
187+
double get_hori_res();
187188

188189
QString get_measure(QString option);
189190

@@ -209,6 +210,8 @@ class View : public QScrollArea {
209210

210211
void resize();
211212

213+
void auto_trig(int index);
214+
212215
private:
213216
void get_scroll_layout(int64_t &length, int64_t &offset) const;
214217

DSView/pv/view/viewport.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,15 @@ void Viewport::wheelEvent(QWheelEvent *event)
902902
}
903903
}
904904

905+
const vector< boost::shared_ptr<Signal> > sigs(_view.session().get_signals());
906+
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
907+
assert(s);
908+
boost::shared_ptr<view::DsoSignal> dsoSig;
909+
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
910+
dsoSig->auto_end();
911+
}
912+
}
913+
905914
measure();
906915
}
907916

libsigrok4DSL/hardware/DSL/dsl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
#define DSCOPEC20_DEFAULT_VGAIN3 0x143D00
188188
#define DSCOPEC20_DEFAULT_VGAIN4 0xAFC00
189189
#define DSCOPEC20_DEFAULT_VGAIN5 0x7C000
190-
#define DSCOPEC20_DEFAULT_VGAIN6 0x55000
190+
#define DSCOPEC20_DEFAULT_VGAIN6 0x54E00
191191
#define DSCOPEC20_DEFAULT_VGAIN7 0x2DD00
192192

193193
#define CALI_VGAIN_RANGE 100

0 commit comments

Comments
 (0)