From a0a1c9f0d429c690ebb6c79d438c51d86c57b541 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 6 Mar 2023 11:42:30 +0800 Subject: [PATCH] fix: The trigger waiting status text is flicker --- DSView/pv/view/viewport.cpp | 33 ++++++++++++++++++++++++++++----- DSView/pv/view/viewport.h | 7 +++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index 7fa16155..9d9af890 100644 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -92,6 +92,9 @@ Viewport::Viewport(View &parent, View_type type) : _clickX = 0; _sample_received = 0; + _lst_wait_tigger_time = high_resolution_clock::now(); + _tigger_wait_times = 0; + // drag inertial _drag_strength = 0; _drag_timer.setSingleShot(true); @@ -326,25 +329,44 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back) uint8_t type; bool roll = false; QString type_str=""; + GVariant *gvar = _view.session().get_device()->get_config(NULL, NULL, SR_CONF_ROLL); if (gvar != NULL) { roll = g_variant_get_boolean(gvar); g_variant_unref(gvar); } + gvar = _view.session().get_device()->get_config(NULL, NULL, SR_CONF_TRIGGER_SOURCE); if (gvar != NULL) { type = g_variant_get_byte(gvar); g_variant_unref(gvar); + if (type == DSO_TRIGGER_AUTO && roll) { type_str = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_AUTO_ROLL), "Auto(Roll)"); - } else if (type == DSO_TRIGGER_AUTO && !_view.session().trigd()) { + } + else if (type == DSO_TRIGGER_AUTO && !_view.session().trigd()) { type_str = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_AUTO), "Auto"); - } else if (_waiting_trig > 0) { + } + else if (_waiting_trig > 0) { type_str = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_WAITING_TRIG), "Waiting Trig"); - for (int i = 1; i < _waiting_trig; i++) - if (i % (WaitLoopTime / SigSession::FeedInterval) == 0) + + for (int i = 0; i < _tigger_wait_times; i++){ type_str += "."; - } else { + } + + high_resolution_clock::time_point cur_time = high_resolution_clock::now(); + milliseconds timeInterval = std::chrono::duration_cast(cur_time - _lst_wait_tigger_time); + int64_t time_keep = timeInterval.count(); + + if (time_keep >= 500){ + _tigger_wait_times++; + _lst_wait_tigger_time = cur_time; + } + + if (_tigger_wait_times > 4) + _tigger_wait_times = 0; + } + else { type_str = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIG_D), "Trig'd"); } } @@ -1195,6 +1217,7 @@ void Viewport::set_receive_len(quint64 length) if (length == 0) { _sample_received = 0; start_trigger_timer(333); + _tigger_wait_times = 0; } else { stop_trigger_timer(); diff --git a/DSView/pv/view/viewport.h b/DSView/pv/view/viewport.h index 10e99903..c5c60838 100644 --- a/DSView/pv/view/viewport.h +++ b/DSView/pv/view/viewport.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "../view/view.h" #include "../dsvdef.h" @@ -39,6 +40,9 @@ class QPainter; class QPaintEvent; class SigSession; +using std::chrono::high_resolution_clock; +using std::chrono::milliseconds; + namespace pv { namespace view { @@ -207,6 +211,9 @@ private: bool _curs_moved; bool _xcurs_moved; int _clickX; + + high_resolution_clock::time_point _lst_wait_tigger_time; + int _tigger_wait_times; }; } // namespace view