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
066ffe31
Commit
066ffe31
authored
Jul 26, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Done
parent
88b201ef
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
119 deletions
+150
-119
Joystick.cc
src/Joystick/Joystick.cc
+81
-58
Joystick.h
src/Joystick/Joystick.h
+29
-24
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+7
-9
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+3
-0
JoystickConfigAdvanced.qml
src/VehicleSetup/JoystickConfigAdvanced.qml
+23
-5
JoystickConfigButtons.qml
src/VehicleSetup/JoystickConfigButtons.qml
+7
-23
No files found.
src/Joystick/Joystick.cc
View file @
066ffe31
This diff is collapsed.
Click to expand it.
src/Joystick/Joystick.h
View file @
066ffe31
...
...
@@ -28,8 +28,7 @@ public:
AssignedButtonAction
(
QObject
*
parent
,
const
QString
name
);
QString
action
;
QTime
buttonTime
;
bool
repeat
=
false
;
int
frequency
=
1
;
bool
repeat
=
false
;
};
//-- Assignable Button Action
...
...
@@ -100,14 +99,15 @@ public:
Q_PROPERTY
(
bool
gimbalEnabled
READ
gimbalEnabled
WRITE
setGimbalEnabled
NOTIFY
gimbalEnabledChanged
)
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
Q_PROPERTY
(
float
frequency
READ
frequency
WRITE
setFrequency
NOTIFY
frequencyChanged
)
Q_PROPERTY
(
float
axisFrequency
READ
axisFrequency
WRITE
setAxisFrequency
NOTIFY
axisFrequencyChanged
)
Q_PROPERTY
(
float
buttonFrequency
READ
buttonFrequency
WRITE
setButtonFrequency
NOTIFY
buttonFrequencyChanged
)
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
circleCorrection
READ
circleCorrection
WRITE
setCircleCorrection
NOTIFY
circleCorrectionChanged
)
Q_INVOKABLE
void
setButtonRepeat
(
int
button
,
bool
repeat
);
Q_INVOKABLE
void
setButtonFrequency
(
int
button
,
int
freq
);
Q_INVOKABLE
bool
getButtonRepeat
(
int
button
);
Q_INVOKABLE
void
setButtonAction
(
int
button
,
const
QString
&
action
);
Q_INVOKABLE
QString
getButtonAction
(
int
button
);
...
...
@@ -144,32 +144,35 @@ public:
*/
virtual
bool
requiresCalibration
(
void
)
{
return
true
;
}
int
throttleMode
();
void
setThrottleMode
(
int
mode
);
int
throttleMode
();
void
setThrottleMode
(
int
mode
);
bool
negativeThrust
();
void
setNegativeThrust
(
bool
allowNegative
);
bool
negativeThrust
();
void
setNegativeThrust
(
bool
allowNegative
);
float
exponential
();
void
setExponential
(
float
expo
);
void
setExponential
(
float
expo
);
bool
accumulator
();
void
setAccumulator
(
bool
accu
);
bool
accumulator
();
void
setAccumulator
(
bool
accu
);
bool
deadband
();
void
setDeadband
(
bool
accu
);
bool
deadband
();
void
setDeadband
(
bool
accu
);
bool
circleCorrection
();
void
setCircleCorrection
(
bool
circleCorrection
);
bool
circleCorrection
();
void
setCircleCorrection
(
bool
circleCorrection
);
void
setTXMode
(
int
mode
);
int
getTXMode
()
{
return
_transmitterMode
;
}
void
setTXMode
(
int
mode
);
int
getTXMode
()
{
return
_transmitterMode
;
}
/// Set the current calibration mode
void
setCalibrationMode
(
bool
calibrating
);
void
setCalibrationMode
(
bool
calibrating
);
float
frequency
();
void
setFrequency
(
float
val
);
float
axisFrequency
()
{
return
_axisFrequency
;
}
void
setAxisFrequency
(
float
val
);
float
buttonFrequency
()
{
return
_buttonFrequency
;
}
void
setButtonFrequency
(
float
val
);
signals:
// The raw signals are only meant for use by calibration
...
...
@@ -196,7 +199,8 @@ signals:
void
buttonActionTriggered
(
int
action
);
void
gimbalEnabledChanged
();
void
frequencyChanged
();
void
axisFrequencyChanged
();
void
buttonFrequencyChanged
();
void
startContinuousZoom
(
int
direction
);
void
stopContinuousZoom
();
void
stepZoom
(
int
direction
);
...
...
@@ -262,7 +266,8 @@ protected:
bool
_accumulator
=
false
;
bool
_deadband
=
false
;
bool
_circleCorrection
=
true
;
float
_frequency
=
25
.
0
f
;
float
_axisFrequency
=
25
.
0
f
;
float
_buttonFrequency
=
5
.
0
f
;
Vehicle
*
_activeVehicle
=
nullptr
;
bool
_gimbalEnabled
=
false
;
...
...
@@ -292,13 +297,13 @@ private:
static
const
char
*
_calibratedSettingsKey
;
static
const
char
*
_buttonActionNameKey
;
static
const
char
*
_buttonActionRepeatKey
;
static
const
char
*
_buttonActionFrequencyKey
;
static
const
char
*
_throttleModeSettingsKey
;
static
const
char
*
_exponentialSettingsKey
;
static
const
char
*
_accumulatorSettingsKey
;
static
const
char
*
_deadbandSettingsKey
;
static
const
char
*
_circleCorrectionSettingsKey
;
static
const
char
*
_frequencySettingsKey
;
static
const
char
*
_axisFrequencySettingsKey
;
static
const
char
*
_buttonFrequencySettingsKey
;
static
const
char
*
_txModeSettingsKey
;
static
const
char
*
_fixedWingTXModeSettingsKey
;
static
const
char
*
_multiRotorTXModeSettingsKey
;
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
066ffe31
...
...
@@ -168,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object)
if
(
i
<
0
||
i
>
_objectList
.
count
())
{
qWarning
()
<<
"Invalid index index:count"
<<
i
<<
_objectList
.
count
();
}
QQmlEngine
::
setObjectOwnership
(
object
,
QQmlEngine
::
CppOwnership
);
// Look for a dirtyChanged signal on the object
if
(
object
->
metaObject
()
->
indexOfSignal
(
QMetaObject
::
normalizedSignature
(
"dirtyChanged(bool)"
))
!=
-
1
)
{
if
(
!
_skipDirtyFirstItem
||
i
!=
0
)
{
QObject
::
connect
(
object
,
SIGNAL
(
dirtyChanged
(
bool
)),
this
,
SLOT
(
_childDirtyChanged
(
bool
)));
if
(
object
)
{
QQmlEngine
::
setObjectOwnership
(
object
,
QQmlEngine
::
CppOwnership
);
// Look for a dirtyChanged signal on the object
if
(
object
->
metaObject
()
->
indexOfSignal
(
QMetaObject
::
normalizedSignature
(
"dirtyChanged(bool)"
))
!=
-
1
)
{
if
(
!
_skipDirtyFirstItem
||
i
!=
0
)
{
QObject
::
connect
(
object
,
SIGNAL
(
dirtyChanged
(
bool
)),
this
,
SLOT
(
_childDirtyChanged
(
bool
)));
}
}
}
_objectList
.
insert
(
i
,
object
);
insertRows
(
i
,
1
);
setDirty
(
true
);
}
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
066ffe31
...
...
@@ -61,6 +61,9 @@ SetupPage {
QGCTabBar
{
id
:
bar
width
:
parent
.
width
Component.onCompleted
:
{
currentIndex
=
_activeJoystick
&&
_activeJoystick
.
calibrated
?
0
:
2
}
anchors.top
:
parent
.
top
QGCTabButton
{
text
:
qsTr
(
"
General
"
)
...
...
src/VehicleSetup/JoystickConfigAdvanced.qml
View file @
066ffe31
...
...
@@ -144,20 +144,38 @@ Item {
visible
:
advancedSettings
.
checked
}
//-----------------------------------------------------------------
//-- Message Frequency
//--
Axis
Message Frequency
QGCLabel
{
text
:
qsTr
(
"
Message
frequency (Hz):
"
)
text
:
qsTr
(
"
Axis
frequency (Hz):
"
)
Layout.alignment
:
Qt
.
AlignVCenter
visible
:
advancedSettings
.
checked
}
QGCTextField
{
text
:
_activeJoystick
.
f
requency
text
:
_activeJoystick
.
axisF
requency
enabled
:
advancedSettings
.
checked
validator
:
DoubleValidator
{
bottom
:
0.25
;
top
:
10
0.0
;
}
validator
:
DoubleValidator
{
bottom
:
0.25
;
top
:
5
0.0
;
}
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.alignment
:
Qt
.
AlignVCenter
onEditingFinished
:
{
_activeJoystick
.
frequency
=
parseFloat
(
text
)
_activeJoystick
.
axisFrequency
=
parseFloat
(
text
)
}
visible
:
advancedSettings
.
checked
}
//-----------------------------------------------------------------
//-- Button Repeat Frequency
QGCLabel
{
text
:
qsTr
(
"
Button repeat frequency (Hz):
"
)
Layout.alignment
:
Qt
.
AlignVCenter
visible
:
advancedSettings
.
checked
}
QGCTextField
{
text
:
_activeJoystick
.
buttonFrequency
enabled
:
advancedSettings
.
checked
validator
:
DoubleValidator
{
bottom
:
0.25
;
top
:
50.0
;
}
inputMethodHints
:
Qt
.
ImhFormattedNumbersOnly
Layout.alignment
:
Qt
.
AlignVCenter
onEditingFinished
:
{
_activeJoystick
.
buttonFrequency
=
parseFloat
(
text
)
}
visible
:
advancedSettings
.
checked
}
...
...
src/VehicleSetup/JoystickConfigButtons.qml
View file @
066ffe31
...
...
@@ -46,7 +46,7 @@ Item {
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
property
bool
pressed
property
var
currentA
ction
:
_activeJoystick
?
_activeJoystick
.
assignableActions
.
get
(
buttonActionCombo
.
currentIndex
)
:
null
property
var
currentA
ssignableAction
:
_activeJoystick
?
_activeJoystick
.
assignableActions
.
get
(
buttonActionCombo
.
currentIndex
)
:
null
Rectangle
{
anchors.verticalCenter
:
parent
.
verticalCenter
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
...
...
@@ -73,39 +73,23 @@ Item {
if
(
_activeJoystick
)
{
var
i
=
find
(
_activeJoystick
.
buttonActions
[
modelData
])
if
(
i
<
0
)
i
=
0
currentIndex
=
0
currentIndex
=
i
}
}
}
QGCCheckBox
{
id
:
repeatCheck
text
:
qsTr
(
"
Repeat
"
)
enabled
:
currentA
ction
&&
_activeJoystick
.
calibrated
&&
current
Action
.
canRepeat
enabled
:
currentA
ssignableAction
&&
_activeJoystick
.
calibrated
&&
currentAssignable
Action
.
canRepeat
onClicked
:
{
_activeJoystick
.
setButtonRepeat
(
modelData
,
checked
)
}
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCComboBox
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
10
model
:
[
"
1Hz
"
,
"
2Hz
"
,
"
5Hz
"
,
"
10Hz
"
,
"
25Hz
"
]
enabled
:
repeatCheck
.
checked
onActivated
:
{
var
freq
=
1
;
switch
(
index
)
{
case
0
:
freq
=
1
;
break
;
case
1
:
freq
=
2
;
break
;
case
2
:
freq
=
5
;
break
;
case
3
:
freq
=
10
;
break
;
case
4
:
freq
=
25
;
break
;
}
_activeJoystick
.
setButtonFrequency
(
modelData
,
freq
)
}
Component.onCompleted
:
{
if
(
_activeJoystick
)
{
checked
=
_activeJoystick
.
getButtonRepeat
(
modelData
)
}
}
anchors
.
verticalCenter
:
parent
.
verticalCenter
}
Item
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
2
...
...
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