Skip to content

Commit 23f9870

Browse files
committed
Working without saving and refresh gui
1 parent 4929090 commit 23f9870

File tree

8 files changed

+232
-157
lines changed

8 files changed

+232
-157
lines changed

CodingStyle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/****************************************************************************
22
*
3-
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
3+
* (c) 2009-2022 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
44
*
55
* QGroundControl is licensed according to the terms in the file
66
* COPYING.md in the root of the source code directory.
@@ -31,7 +31,7 @@ Q_DECLARE_LOGGING_CATEGORY(CodingStyleLog)
3131

3232
/// Here is the class documentation. Class names are PascalCase. If you override any of the Qt base classes to provide
3333
/// generic base implementations for widespread use prefix the class name with QGC. For example:
34-
/// QGCMessageBox - is a QGC special vesion of Qt MessageBox
34+
/// QGCMessageBox - is a QGC special version of Qt MessageBox
3535
/// QGCPalette - is a QGC special version of Qt Palette
3636
/// For normal single use classes do no prefix them name with QGC.
3737

src/Joystick/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ add_library(Joystick
1212
JoystickManager.cc
1313
JoystickSDL.cc
1414
JoystickMavCommand.cc
15-
JoystickRcOverride.cc
1615
${EXTRA_SRC}
1716
)
1817

src/Joystick/Joystick.cc

Lines changed: 184 additions & 70 deletions
Large diffs are not rendered by default.

src/Joystick/Joystick.h

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <atomic>
1818

1919
#include "JoystickMavCommand.h"
20-
#include "JoystickRcOverride.h"
2120
#include "MultiVehicleManager.h"
2221
#include "QGCLoggingCategory.h"
2322
#include "Vehicle.h"
@@ -30,12 +29,36 @@ Q_DECLARE_METATYPE(GRIPPER_ACTIONS)
3029
class AssignedButtonAction : public QObject {
3130
Q_OBJECT
3231
public:
33-
AssignedButtonAction(QObject* parent, const QString name);
32+
AssignedButtonAction(QObject* parent, const QString action);
3433
QString action;
3534
QElapsedTimer buttonTime;
3635
bool repeat = false;
3736
};
3837

38+
/// Action of RC Pwm value override assigned to button
39+
class AssignedButtonRcPwmOverrideAction : public AssignedButtonAction {
40+
Q_OBJECT
41+
public:
42+
AssignedButtonRcPwmOverrideAction(QObject* parent, const QString name,
43+
const uint16_t loPwmValue,
44+
const uint16_t hiPwmValue,
45+
bool latch);
46+
void send(Vehicle* vehicle, bool buttonDown);
47+
uint8_t channel() const;
48+
void setLatchMode(bool latch);
49+
bool getLatchMode();
50+
static uint8_t getRcChannelFromAction(const QString action);
51+
52+
private:
53+
const uint8_t _rcChannel;
54+
uint16_t _loPwmValue;
55+
uint16_t _hiPwmValue;
56+
bool _latchMode;
57+
bool _latchButtonDown = false;
58+
59+
};
60+
61+
3962
/// Assignable Button Action
4063
class AssignableButtonAction : public QObject {
4164
Q_OBJECT
@@ -117,11 +140,14 @@ class Joystick : public QThread
117140

118141
Q_INVOKABLE void setButtonRepeat (int button, bool repeat);
119142
Q_INVOKABLE bool getButtonRepeat (int button);
143+
Q_INVOKABLE void setButtonPwmLatch (int button, bool latch);
144+
Q_INVOKABLE bool getButtonPwmLatch (int button);
120145
Q_INVOKABLE void setButtonAction (int button, const QString& action);
121146
Q_INVOKABLE QString getButtonAction (int button);
122-
Q_INVOKABLE bool assignableActionIsPWM (int button);
123-
Q_INVOKABLE void setButtonPWM (int button, bool lowPwm, int value);
124-
Q_INVOKABLE int getButtonPWM (int button, bool lowPwm);
147+
Q_INVOKABLE bool assignableActionIsPwm (int button);
148+
Q_INVOKABLE bool assignableActionIsPwm (QString action);
149+
Q_INVOKABLE void setButtonPwm (int button, bool lowPwm, int value);
150+
Q_INVOKABLE int getButtonPwm (int button, bool lowPwm);
125151

126152

127153
// Property accessors
@@ -236,7 +262,7 @@ class Joystick : public QThread
236262
void _saveButtonSettings ();
237263
void _loadSettings ();
238264
float _adjustRange (int value, Calibration_t calibration, bool withDeadbands);
239-
void _executeButtonAction (const QString& action, bool buttonDown);
265+
void _executeButtonAction (const QString &action, int buttonIndex, bool buttonDown);
240266
int _findAssignableButtonAction(const QString& action);
241267
bool _validAxis (int axis) const;
242268
bool _validButton (int button) const;
@@ -311,8 +337,7 @@ class Joystick : public QThread
311337
QStringList _availableActionTitles;
312338
MultiVehicleManager* _multiVehicleManager = nullptr;
313339

314-
QList<JoystickMavCommand> _customMavCommands;
315-
QList<JoystickRcOverride> _rcOverrides;
340+
QList<JoystickMavCommand> _customMavCommands;
316341

317342
static const float _minAxisFrequencyHz;
318343
static const float _maxAxisFrequencyHz;
@@ -328,6 +353,7 @@ class Joystick : public QThread
328353
static const char* _buttonActionRepeatKey;
329354
static const char* _buttonActionLowPwmValueKey;
330355
static const char* _buttonActionHighPwmValueKey;
356+
static const char* _buttonActionLatchPwmValueKey;
331357
static const char* _throttleModeSettingsKey;
332358
static const char* _negativeThrustSettingsKey;
333359
static const char* _exponentialSettingsKey;
@@ -373,6 +399,5 @@ class Joystick : public QThread
373399

374400
private slots:
375401
void _activeVehicleChanged(Vehicle* activeVehicle);
376-
bool _executeRcOverrideButtonAction(const QString &action, bool buttonDown);
377-
int getRcChannelFromAction(QString actionName);
402+
bool _executeRcOverrideButtonAction(int buttonIndex, bool buttonDown);
378403
};

src/Joystick/JoystickRcOverride.cc

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Joystick/JoystickRcOverride.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/QGCLoggingCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Q_DECLARE_LOGGING_CATEGORY(VideoAllLog) // turns on all individual QGC video log
2727

2828
/// @def QGC_LOGGING_CATEGORY
2929
/// This is a QGC specific replacement for Q_LOGGING_CATEGORY. It will register the category name into a
30-
/// global list. It's usage is the same as Q_LOGGING_CATEOGRY.
30+
/// global list. It's usage is the same as Q_LOGGING_CATEGORY.
3131
#define QGC_LOGGING_CATEGORY(name, ...) \
3232
static QGCLoggingCategory qgcCategory ## name (__VA_ARGS__); \
3333
Q_LOGGING_CATEGORY(name, __VA_ARGS__)

src/VehicleSetup/JoystickConfigButtons.qml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ ColumnLayout {
5555

5656
Column {
5757
spacing: ScreenTools.defaultFontPixelWidth
58+
property bool pressed
5859

5960
Row {
6061
spacing: ScreenTools.defaultFontPixelWidth
61-
property bool pressed
6262
property var currentAssignableAction: _activeJoystick ? _activeJoystick.assignableActions.get(buttonActionCombo.currentIndex) : null
6363
Rectangle {
6464
anchors.verticalCenter: parent.verticalCenter
6565
width: ScreenTools.defaultFontPixelHeight * 1.5
6666
height: width
6767
border.width: 1
6868
border.color: qgcPal.text
69-
color: parent.pressed ? qgcPal.buttonHighlight : qgcPal.button
69+
color: parent.parent.pressed ? qgcPal.buttonHighlight : qgcPal.button
7070
QGCLabel {
7171
anchors.fill: parent
72-
color: parent.parent.pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
72+
color: parent.parent.parent.pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
7373
horizontalAlignment: Text.AlignHCenter
7474
verticalAlignment: Text.AlignVCenter
7575
text: modelData
@@ -89,8 +89,8 @@ ColumnLayout {
8989
}
9090
}
9191

92-
function _isCurrentButtonActionPWM() {
93-
return _activeJoystick ? _activeJoystick.assignableActionIsPWM(modelData) : false
92+
function _isCurrentButtonActionPwm() {
93+
return _activeJoystick ? _activeJoystick.assignableActionIsPwm(modelData) : false
9494
}
9595

9696
Component.onCompleted: _findCurrentButtonAction()
@@ -119,7 +119,7 @@ ColumnLayout {
119119

120120
Row {
121121
id: pwmSettings
122-
property bool pwmRowVisible: buttonActionCombo._isCurrentButtonActionPWM()
122+
property bool pwmRowVisible: buttonActionCombo._isCurrentButtonActionPwm()
123123
spacing: ScreenTools.defaultFontPixelWidth
124124
visible: pwmRowVisible
125125

@@ -131,14 +131,14 @@ ColumnLayout {
131131
if (pwm > 2000) {
132132
pwm = 2000;
133133
}
134-
_activeJoystick.setButtonPWM(modelData, isLow, pwm)
134+
_activeJoystick.setButtonPwm(modelData, isLow, pwm)
135135
}
136136
}
137137

138138
function _getButtonPwm(button, isLow) {
139139
var pwm = -1;
140140
if(_activeJoystick) {
141-
pwm = _activeJoystick.getButtonPWM(modelData, isLow)
141+
pwm = _activeJoystick.getButtonPwm(modelData, isLow)
142142
}
143143
return pwm == -1 ? "" : pwm;
144144
}
@@ -185,11 +185,11 @@ ColumnLayout {
185185
anchors.verticalCenter: parent.verticalCenter
186186

187187
onClicked: {
188-
_activeJoystick.setButtonRepeat(modelData, checked)
188+
_activeJoystick.setButtonPwmLatch(modelData, checked)
189189
}
190190
Component.onCompleted: {
191191
if(_activeJoystick) {
192-
checked = _activeJoystick.getButtonRepeat(modelData)
192+
checked = _activeJoystick.getButtonPwmLatch(modelData)
193193
}
194194
}
195195
}

0 commit comments

Comments
 (0)