33
33
#include < boost/foreach.hpp>
34
34
35
35
#include < QDebug>
36
+ #include < QTimer>
36
37
37
38
using namespace boost ;
38
39
using namespace std ;
@@ -201,11 +202,11 @@ bool DsoSignal::go_vDialPre()
201
202
_scale *= pre_vdiv/_vDial->get_value ();
202
203
update_vpos ();
203
204
_view->update_calibration ();
204
- _view->set_update (_viewport, true );
205
- _view->update ();
205
+ // _view->set_update(_viewport, true);
206
+ // _view->update();
206
207
return true ;
207
208
} else {
208
- _autoV = false ;
209
+ autoV_end () ;
209
210
return false ;
210
211
}
211
212
}
@@ -223,11 +224,11 @@ bool DsoSignal::go_vDialNext()
223
224
_scale *= pre_vdiv/_vDial->get_value ();
224
225
update_vpos ();
225
226
_view->update_calibration ();
226
- _view->set_update (_viewport, true );
227
- _view->update ();
227
+ // _view->set_update(_viewport, true);
228
+ // _view->update();
228
229
return true ;
229
230
} else {
230
- _autoV = false ;
231
+ autoV_end () ;
231
232
return false ;
232
233
}
233
234
}
@@ -947,23 +948,13 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
947
948
p.drawText (x1_rect, Qt::AlignCenter | Qt::AlignVCenter, " x1" );
948
949
}
949
950
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
-
961
951
bool DsoSignal::mouse_press (int right, const QPoint pt)
962
952
{
963
953
int y = get_y ();
964
954
const QRectF vDial_rect = get_rect (DSO_VDIAL, y, right);
965
955
const QRectF chEn_rect = get_rect (DSO_CHEN, y, right);
966
956
const QRectF acdc_rect = get_rect (DSO_ACDC, y, right);
957
+ const QRectF auto_rect = get_rect (DSO_AUTO, y, right);
967
958
const QRectF x1_rect = get_rect (DSO_X1, y, right);
968
959
const QRectF x10_rect = get_rect (DSO_X10, y, right);
969
960
const QRectF x100_rect = get_rect (DSO_X100, y, right);
@@ -985,6 +976,8 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
985
976
set_acCoupling ((get_acCoupling ()+1 )%2 );
986
977
else
987
978
set_acCoupling ((get_acCoupling ()+1 )%2 );
979
+ } else if (auto_rect.contains (pt)) {
980
+ auto_start ();
988
981
} else if (x1_rect.contains (pt)) {
989
982
set_factor (1 );
990
983
} else if (x10_rect.contains (pt)) {
@@ -1160,26 +1153,70 @@ void DsoSignal::paint_measure(QPainter &p)
1160
1153
}
1161
1154
p.setRenderHint (QPainter::Antialiasing, antialiasing);
1162
1155
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 );
1164
1165
const uint8_t vscale = abs (_max - _min);
1165
1166
if (_max == 0xff || _min == 0x00 || vscale > 0xCC ) {
1166
1167
go_vDialNext ();
1167
1168
} else if (vscale > 0x33 ) {
1168
- _autoV = false ;
1169
+ autoV_end () ;
1169
1170
} else {
1170
1171
go_vDialPre ();
1171
1172
}
1172
1173
}
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
+ }
1173
1185
}
1174
1186
1175
- void DsoSignal::auto_set ()
1187
+ void DsoSignal::autoV_end ()
1176
1188
{
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) {
1181
1217
_autoV = true ;
1182
1218
_autoH = true ;
1219
+ QTimer::singleShot (AutoTime, this , SLOT (auto_end ()));
1183
1220
}
1184
1221
}
1185
1222
0 commit comments