Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3051ab71
Commit
3051ab71
authored
May 23, 2017
by
Pierre Kancir
Committed by
khancyr
Sep 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Joystick: add a button to support negative thrust
parent
54780e15
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
Joystick.cc
src/Joystick/Joystick.cc
+20
-1
Joystick.h
src/Joystick/Joystick.h
+8
-0
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+8
-0
No files found.
src/Joystick/Joystick.cc
View file @
3051ab71
...
...
@@ -55,6 +55,7 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
,
_rgButtonValues
(
NULL
)
,
_lastButtonBits
(
0
)
,
_throttleMode
(
ThrottleModeCenterZero
)
,
_negativeThrust
(
false
)
,
_exponential
(
0
)
,
_accumulator
(
false
)
,
_deadband
(
false
)
...
...
@@ -462,7 +463,9 @@ void Joystick::run(void)
// Adjust throttle to 0:1 range
if
(
_throttleMode
==
ThrottleModeCenterZero
&&
_activeVehicle
->
supportsThrottleModeCenterZero
())
{
if
(
!
_negativeThrust
)
{
throttle
=
std
::
max
(
0.0
f
,
throttle
);
}
}
else
{
throttle
=
(
throttle
+
1.0
f
)
/
2.0
f
;
}
...
...
@@ -687,6 +690,22 @@ void Joystick::setThrottleMode(int mode)
emit
throttleModeChanged
(
_throttleMode
);
}
bool
Joystick
::
negativeThrust
(
void
)
{
return
_negativeThrust
;
}
void
Joystick
::
setNegativeThrust
(
bool
allowNegative
)
{
if
(
_negativeThrust
==
allowNegative
)
{
return
;
}
_negativeThrust
=
allowNegative
;
_saveSettings
();
emit
negativeThrustChanged
(
_negativeThrust
);
}
float
Joystick
::
exponential
(
void
)
{
return
_exponential
;
...
...
src/Joystick/Joystick.h
View file @
3051ab71
...
...
@@ -72,6 +72,7 @@ public:
Q_INVOKABLE
QString
getButtonAction
(
int
button
);
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
Q_PROPERTY
(
bool
negativeThrust
READ
negativeThrust
WRITE
setNegativeThrust
NOTIFY
negativeThrustChanged
)
Q_PROPERTY
(
float
exponential
READ
exponential
WRITE
setExponential
NOTIFY
exponentialChanged
)
Q_PROPERTY
(
bool
accumulator
READ
accumulator
WRITE
setAccumulator
NOTIFY
accumulatorChanged
)
Q_PROPERTY
(
bool
requiresCalibration
READ
requiresCalibration
CONSTANT
)
...
...
@@ -106,6 +107,9 @@ public:
int
throttleMode
(
void
);
void
setThrottleMode
(
int
mode
);
bool
negativeThrust
(
void
);
void
setNegativeThrust
(
bool
allowNegative
);
float
exponential
(
void
);
void
setExponential
(
float
expo
);
...
...
@@ -141,6 +145,8 @@ signals:
void
throttleModeChanged
(
int
mode
);
void
negativeThrustChanged
(
bool
allowNegative
);
void
exponentialChanged
(
float
exponential
);
void
accumulatorChanged
(
bool
accumulator
);
...
...
@@ -206,6 +212,8 @@ protected:
ThrottleMode_t
_throttleMode
;
bool
_negativeThrust
;
float
_exponential
;
bool
_accumulator
;
bool
_deadband
;
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
3051ab71
...
...
@@ -453,6 +453,14 @@ SetupPage {
onClicked
:
_activeJoystick
.
throttleMode
=
1
}
QGCCheckBox
{
id
:
negativeThrust
text
:
qsTr
(
"
Allow negative Thrust
"
)
checked
:
_activeJoystick
?
_activeJoystick
.
negativeThrust
:
false
onClicked
:
_activeJoystick
.
negativeThrust
=
checked
}
}
Column
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment