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
c1480680
Commit
c1480680
authored
Mar 05, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add switch assignment
parent
f5776307
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
64 deletions
+126
-64
PX4SimpleFlightModes.qml
src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml
+115
-62
PX4SimpleFlightModesController.cc
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc
+6
-0
PX4SimpleFlightModesController.h
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.h
+5
-2
No files found.
src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml
View file @
c1480680
...
...
@@ -57,79 +57,132 @@ Item {
id
:
contentColumn
spacing
:
_margins
QGCLabel
{
id
:
flightModeLabel
text
:
"
Flight Mode Settings
"
font.weight
:
Font
.
DemiBold
}
Item
{
height
:
modeChannelCombo
.
height
width
:
modeChannelCombo
.
x
+
modeChannelCombo
.
width
QGCLabel
{
id
:
modeChannelLabel
anchors.baseline
:
modeChannelCombo
.
baseline
text
:
"
Flight mode channel:
"
}
FactComboBox
{
id
:
modeChannelCombo
anchors.leftMargin
:
_margins
anchors.left
:
modeChannelLabel
.
right
width
:
ScreenTools
.
defaultFontPixelWidth
*
15
fact
:
controller
.
getParameterFact
(
-
1
,
"
RC_MAP_FLTMODE
"
)
indexModel
:
false
}
}
Rectangle
{
id
:
flightModeSettings
width
:
flightModeColumn
.
width
+
(
_margins
*
2
)
height
:
flightModeColumn
.
height
+
ScreenTools
.
defaultFontPixelHeight
color
:
qgcPal
.
windowShade
Row
{
id
:
settingsRow
spacing
:
_margins
Column
{
id
:
flightModeColumn
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
spacing
:
ScreenTools
.
defaultFontPixelHeight
id
:
flightModeSettingsColumn
spacing
:
_margins
QGCLabel
{
id
:
flightModeLabel
text
:
"
Flight Mode Settings
"
font.weight
:
Font
.
DemiBold
}
Rectangle
{
id
:
flightModeSettings
width
:
flightModeColumn
.
width
+
(
_margins
*
2
)
height
:
flightModeColumn
.
height
+
ScreenTools
.
defaultFontPixelHeight
color
:
qgcPal
.
windowShade
Column
{
id
:
flightModeColumn
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
spacing
:
ScreenTools
.
defaultFontPixelHeight
Row
{
spacing
:
_margins
QGCLabel
{
id
:
modeChannelLabel
anchors.baseline
:
modeChannelCombo
.
baseline
text
:
"
Flight mode channel:
"
}
FactComboBox
{
id
:
modeChannelCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
15
fact
:
controller
.
getParameterFact
(
-
1
,
"
RC_MAP_FLTMODE
"
)
indexModel
:
false
}
}
Repeater
{
model
:
6
Repeater
{
model
:
6
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
property
int
index
:
modelData
+
1
property
var
pwmStrings
:
[
"
PWM 0 - 1230
"
,
"
PWM 1231 - 1360
"
,
"
PWM 1361 - 1490
"
,
"
PWM 1491 - 1620
"
,
"
PWM 1621 - 1749
"
,
"
PWM 1750 +
"
]
property
int
index
:
modelData
+
1
property
var
pwmStrings
:
[
"
PWM 0 - 1230
"
,
"
PWM 1231 - 1360
"
,
"
PWM 1361 - 1490
"
,
"
PWM 1491 - 1620
"
,
"
PWM 1621 - 1749
"
,
"
PWM 1750 +
"
]
QGCLabel
{
anchors.baseline
:
modeCombo
.
baseline
text
:
"
Flight Mode
"
+
index
+
"
:
"
color
:
controller
.
activeFlightMode
==
index
?
"
yellow
"
:
qgcPal
.
text
}
QGCLabel
{
anchors.baseline
:
modeCombo
.
baseline
text
:
"
Flight Mode
"
+
index
+
"
:
"
color
:
controller
.
activeFlightMode
==
index
?
"
yellow
"
:
qgcPal
.
text
}
FactComboBox
{
id
:
modeCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
fact
:
controller
.
getParameterFact
(
-
1
,
"
COM_FLTMODE
"
+
index
)
indexModel
:
false
}
FactComboBox
{
id
:
modeCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
fact
:
controller
.
getParameterFact
(
-
1
,
"
COM_FLTMODE
"
+
index
)
indexModel
:
false
}
QGCLabel
{
anchors.baseline
:
modeCombo
.
baseline
text
:
pwmStrings
[
modelData
]
}
}
}
// Repeater - Flight Modes
}
// Column - Flight Modes
}
// Rectangle - Flight Modes
QGCLabel
{
anchors.baseline
:
modeCombo
.
baseline
text
:
pwmStrings
[
modelData
]
}
}
}
// Repeater - Flight Modes
}
// Column - Flight Modes
}
// Rectangle - Flight Modes
}
// Column - Flight mode settings
Column
{
spacing
:
_margins
QGCLabel
{
text
:
"
Switch Settings
"
font.weight
:
Font
.
DemiBold
}
Rectangle
{
width
:
switchSettingsColumn
.
width
+
(
_margins
*
2
)
height
:
switchSettingsColumn
.
height
+
ScreenTools
.
defaultFontPixelHeight
color
:
qgcPal
.
windowShade
Column
{
id
:
switchSettingsColumn
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
spacing
:
ScreenTools
.
defaultFontPixelHeight
Repeater
{
model
:
[
"
RC_MAP_RETURN_SW
"
,
"
RC_MAP_KILL_SW
"
,
"
RC_MAP_FLAPS
"
,
"
RC_MAP_AUX1
"
,
"
RC_MAP_AUX2
"
,
"
RC_MAP_AUX3
"
,
"
RC_MAP_OFFB_SW
"
]
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
property
Fact
fact
:
controller
.
getParameterFact
(
-
1
,
modelData
)
QGCLabel
{
anchors.baseline
:
optCombo
.
baseline
text
:
fact
.
shortDescription
+
"
:
"
color
:
fact
.
value
==
0
?
qgcPal
.
text
:
(
controller
.
rcChannelValues
[
fact
.
value
-
1
]
>=
1500
?
"
yellow
"
:
qgcPal
.
text
)
}
FactComboBox
{
id
:
optCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
15
fact
:
parent
.
fact
indexModel
:
false
}
}
}
// Repeater
}
// Column
}
// Rectangle
}
// Column - Switch settings
}
// Row - Settings
QGCButton
{
text
:
"
Use Advanced Flight Modes
"
text
:
"
Use Advanced Flight Modes
"
onClicked
:
{
controller
.
getParameterFact
(
-
1
,
"
RC_MAP_MODE_SW
"
).
value
=
5
controller
.
getParameterFact
(
-
1
,
"
RC_MAP_FLTMODE
"
).
value
=
0
...
...
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc
View file @
c1480680
...
...
@@ -47,6 +47,12 @@ PX4SimpleFlightModesController::PX4SimpleFlightModesController(void)
/// Connected to Vehicle::rcChannelsChanged signal
void
PX4SimpleFlightModesController
::
_rcChannelsChanged
(
int
channelCount
,
int
pwmValues
[
Vehicle
::
cMaxRcChannels
])
{
_rcChannelValues
.
clear
();
for
(
int
i
=
0
;
i
<
channelCount
;
i
++
)
{
_rcChannelValues
.
append
(
pwmValues
[
i
]);
}
emit
rcChannelValuesChanged
();
int
flightModeChannel
=
getParameterFact
(
-
1
,
"RC_MAP_FLTMODE"
)
->
rawValue
().
toInt
()
-
1
;
if
(
flightModeChannel
<
0
||
flightModeChannel
>
channelCount
)
{
...
...
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.h
View file @
c1480680
...
...
@@ -42,14 +42,16 @@ class PX4SimpleFlightModesController : public FactPanelController
public:
PX4SimpleFlightModesController
(
void
);
Q_PROPERTY
(
int
activeFlightMode
READ
activeFlightMode
NOTIFY
activeFlightModeChanged
)
Q_PROPERTY
(
int
channelCount
MEMBER
_channelCount
CONSTANT
)
Q_PROPERTY
(
int
activeFlightMode
READ
activeFlightMode
NOTIFY
activeFlightModeChanged
)
Q_PROPERTY
(
int
channelCount
MEMBER
_channelCount
CONSTANT
)
Q_PROPERTY
(
QVariantList
rcChannelValues
MEMBER
_rcChannelValues
NOTIFY
rcChannelValuesChanged
)
int
activeFlightMode
(
void
)
const
{
return
_activeFlightMode
;
}
signals:
void
activeFlightModeChanged
(
int
activeFlightMode
);
void
channelOptionEnabledChanged
(
void
);
void
rcChannelValuesChanged
(
void
);
private
slots
:
void
_rcChannelsChanged
(
int
channelCount
,
int
pwmValues
[
Vehicle
::
cMaxRcChannels
]);
...
...
@@ -57,6 +59,7 @@ private slots:
private:
int
_activeFlightMode
;
int
_channelCount
;
QVariantList
_rcChannelValues
;
};
#endif
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