2
0
forked from Ivasoft/DSView

add: Reduce the rolling trigger sensitivity of logic analyzer

This commit is contained in:
dreamsourcelabTAI
2022-04-15 15:51:36 +08:00
parent 84ed78c876
commit f5bc2b1ee7
11 changed files with 70 additions and 41 deletions

View File

@@ -26,6 +26,7 @@
#include <QDir>
#include <QCoreApplication>
#include <QDebug>
#include <QWidget>
#include "devicemanager.h"
#include "sigsession.h"
@@ -35,7 +36,8 @@
AppControl::AppControl()
{
sr_ctx = NULL;
_topWindow = NULL;
_device_manager = new pv::DeviceManager();
_session = new pv::SigSession(_device_manager);
}
@@ -149,3 +151,11 @@ const char *AppControl::GetLastError()
sr_log_loglevel_set(level);
srd_log_loglevel_set(level);
}
bool AppControl::TopWindowIsMaximized()
{
if (_topWindow != NULL){
return _topWindow->isMaximized();
}
return false;
}

View File

@@ -24,6 +24,7 @@
#include <string>
struct sr_context;
class QWidget;
namespace pv{
class DeviceManager;
@@ -54,11 +55,23 @@ public:
void SetLogLevel(int level);
inline pv::SigSession* GetSession()
{ return _session;}
inline pv::SigSession* GetSession(){
return _session;
}
inline pv::DeviceManager& GetDeviceManager()
{ return *_device_manager;}
inline pv::DeviceManager& GetDeviceManager(){
return *_device_manager;
}
inline void SetTopWindow(QWidget *w){
_topWindow = w;
}
inline QWidget* GetTopWindow(){
return _topWindow;
}
bool TopWindowIsMaximized();
public:
std::string _open_file_name;
@@ -68,4 +81,5 @@ private:
struct sr_context *sr_ctx;
pv::DeviceManager *_device_manager;
pv::SigSession *_session;
QWidget *_topWindow;
};

View File

@@ -62,23 +62,6 @@ namespace DecoderDataFormat
namespace app
{
QWidget* get_app_window_instance(QWidget *ins, bool bSet){
static QWidget *g_ins = NULL;
if (bSet){
g_ins = ins;
}
return g_ins;
}
bool is_app_top_window(QWidget* w){
QWidget *top =get_app_window_instance(NULL, NULL);
if (top && top == w){
return true;
}
return false;
}
void set_utf8(QTextStream &stream){
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
stream.setEncoding(QStringConverter::Utf8);

View File

@@ -53,7 +53,7 @@ class QTextStream;
#define RELEASE_ARRAY(a) for (auto ptr : (a)){delete ptr;} (a).clear();
#define ABS_VAL(x) (x>0?x:-x)
#define ABS_VAL(x) ((x) > 0 ? (x) : -(x))
namespace DecoderDataFormat
{
@@ -71,10 +71,6 @@ namespace DecoderDataFormat
namespace app
{
QWidget* get_app_window_instance(QWidget *ins, bool bSet);
bool is_app_top_window(QWidget* w);
void set_utf8(QTextStream &stream);
}

View File

@@ -47,6 +47,7 @@
#include "dsvdef.h"
#include "config/appconfig.h"
#include "ui/msgbox.h"
#include "appcontrol.h"
#include <algorithm>
@@ -61,6 +62,8 @@ MainFrame::MainFrame()
_titleBar = NULL;
_mainWindow = NULL;
AppControl::Instance()->SetTopWindow(this);
setAttribute(Qt::WA_TranslucentBackground);
// Make this a borderless window which can't
// be resized or moved via the window system
@@ -77,8 +80,6 @@ MainFrame::MainFrame()
QIcon icon;
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
setWindowIcon(icon);
app::get_app_window_instance(this, true);
// Title
_titleBar = new toolbars::TitleBar(true, this);

View File

@@ -103,7 +103,7 @@ MainWindow::MainWindow(QWidget *parent) :
_msg(NULL)
{
_control = AppControl::Instance();
_control->GetSession()->set_callback(this);
_control->GetSession()->set_callback(this);
_bFirstLoad = true;
setup_ui();

View File

@@ -32,6 +32,7 @@
#include <QStyleOption>
#include <assert.h>
#include "../config/appconfig.h"
#include "../appcontrol.h"
#include "../dsvdef.h"
@@ -192,7 +193,8 @@ void TitleBar::mousePressEvent(QMouseEvent* event)
{
int x = event->pos().x();
int y = event->pos().y();
bool bTopWidow = app::is_app_top_window(_parent);
bool bTopWidow = AppControl::Instance()->GetTopWindow() == _parent;
bool bClick = (x >= 6 && y >= 5 && x <= width() - 6); //top window need resize hit check
if (!bTopWidow || bClick ){

View File

@@ -25,6 +25,7 @@
#include <QMessageBox>
#include <QString>
#include "../dsvdef.h"
#include "../appcontrol.h"
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No);
@@ -40,7 +41,7 @@ void MsgBox::Show(const char *title, const char *text, QWidget *parent)
str.append(text);
if (parent == NULL){
parent = app::get_app_window_instance(NULL, false);
parent = AppControl::Instance()->GetTopWindow();
}
pv::dialogs::DSMessageBox msg(parent, title);
@@ -59,8 +60,8 @@ bool MsgBox::Confirm(const char *text, QWidget *parent)
str.append("\n");
str.append(text);
if (parent == NULL){
parent = app::get_app_window_instance(NULL, false);
if (parent == NULL){
parent = AppControl::Instance()->GetTopWindow();
}
pv::dialogs::DSMessageBox msg(parent, "Question");

View File

@@ -44,6 +44,7 @@
#include "../config/appconfig.h"
#include "../dsvdef.h"
#include "../appcontrol.h"
using namespace std;
@@ -88,6 +89,7 @@ Viewport::Viewport(View &parent, View_type type) :
_edge_hit = false;
transfer_started = false;
timer_cnt = 0;
_clickX = 0;
// drag inertial
_drag_strength = 0;
@@ -499,6 +501,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
{
assert(event);
_clickX = event->globalPos().x();
_mouse_down_point = event->pos();
_mouse_down_offset = _view.offset();
_drag_strength = 0;
@@ -757,6 +760,9 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
void Viewport::mouseReleaseEvent(QMouseEvent *event)
{
assert(event);
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll;
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
if (_type != TIME_VIEW){
update();
@@ -769,7 +775,22 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_view.session().get_capture_state() == SigSession::Stopped) {
//priority 1
//try to quick scroll view...
if (_action_type == NO_ACTION && AppConfig::Instance()._appOptions.quickScroll) {
int curX = event->globalPos().x();
int moveLong = ABS_VAL(curX - _clickX);
int maxWidth = this->geometry().width();
float mvk = (float) moveLong / (float)maxWidth;
if (quickScroll){
quickScroll = false;
if (isMaxWindow && mvk > 0.5f){
quickScroll = true;
}
else if (!isMaxWindow && mvk > 0.6f){
quickScroll = true;
}
}
if (_action_type == NO_ACTION && quickScroll) {
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
if (_elapsed_time.elapsed() < 200 &&
abs(_drag_strength) < MinorDragOffsetUp &&

View File

@@ -217,10 +217,11 @@ private:
int _dso_ym_start;
int _dso_ym_end;
int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
bool _xcurs_moved;
int _waiting_trig;
bool _dso_trig_moved;
bool _curs_moved;
bool _xcurs_moved;
int _clickX;
};
} // namespace view

View File

@@ -134,8 +134,8 @@ class Decoder(srd.Decoder):
# 解码函数解码任务开始时由c底层代码调用
# 这里不断循环等待所有采样数据被处理完成
# 下面的例代码是想以一对向上边沿向下边沿,输出它们的样品位置差值,
# 同时奇数次显示第二行,偶数次显示在第一行,我们只指定annotations里定义的序号
# 下面的例代码是解析某一通道的数据,从向上边沿开始到向下边沿结束,输出它们的样品位置差值,
# 奇数次显示第二行偶数次显示在第一行我们只指定annotations里定义的序号
# 软件会自动根据annotation_rows的设置决定显示在哪一行
def decode(self):
# 次数计数