-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmainwindow.h
137 lines (109 loc) · 2.73 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
128
129
130
131
132
133
134
135
136
137
/*
* STM32Programming
*
* Copyright 2015 - 2020 yangfuyuan
*
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSerialPortInfo>
#include "sdk/include/stm32_bootloader.h"
#include "elapsedtimer.h"
using namespace stm32;
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
enum AppState
{
IDLE = 0,
INITIALED = 1,
READING = 2,
WRITING = 3,
VERIFYING = 4,
CANCELED = 5,
EXIT = 6,
};
enum MessageLevel
{
INFO = 0,
WARNING = 1,
CRITICAL = 2
};
enum actions
{
ACT_NONE,
ACT_READ,
ACT_WRITE,
ACT_WRITE_UNPROTECT,
ACT_READ_PROTECT,
ACT_READ_UNPROTECT,
ACT_ERASE_ONLY,
ACT_CRC
};
void closeEvent(QCloseEvent *event);
void initialParamters();
void initialObject();
void initialSignalSlot();
protected slots:
void on_tbBrowse_clicked();
void on_bCancel_clicked();
void on_bWrite_clicked();
void on_bRead_clicked();
private slots:
void on_bDevice_clicked();
void on_ClearBtn_clicked();
void on_SaveBtn_clicked();
void on_deleteBtn_clicked();
void on_ConnectBtn_clicked(bool checked);
void on_bVerfiy_toggled(bool checked);
void on_bSkip_toggled(bool checked);
void on_bRun_toggled(bool checked);
void userOperator(const QString &filename);
signals:
void logView(const QString &info, int level);
void dataProcessSignal(int value, int total);
void taskFininshedSignal();
private:
void wait_ms(unsigned long time);
private:
// find attached devices
void setReadWriteButtonState(bool state);
void setConnectButtonState(bool state);
void loginfo(const std::string &info, int level);
void logMessage(QString str, QString tag, MessageLevel level);
void enabled(bool enable);
void bootloader(const QString &filename);
private slots:
void logInfoSlot(const QString &info, int level);
void dataProcessSlot(int value, int total);
void taskFininshed();
private:
Ui::MainWindow *ui;
AppState m_state;
ElapsedTimer *elapsed_timer;
enum actions m_action;
stm32_info stm;
QMutex operator_mutex;
int npages;
int spage;
bool no_erase;
bool verify;
int retry;
bool exec_flag;
uint32_t execute;
char init_flag;
char force_binary;
char reset_flag;
uint32_t start_addr;
uint32_t readwrite_len;
};
#endif // MAINWINDOW_H