-
Notifications
You must be signed in to change notification settings - Fork 10
/
guiwindow.h
276 lines (185 loc) · 6.72 KB
/
guiwindow.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/* OpenFIRE App: a configuration utility for the OpenFIRE light gun system.
Copyright (C) 2024 Team OpenFIRE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GUIWINDOW_H
#define GUIWINDOW_H
#include "constants.h"
#include <QMainWindow>
#include <QSerialPort>
#include <QGraphicsItem>
#include <QPen>
#include <QTimer>
QT_BEGIN_NAMESPACE
namespace Ui {
class guiWindow;
}
QT_END_NAMESPACE
class guiWindow : public QMainWindow
{
Q_OBJECT
public:
guiWindow(QWidget *parent = nullptr);
~guiWindow();
QSerialPort serialPort;
bool serialActive = false;
private slots:
void aliveTimer_timeout();
void on_comPortSelector_currentIndexChanged(int index);
void on_confirmButton_clicked();
void serialPort_readyRead();
void pinBoxes_activated(int index);
void renameBoxes_clicked();
void colorBoxes_clicked();
void layoutBoxes_activated(int arg1);
void irBoxes_activated(int index);
void runModeBoxes_activated(int index);
void on_customPinsEnabled_stateChanged(int arg1);
void on_presetsBox_currentIndexChanged(int index);
void on_rumbleTestBtn_clicked();
void on_solenoidTestBtn_clicked();
void on_baudResetBtn_clicked();
void on_rumbleToggle_stateChanged(int arg1);
void on_solenoidToggle_stateChanged(int arg1);
void on_autofireToggle_stateChanged(int arg1);
void on_simplePauseToggle_stateChanged(int arg1);
void on_holdToPauseToggle_stateChanged(int arg1);
void on_commonAnodeToggle_stateChanged(int arg1);
void on_lowButtonsToggle_stateChanged(int arg1);
void on_rumbleFFToggle_stateChanged(int arg1);
void on_rumbleIntensityBox_valueChanged(int arg1);
void on_rumbleLengthBox_valueChanged(int arg1);
void on_holdToPauseLengthBox_valueChanged(int arg1);
void on_solenoidNormalIntervalBox_valueChanged(int arg1);
void on_solenoidFastIntervalBox_valueChanged(int arg1);
void on_solenoidHoldLengthBox_valueChanged(int arg1);
void on_autofireWaitFactorBox_valueChanged(int arg1);
void on_productIdInput_textEdited(const QString &arg1);
void on_productNameInput_textEdited(const QString &arg1);
void on_neopixelStrandLengthBox_valueChanged(int arg1);
void on_clearEepromBtn_clicked();
void on_productIdInput_textChanged(const QString &arg1);
void on_testBtn_clicked();
void selectedProfile_isChecked(bool isChecked);
void on_calib1Btn_clicked();
void on_calib2Btn_clicked();
void on_calib3Btn_clicked();
void on_calib4Btn_clicked();
void on_actionAbout_UI_triggered();
void on_customLEDstaticSpinbox_valueChanged(int arg1);
void on_customLEDstaticBtn1_clicked();
void on_customLEDstaticBtn2_clicked();
void on_customLEDstaticBtn3_clicked();
void on_tinyUSBLayoutToggle_stateChanged(int arg1);
void on_tUSB_p1_toggled(bool checked);
void on_tUSB_p2_toggled(bool checked);
void on_tUSB_p3_toggled(bool checked);
void on_tUSB_p4_toggled(bool checked);
void on_redLedTestBtn_clicked();
void on_greenLedTestBtn_clicked();
void on_blueLedTestBtn_clicked();
void on_actionOpenFIRE_Documentation_triggered();
void on_actionOpenFIRE_Serial_Usage_triggered();
private:
Ui::guiWindow *ui;
// Used by pinBoxes, matching boardInputs_e
QStringList valuesNameList = {
"Unmapped",
"Trigger",
"Button A",
"Button B",
"Button C",
"Start",
"Select",
"D-Pad Up",
"D-Pad Down",
"D-Pad Left",
"D-Pad Right",
"Pedal",
"Alt Pedal",
"Home Button",
"Pump Action",
"Rumble Signal",
"Solenoid Signal",
"Rumble Switch",
"Solenoid Switch",
"Autofire Switch",
"External NeoPixel",
"RGB LED Red",
"RGB LED Green",
"RGB LED Blue",
"Camera SDA",
"Camera SCL",
"Peripherals SDA",
"Peripherals SCL",
"Battery Sensor",
"Analog Pin X",
"Analog Pin Y",
"Temp Sensor"
};
// List of serial port objects that were found in PortsSearch()
QList<QSerialPortInfo> serialFoundList;
// Extracted COM paths, as provided from serialFoundList
QStringList usbName;
// Tracks the amount of differences between current config and loaded config.
// Resets after every call to DiffUpdate()
uint8_t settingsDiff;
// Current array of booleans, meant to be used as a bitmask
bool boolSettings[boolTypesCount];
// Array of booleans, as loaded from the gun firmware
bool boolSettings_orig[boolTypesCount];
// Current table of tunable settings
uint32_t settingsTable[settingsTypesCount];
// Table of tunables, as loaded from gun firmware
uint32_t settingsTable_orig[settingsTypesCount];
// TODO: add this to settingsTable (5.1?)
uint8_t tempWarning = 35;
uint8_t tempShutoff = 42;
// Indexed array map of the current physical layout of the board;
// Also doubles as combobox sanity check.
// Key = pin number, Value = pin function
// Values: -2 = N/A, -1 = reserved, 0 = available, unused
QMap<uint8_t, int8_t> currentPins;
bool testMode = false;
// for timer
bool boardIsAlive = false;
QTimer *aliveTimer;
// Test Mode screen points & colors
QGraphicsEllipseItem testPointTL;
QGraphicsEllipseItem testPointTR;
QGraphicsEllipseItem testPointBL;
QGraphicsEllipseItem testPointBR;
QGraphicsEllipseItem testPointMed;
QGraphicsEllipseItem testPointD;
QGraphicsPolygonItem testBox;
QPen testPointTLPen;
QPen testPointTRPen;
QPen testPointBLPen;
QPen testPointBRPen;
QPen testPointMedPen;
QPen testPointDPen;
// ^^^---Values---^^^
//
// vvv---Methods---vvv
void BoxesFill();
void BoxesUpdate();
void LabelsUpdate();
void DiffUpdate();
void PixelsDiff();
void PopupWindow(QString errorTitle, QString errorMessage, QString windowTitle, int errorType);
void PortsSearch();
void SelectionUpdate(uint8_t newSelection);
bool SerialInit(int portNum);
void SerialLoad();
void SyncSettings();
};
#endif // GUIWINDOW_H