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
41035462
Commit
41035462
authored
Sep 03, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1831 from DonLakeFlyer/EvenMoreJoystick
Joystick message fixes
parents
d14444a5
184af37c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
17 deletions
+45
-17
Joystick.cc
src/Joystick/Joystick.cc
+29
-10
Joystick.h
src/Joystick/Joystick.h
+12
-5
JoystickConfigController.cc
src/VehicleSetup/JoystickConfigController.cc
+4
-2
No files found.
src/Joystick/Joystick.cc
View file @
41035462
...
...
@@ -57,10 +57,9 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int sdlI
:
_sdlIndex
(
sdlIndex
)
,
_exitThread
(
false
)
,
_name
(
name
)
,
_calibrated
(
false
)
,
_calibrating
(
false
)
,
_axisCount
(
axisCount
)
,
_buttonCount
(
buttonCount
)
,
_calibrationMode
(
CalibrationModeOff
)
,
_lastButtonBits
(
0
)
,
_throttleMode
(
ThrottleModeCenterZero
)
,
_activeVehicle
(
NULL
)
...
...
@@ -273,7 +272,7 @@ void Joystick::run(void)
}
}
if
(
_calibrat
ed
&&
!
_c
alibrating
)
{
if
(
_calibrat
ionMode
!=
CalibrationModeC
alibrating
)
{
int
axis
=
_rgFunctionAxis
[
rollFunction
];
float
roll
=
_adjustRange
(
_rgAxisValues
[
axis
],
_rgCalibration
[
axis
]);
...
...
@@ -355,8 +354,14 @@ void Joystick::run(void)
void
Joystick
::
startPolling
(
Vehicle
*
vehicle
)
{
if
(
isRunning
())
{
if
(
_calibrating
&&
vehicle
!=
_activeVehicle
)
{
if
(
vehicle
!=
_activeVehicle
)
{
// Joystick was previously disabled, but now enabled from config screen
if
(
_calibrationMode
==
CalibrationModeOff
)
{
qWarning
()
<<
"Incorrect usage pattern"
;
return
;
}
_activeVehicle
=
vehicle
;
_pollingStartedForCalibration
=
false
;
}
...
...
@@ -489,9 +494,14 @@ void Joystick::setThrottleMode(int mode)
emit
throttleModeChanged
(
_throttleMode
);
}
void
Joystick
::
startCalibration
(
void
)
void
Joystick
::
startCalibration
Mode
(
CalibrationMode_t
mode
)
{
_calibrating
=
true
;
if
(
mode
==
CalibrationModeOff
)
{
qWarning
()
<<
"Incorrect mode CalibrationModeOff"
;
return
;
}
_calibrationMode
=
mode
;
if
(
!
isRunning
())
{
_pollingStartedForCalibration
=
true
;
...
...
@@ -499,11 +509,20 @@ void Joystick::startCalibration(void)
}
}
void
Joystick
::
stopCalibration
(
void
)
void
Joystick
::
stopCalibration
Mode
(
CalibrationMode_t
mode
)
{
if
(
_calibrating
)
{
_calibrating
=
false
;
if
(
mode
==
CalibrationModeOff
)
{
qWarning
()
<<
"Incorrect mode: CalibrationModeOff"
;
return
;
}
else
if
(
mode
!=
_calibrationMode
)
{
qWarning
()
<<
"Incorrect mode sequence request:active"
<<
mode
<<
_calibrationMode
;
return
;
}
if
(
mode
==
CalibrationModeCalibrating
)
{
_calibrationMode
=
CalibrationModeMonitor
;
}
else
{
_calibrationMode
=
CalibrationModeOff
;
if
(
_pollingStartedForCalibration
)
{
stopPolling
();
}
...
...
src/Joystick/Joystick.h
View file @
41035462
...
...
@@ -96,11 +96,17 @@ public:
int
throttleMode
(
void
);
void
setThrottleMode
(
int
mode
);
/// Calibration is about to start
void
startCalibration
(
void
);
typedef
enum
{
CalibrationModeOff
,
// Not calibrating
CalibrationModeMonitor
,
// Monitors are active, continue to send to vehicle if already polling
CalibrationModeCalibrating
,
// Calibrating, stop sending joystick to vehicle
}
CalibrationMode_t
;
/// Set the current calibration mode
void
startCalibrationMode
(
CalibrationMode_t
mode
);
/// C
alibration has ended
void
stopCalibration
(
void
);
/// C
lear the current calibration mode
void
stopCalibration
Mode
(
CalibrationMode_t
mode
);
signals:
void
calibratedChanged
(
bool
calibrated
);
...
...
@@ -140,10 +146,11 @@ private:
QString
_name
;
bool
_calibrated
;
bool
_calibrating
;
int
_axisCount
;
int
_buttonCount
;
CalibrationMode_t
_calibrationMode
;
static
const
int
_cAxes
=
4
;
int
_rgAxisValues
[
_cAxes
];
Calibration_t
_rgCalibration
[
_cAxes
];
...
...
src/VehicleSetup/JoystickConfigController.cc
View file @
41035462
...
...
@@ -73,7 +73,7 @@ JoystickConfigController::JoystickConfigController(void)
_activeJoystickChanged
(
joystickManager
->
activeJoystick
());
_loadSettings
();
_resetInternalCalibrationValues
();
_activeJoystick
->
startCalibration
(
);
_activeJoystick
->
startCalibration
Mode
(
Joystick
::
CalibrationModeMonitor
);
}
void
JoystickConfigController
::
start
(
void
)
...
...
@@ -84,7 +84,7 @@ void JoystickConfigController::start(void)
JoystickConfigController
::~
JoystickConfigController
()
{
_activeJoystick
->
stopCalibration
(
);
_activeJoystick
->
stopCalibration
Mode
(
Joystick
::
CalibrationModeMonitor
);
_storeSettings
();
}
...
...
@@ -548,6 +548,7 @@ void JoystickConfigController::_startCalibration(void)
{
Q_ASSERT
(
_axisCount
>=
_axisMinimum
);
_activeJoystick
->
startCalibrationMode
(
Joystick
::
CalibrationModeCalibrating
);
_resetInternalCalibrationValues
();
_nextButton
->
setProperty
(
"text"
,
"Next"
);
...
...
@@ -562,6 +563,7 @@ void JoystickConfigController::_stopCalibration(void)
{
_currentStep
=
-
1
;
_activeJoystick
->
stopCalibrationMode
(
Joystick
::
CalibrationModeCalibrating
);
_setInternalCalibrationValuesFromSettings
();
_statusText
->
setProperty
(
"text"
,
""
);
...
...
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