Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some usability improvements, and fix some compiler warnings #172

Open
wants to merge 109 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b9335d0
Don't strip all optimization flags.
sandsmark Apr 3, 2021
6b1e3b6
add standard shortcut for quit action
sandsmark Apr 14, 2021
19e0fed
don't crash when failing to load the default list of waveforms
sandsmark Apr 14, 2021
51bf7de
add some missing keyboard accelerators
sandsmark Apr 14, 2021
2805c5e
fix warning of using uninitialized variable
sandsmark Apr 14, 2021
5b73248
feedback when failing to flash/fix warning about unused stored value
sandsmark Apr 14, 2021
7293fb4
fix clang warning about using int as bool
sandsmark Apr 14, 2021
d1e50af
fix uninitialized value (and remove some magic 'auto' variable)
sandsmark Apr 14, 2021
7bbf5d1
fix some minor warnings
sandsmark Apr 14, 2021
14b3b39
add dialog with pinout for easy access
sandsmark Apr 14, 2021
29a76c0
fix some type issues
sandsmark Apr 14, 2021
140873a
fix warning about unhandled enum values
sandsmark Apr 14, 2021
a9d04cb
don't emit code in all translation units, fix warning
sandsmark Apr 14, 2021
5960743
let clang-tidy clean up the int/bool issues
sandsmark Apr 14, 2021
319adfa
fix use of uninitialized memory
sandsmark Apr 14, 2021
2c04611
fix unused warning
sandsmark Apr 14, 2021
5772bd1
fix invalid format specifier
sandsmark Apr 14, 2021
3b29bfe
fix potential memory leak
sandsmark Apr 14, 2021
91ecafd
fix potential division by zero
sandsmark Apr 14, 2021
1064ac4
let clang-tidy do some minor performance improvements
sandsmark Apr 14, 2021
3e1dba0
final invalid type specifier, I think
sandsmark Apr 14, 2021
b75cb30
bundle default waveforms in the application binary
sandsmark Apr 15, 2021
cc041c3
port away from dangerous strcpy
sandsmark Apr 15, 2021
e661413
simplify the waveform reading and make it a bit more robust
sandsmark Apr 15, 2021
c97a2cc
fix minor compiler warnings
sandsmark Apr 15, 2021
d37e184
port away from some deprecated APIs
sandsmark Apr 15, 2021
6f9b062
fix using up/down keys in the spinboxes
sandsmark Apr 15, 2021
3c20332
port away from deprecated APIs, stop leaking memory
sandsmark Apr 15, 2021
39f0c9f
add button to automatically set ranges for what is on the screen
sandsmark Apr 15, 2021
a66ad5f
mis-groked the code
sandsmark Apr 18, 2021
403a989
remove some dead code
sandsmark Apr 18, 2021
d4dc2ee
minor issues
sandsmark Apr 18, 2021
526fdfb
replace magic numbers with enum
sandsmark Apr 18, 2021
f0f5fc8
fix some direct memory leak (should ideally be rewritten away from ra…
sandsmark Apr 18, 2021
4597487
fix remaining memory leaks, mostly by letting Qt handle it
sandsmark Apr 18, 2021
23b0b21
fix slot signature
sandsmark Apr 18, 2021
654a2f5
remove some dead code, fixes warnings
sandsmark Apr 18, 2021
d987273
fix another couple of warnings from Qt about unused slots
sandsmark Apr 18, 2021
92453ad
don't use raw pointers, fixes a race condition crash at exit
sandsmark Apr 18, 2021
4eaeffc
fix hanging on exit
sandsmark Apr 18, 2021
9a5e133
don't busyloop
sandsmark Apr 18, 2021
facfe3d
fix deprecated warnings in bundled version of qcustomplot
sandsmark Apr 18, 2021
ad64f1f
fix potential double free (really should port away from raw C buffers)
sandsmark Apr 18, 2021
9fb61b5
fix libusb shutdown
sandsmark Apr 18, 2021
2cd9f51
port to C++ smart pointers, avoids raw memory juggling and associated…
sandsmark Apr 18, 2021
aefa583
fix build with qcustomplot2
sandsmark Apr 20, 2021
446a1ca
allow building with system version of qcustomplot
sandsmark Apr 20, 2021
2594618
fix missing emits
sandsmark Apr 20, 2021
7460151
fix unused
sandsmark Apr 20, 2021
b3a8722
fix signedness
sandsmark Apr 20, 2021
81570aa
implement baudot decoding
sandsmark Apr 20, 2021
e99f003
fix some crashing
sandsmark Apr 22, 2021
ec4c5e9
port away from deprecated libusb API
sandsmark Apr 22, 2021
3f5604b
more usage of enums and flags to make code understandable
sandsmark Apr 24, 2021
35bed4c
fix memory leak
sandsmark Apr 24, 2021
f394ccd
clean up manual firmware recovery UI code a bit
sandsmark Apr 24, 2021
551c450
try to fix some issues with broken zooming
sandsmark Apr 24, 2021
ae6fb8e
.... old style signals and slots
sandsmark Apr 24, 2021
70c9707
more porting away from boolean traps
sandsmark Apr 24, 2021
f0205ea
fix some minor warnings
sandsmark Apr 24, 2021
c6fbd05
some memory safety
sandsmark Apr 24, 2021
0c78851
fix more magic numbers
sandsmark Apr 24, 2021
6e9f461
move DisplayControl class to separate files
sandsmark Apr 24, 2021
8c1d355
move zooming code out into separate functions
sandsmark Apr 24, 2021
6e5894e
fix whitespace, in separate commit for better history
sandsmark Apr 24, 2021
8ff4c86
more protection against division by zero
sandsmark Apr 24, 2021
ed40bd7
avoid including QWheelEvent in displaycontrol
sandsmark Apr 24, 2021
d529080
better naming
sandsmark Apr 24, 2021
760f67b
goddamn pixel/angle delta
sandsmark Apr 24, 2021
a400004
goddamn qt and stupid deprecations
sandsmark Apr 24, 2021
5866223
add some missing emits
sandsmark Apr 24, 2021
502c733
fix some connections
sandsmark Apr 24, 2021
d76ee6b
last of the connects (except the android code)
sandsmark Apr 24, 2021
685bfec
fix cursor text with QCP 2
sandsmark Apr 24, 2021
cb86884
fix build with system version of QCP
sandsmark Apr 24, 2021
3f5f8a9
start porting stuff away from shitty STL APIs so it is possible to debug
sandsmark Apr 24, 2021
8cc496e
clang-tidy
sandsmark Apr 24, 2021
1062db6
fix spin boxes not updating
sandsmark Apr 24, 2021
e04b5c5
clean up the shortcuts
sandsmark Apr 24, 2021
bc51416
fix division by zero
sandsmark Apr 24, 2021
e119cfe
proper default window size
sandsmark Apr 24, 2021
35aa228
add shortcut to zoom back out again
sandsmark Apr 24, 2021
06c23f6
I never which color is which
sandsmark Apr 24, 2021
1c211a5
try to improve the plotting
sandsmark Apr 24, 2021
3c063f6
need a better downsampling
sandsmark Apr 24, 2021
cfe2634
minor fixes
sandsmark Apr 24, 2021
4b4cd0d
fix building with old libusb versions
sandsmark May 9, 2021
8b01c52
fix assert on exit in libusb
sandsmark Apr 26, 2021
ad417bc
tradeoff a tiny bit of performance (5-10% on a 1.9GHz core)
sandsmark Apr 26, 2021
7d72b92
better default
sandsmark Apr 26, 2021
128a93c
memory safety
sandsmark May 1, 2021
1fa80e5
don't use zero for pointers
sandsmark May 1, 2021
7fdae93
fix the key event override when hovering the scope
sandsmark May 5, 2021
98bbf81
don't hardcode default values everywhere
sandsmark May 9, 2021
b909385
use just a single CONFIG option
sandsmark May 9, 2021
562613d
I think I finally found a usable method of downsampling with an OK tr…
sandsmark May 9, 2021
a45b82c
expose selecting downsampling method in the UI
sandsmark May 9, 2021
1132f81
whoops, should be in sync with UI
sandsmark May 9, 2021
c1c9eca
I'm not a smart person
sandsmark May 9, 2021
1d0e282
trigger works a bit more
sandsmark May 9, 2021
0bb3bbc
tiny performance improvement for trigger
sandsmark May 9, 2021
0e20265
fix trigger randomly not working with auto gain/changing gain
sandsmark May 9, 2021
079e081
the lack of emit markings was really confusing
sandsmark May 9, 2021
f5219d0
use nullptr
sandsmark May 9, 2021
c80f110
remove redundant void arguments
sandsmark May 9, 2021
867ffab
fix some minor clang warnings
sandsmark May 9, 2021
0ac0323
add some translucency to the plots, makes it a bit easier to see over…
sandsmark May 26, 2021
3af25e7
accelerator
sandsmark Jul 30, 2021
536da41
some cleanup
sandsmark Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Desktop_Interface/bin/Labrador
*.so
*.so.*
*.qmake.stash
pinout.png
/pinout.png
Matlab_Octave_API/___librador/build-librador-Desktop_Qt_5_10_0_GCC_64bit-Release
Matlab_Octave_API/___librador/build-librador-Desktop_Qt_5_10_0_GCC_64bit-Debug

Expand Down
108 changes: 108 additions & 0 deletions Desktop_Interface/DisplayControl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include "DisplayControl.h"

#include <qcustomplot.h>
#include <QDebug>

void DisplayControl::setVoltageRange (const QPointF &position, const QPoint zoomDelta, const Qt::KeyboardModifiers modifiers, bool isProperlyPaused, double maxWindowSize, QCustomPlot* axes)
{
const bool isVertical = qAbs(zoomDelta.y()) > qAbs(zoomDelta.x());
const bool isHorizontal = qAbs(zoomDelta.x()) > qAbs(zoomDelta.y());
if (!(modifiers == Qt::ControlModifier) && isVertical) {
zoomVertically(zoomDelta.y(), position.y(), axes);
} else if (isHorizontal) {
zoomHorizontally(zoomDelta.x(), position.x(), isProperlyPaused, maxWindowSize, axes);
}
}

void DisplayControl::zoomVertically(const double delta, const double y, QCustomPlot *axes)
{
if (qFuzzyIsNull(delta)) {
return;
}

double c;
if (qFuzzyIsNull(topRange) || qFuzzyIsNull(botRange) || qFuzzyCompare(topRange, botRange)) {
c = 1. / 400.;
} else {
c = (topRange - botRange) / 400.;
}

QCPRange range = axes->yAxis->range();

double pixPct = (double)100 - ((double)100 * (((double)axes->yAxis->pixelToCoord(y)-range.lower) / range.size()));
if (pixPct < 0) pixPct = 0;
if (pixPct > 100) pixPct = 100;

qDebug() << "WHEEL @ " << pixPct << "%";
qDebug() << range.upper;

topRange -= delta / 120.0 * c * pixPct;
botRange += delta / 120.0 * c * (100.0 - pixPct);

topRange = qMin(topRange, 20.);
botRange = qMin(botRange, 20.);

// Never allow 0 delta between top and bottom
if (qFuzzyCompare(topRange, botRange)) {
topRange += 0.01;
botRange -= 0.01;
}

emit topRangeUpdated(topRange);
emit botRangeUpdated(botRange);
}

void DisplayControl::zoomHorizontally(const double delta, const double x, bool isProperlyPaused, double maxWindowSize, QCustomPlot *axes)
{
if (qFuzzyIsNull(delta)) {
return;
}

double c;
if (qFuzzyIsNull(window)) {
c = 1. / 200.;
} else {
c = window / 200.;
}

QCPRange range = axes->xAxis->range();

double pixPct = 100. * (double(axes->xAxis->pixelToCoord(x)) - range.lower);

if (qFuzzyIsNull(window) || qFuzzyCompare(range.upper, range.lower)) {
pixPct = 1;
} else {
pixPct /= isProperlyPaused ? double(range.upper - range.lower)
: double(window);
}

pixPct = qBound(0., pixPct, 100.);

qDebug() << "WHEEL @ " << pixPct << "%";
qDebug() << delta;

if (! isProperlyPaused)
{
qDebug() << "TIGGERED";
qDebug() << "upper = " << range.upper << "lower = " << range.lower;
qDebug() << "window = " << window;
qDebug() << c * ((double)pixPct);
qDebug() << c * ((double)100 - (double)pixPct) * pixPct / 100;
}

window -= delta / 120.0 * c * pixPct;

delay += delta / 120.0 * c * (100.0 - pixPct) * pixPct / 100.0;
delay = qBound(0., delay, maxWindowSize - window);

if (window <= 0.) {
window = 0.01;
} else if (window > maxWindowSize) {
window = maxWindowSize;
}

qDebug() << window << delay;

emit delayUpdated(delay);
emit timeWindowUpdated(window);
}
33 changes: 33 additions & 0 deletions Desktop_Interface/DisplayControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include <QObject>

#include "desktop_settings.h"

class QCustomPlot;

class DisplayControl : public QObject
{
Q_OBJECT
public:

double delay = 0;
double window = MAX_WINDOW_SIZE;
double y0 = 0;
double y1 = 0;
double x0 = 0;
double x1 = 0;
double topRange = DEFAULT_TOP_RANGE;
double botRange = DEFAULT_BOTTOM_RANGE;

void setVoltageRange (const QPointF &position, const QPoint zoomDelta, const Qt::KeyboardModifiers modifiers, bool isProperlyPaused, double maxWindowSize, QCustomPlot* axes);

void zoomVertically(const double delta, const double y, QCustomPlot *axes);
void zoomHorizontally(const double delta, const double x, bool isProperlyPaused, double maxWindowSize, QCustomPlot* axes);

signals:
void topRangeUpdated(double);
void botRangeUpdated(double);
void timeWindowUpdated(double);
void delayUpdated(double);
};
117 changes: 56 additions & 61 deletions Desktop_Interface/Labrador.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@

QT += core gui

CONFIG += c++14
CONFIG += c++17

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

TARGET = Labrador
TEMPLATE = app

QCP_VER = 1

!contains(CONFIG, "USE_SYSTEM_LIBS") {
message("Using bundled version of qcustomplot")
QCP_VER = 1
} else {
message("Using system version of qcustomplot")
DEFINES += QCUSTOMPLOT_USE_OPENGL
QCP_VER = 2
LIBS += -lqcustomplot
}


DEFINES += "QCP_VER=$${QCP_VER}"
equals(QCP_VER,"2"){
DEFINES += QCUSTOMPLOT_USE_OPENGL
LIBS += -lOpenGL32
win32: LIBS += -lOpenGL32
message("Using QCP2 with OpenGL support")
}

Expand All @@ -31,11 +42,13 @@ include(ui_elements.pri)
MOC_DIR = $$PWD/moc

SOURCES += main.cpp\
DisplayControl.cpp \
mainwindow.cpp \
functiongencontrol.cpp \
isodriver.cpp \
isobuffer.cpp \
desktop_settings.cpp \
pinoutDialog.cpp \
scoperangeenterdialog.cpp \
genericusbdriver.cpp \
isobufferbuffer.cpp \
Expand All @@ -46,7 +59,9 @@ SOURCES += main.cpp\
i2cdecoder.cpp

HEADERS += mainwindow.h \
DisplayControl.h \
functiongencontrol.h \
pinoutDialog.h \
xmega.h \
isodriver.h \
isobuffer.h \
Expand Down Expand Up @@ -120,54 +135,58 @@ win32{

unix:!android:!macx{
INCLUDEPATH += $$PWD/build_linux
LIBS += -lusb-1.0 ##make sure you have the libusb-1.0-0-dev package!
LIBS += -ldfuprog-0.9

QMAKE_CXXFLAGS+=-O2

contains(QT_ARCH, arm) {
message("Building for Raspberry Pi")
#libusb include
unix:!android:!macx:LIBS += -lusb-1.0 ##make sure you have the libusb-1.0-0-dev package!
unix:!android:!macx:INCLUDEPATH += build_linux/libusb
unix:!android:!macx:DEPENDPATH += build_linux/libusb

#libdfuprog include
unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/arm -ldfuprog-0.9
unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include

#All ARM-Linux GCC treats char as unsigned by default???
QMAKE_CFLAGS += -fsigned-char
QMAKE_CXXFLAGS += -fsigned-char
DEFINES += "PLATFORM_RASPBERRY_PI"
#All ARM-Linux GCC treats char as unsigned by default???
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/arm/libdfuprog-0.9.so
lib_deploy.path = /usr/lib

!contains(CONFIG, "USE_SYSTEM_LIBS") {
LIBS += -L$$PWD/build_linux/libdfuprog/lib/arm
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/arm/libdfuprog-0.9.so
}

} else {
contains(QT_ARCH, i386) {
message("Building for Linux (x86)")
unix:!android:!macx:LIBS += -lusb-1.0 ##make sure you have the libusb-1.0-0-dev package!
unix:!android:!macx:INCLUDEPATH += build_linux/libusb
unix:!android:!macx:DEPENDPATH += build_linux/libusb

#libdfuprog include
unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/x86 -ldfuprog-0.9
unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/x86/libdfuprog-0.9.so
lib_deploy.path = /usr/lib

!contains(CONFIG, "USE_SYSTEM_LIBS") {
LIBS += -L$$PWD/build_linux/libdfuprog/lib/x86
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/x86/libdfuprog-0.9.so
}
} else {
message("Building for Linux (x64)")
#libusb include
unix:!android:!macx:LIBS += -Lbuild_linux/libusb -lusb-1.0 ##I suspect the -L here does nothing!
unix:!android:!macx:INCLUDEPATH += build_linux/libusb
unix:!android:!macx:DEPENDPATH += build_linux/libusb

#libdfuprog include
unix:!android:!macx:LIBS += -L$$PWD/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9
unix:!android:!macx:INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
unix:!android:!macx:DEPENDPATH += $$PWD/build_linux/libdfuprog/include
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/x64/libdfuprog-0.9.so
lib_deploy.path = /usr/lib
!contains(CONFIG, "USE_SYSTEM_LIBS") {
LIBS += -Lbuild_linux/libusb ##I suspect the -L here does nothing!
#libdfuprog include
LIBS += -L$$PWD/build_linux/libdfuprog/lib/x64
lib_deploy.files = $$PWD/build_linux/libdfuprog/lib/x64/libdfuprog-0.9.so
}
}
}


contains(CONFIG, "USE_SYSTEM_LIBS") {
message("Using system version of libusb")
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/include/libusb-1.0
} else {
INCLUDEPATH += build_linux/libusb
DEPENDPATH += build_linux/libusb

#libdfuprog include
INCLUDEPATH += $$PWD/build_linux/libdfuprog/include
DEPENDPATH += $$PWD/build_linux/libdfuprog/include

lib_deploy.path = /usr/lib
INSTALLS += lib_deploy
}

other.files += bin/firmware
other.files += bin/waveforms
other.path = /usr/bin/EspoTek-Labrador
Expand Down Expand Up @@ -205,7 +224,6 @@ unix:!android:!macx{
}

INSTALLS += target
INSTALLS += lib_deploy
INSTALLS += other
INSTALLS += udev
INSTALLS += icon48
Expand Down Expand Up @@ -250,29 +268,6 @@ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
unix:SOURCES += unixusbdriver.cpp
unix:HEADERS += unixusbdriver.h

#############################################################
######## SHARED ANDROID/LINUX GCC FLAGS #########
###########################################################

unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O0
unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O1
unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O2
unix:!macx: QMAKE_CXXFLAGS_RELEASE -= -O3

android: QMAKE_CXXFLAGS_RELEASE -= -O0
android: QMAKE_CXXFLAGS_RELEASE -= -O1
android: QMAKE_CXXFLAGS_RELEASE -= -O2
android: QMAKE_CXXFLAGS_RELEASE -= -O3
android: QMAKE_CXXFLAGS_RELEASE -= -Os


android: QMAKE_CFLAGS_RELEASE -= -O0
android: QMAKE_CFLAGS_RELEASE -= -O1
android: QMAKE_CFLAGS_RELEASE -= -O2
android: QMAKE_CFLAGS_RELEASE -= -O3
android: QMAKE_CFLAGS_RELEASE -= -Os


#############################################################
################# ANDROID BUILD ONLY #################
###########################################################
Expand Down
Loading