-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
127 lines (96 loc) · 2.76 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//******** mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QLabel>
#include <QMainWindow>
#include <QSerialPort>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
// two channels for data
struct WaveformData {
QVector<double> channel1;
QVector<double> channel2;
};
enum TriggerType {
NoTrigger,
RisingEdgeHighlighter,
FallingEdgeHighlighter,
TriggerLevel
};
struct OscilloscopeSettings {
TriggerType triggerType;
double triggerLevel;
};
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void initializeSerialCommunication();
private:
Ui::MainWindow *ui;
QSerialPort serial;
QTimer* updateTimer;
bool isRisingEdgeFound = false;
int risingEdgeTriggerLevel = -1;
// double previousLockingLevel = -1;
// bool lockingEnabled;
// int lockedRisingEdgeIndex = -1;
OscilloscopeSettings oscSettings; // Oscilloscope settings
TriggerType currentTriggerType = NoTrigger;
WaveformData waveformData;
WaveformData lockedWaveformData;
WaveformData currentBuffer;
WaveformData sampledData;
bool isSampling = false;
double triggerLevel = 0.0;
//bool isTrig1Set = false;
//bool isTrig2Set = false;
bool isTrig1Hit = false;
bool isTrig2Hit = false;
double zoomLevel = 30.0;
int shiftValue = 0;
// void setupOscilloscopeControls();
void applyTriggerSettings();
bool snapShot = false;
WaveformData snapShotData;
void analyzeWaveformData();
void onDataSliderInit();
//int timerId;
void smoothing();
double calculateWaveformSmoothness();
void smoothWaveformData(double windowSize);
private slots:
void onAutoSmoothChanged(int state);
void onBrowseFile();
QString isConnected();
void highlightRisingEdge();
void highlightFallingEdge();
void setTriggerLevel();
void drawWaveform(QLabel* label, const QVector<double>& data);
void generateWaveformData();
void onDataSliderChanged();
void onSnapshot();
void onClear();
void onPeek(const QString &addressStr, bool debug = true);
void onPoke(const QString &addressStr, const QString &dataStr, bool isHex, bool debug = true);
void onVersion();
void turnOnBoard();
void turnOffBoard();
void onZoomOut();
void onDefaultZoom();
void onZoomIn();
void onRefreshCOMPorts();
void updateWaveforms();
void onUpdateFirmware();
void updateStatusLabel(const QString &status);
void logInfo(const QString &message);
void onStartStopSampling();
void Sampling();
void initDMA();
// void updateTimerInterval();
protected:
// void timerEvent(QTimerEvent *event) override;
};
#endif // MAINWINDOW_H