3333#include < boost/foreach.hpp>
3434
3535#include < QDebug>
36+ #include < QTimer>
3637
3738using namespace boost ;
3839using 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-
961951bool 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
0 commit comments