Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9868e0d5
Commit
9868e0d5
authored
Mar 07, 2016
by
Don Gagne
Browse files
Fix settable flight mode channel
parent
76975530
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/AutoPilotPlugins/APM/APMFlightModesComponent.qml
View file @
9868e0d5
...
...
@@ -39,6 +39,9 @@ QGCView {
property
bool
_channel7OptionsAvailable
:
controller
.
parameterExists
(
-
1
,
"
CH7_OPT
"
)
// Not available in all firmware types
property
bool
_channel9OptionsAvailable
:
controller
.
parameterExists
(
-
1
,
"
CH9_OPT
"
)
// Not available in all firmware types
property
int
_channelOptionCount
:
_channel7OptionsAvailable
?
(
_channel9OptionsAvailable
?
6
:
2
)
:
0
property
Fact
_nullFact
property
bool
_fltmodeChExists
:
controller
.
parameterExists
(
-
1
,
"
FLTMODE_CH
"
)
property
Fact
_fltmodeCh
:
_fltmodeChExists
?
controller
.
getParameterFact
(
-
1
,
"
FLTMODE_CH
"
)
:
_nullFact
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
panel
.
enabled
}
...
...
@@ -59,7 +62,7 @@ QGCView {
QGCLabel
{
id
:
flightModeLabel
text
:
"
Channel 5
Flight Mode Settings
"
text
:
"
Flight Mode Settings
"
+
(
_fltmodeChExists
?
""
:
"
(Channel 5)
"
)
font.weight
:
Font
.
DemiBold
}
...
...
@@ -75,10 +78,28 @@ QGCView {
id
:
flightModeColumn
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.left
:
parent
.
left
// anchors.right: parent.right
anchors.top
:
parent
.
top
spacing
:
ScreenTools
.
defaultFontPixelHeight
Row
{
spacing
:
_margins
visible
:
_fltmodeChExists
QGCLabel
{
id
:
modeChannelLabel
anchors.baseline
:
modeChannelCombo
.
baseline
text
:
"
Flight mode channel:
"
}
QGCComboBox
{
id
:
modeChannelCombo
width
:
ScreenTools
.
defaultFontPixelWidth
*
15
model
:
[
"
Not assigned
"
,
"
Channel 1
"
,
"
Channel 2
"
,
"
Channel 3
"
,
"
Channel 4
"
,
"
Channel 5
"
,
"
Channel 6
"
,
"
Channel 7
"
,
"
Channel 8
"
]
currentIndex
:
_fltmodeCh
.
value
onActivated
:
_fltmodeCh
.
value
=
index
}
}
Repeater
{
model
:
6
...
...
src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc
View file @
9868e0d5
...
...
@@ -32,8 +32,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
:
_activeFlightMode
(
0
)
,
_channelCount
(
Vehicle
::
cMaxRcChannels
)
,
_fixedWing
(
_vehicle
->
vehicleType
()
==
MAV_TYPE_FIXED_WING
)
,
_flightModeChannel
(
5
)
{
QStringList
usedParams
;
usedParams
<<
QStringLiteral
(
"FLTMODE1"
)
<<
QStringLiteral
(
"FLTMODE2"
)
<<
QStringLiteral
(
"FLTMODE3"
)
...
...
@@ -42,10 +40,6 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
return
;
}
if
(
parameterExists
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FLTMODE_CH"
)))
{
_flightModeChannel
=
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FLTMODE_CH"
))
->
rawValue
().
toInt
();
}
_rgChannelOptionEnabled
<<
QVariant
(
false
)
<<
QVariant
(
false
)
<<
QVariant
(
false
)
<<
QVariant
(
false
)
<<
QVariant
(
false
)
<<
QVariant
(
false
);
connect
(
_vehicle
,
&
Vehicle
::
rcChannelsChanged
,
this
,
&
APMFlightModesComponentController
::
_rcChannelsChanged
);
...
...
@@ -54,12 +48,18 @@ APMFlightModesComponentController::APMFlightModesComponentController(void)
/// Connected to Vehicle::rcChannelsChanged signal
void
APMFlightModesComponentController
::
_rcChannelsChanged
(
int
channelCount
,
int
pwmValues
[
Vehicle
::
cMaxRcChannels
])
{
if
(
_flightModeChannel
>
channelCount
)
{
int
flightModeChannel
=
4
;
if
(
parameterExists
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FLTMODE_CH"
)))
{
flightModeChannel
=
getParameterFact
(
FactSystem
::
defaultComponentId
,
QStringLiteral
(
"FLTMODE_CH"
))
->
rawValue
().
toInt
()
-
1
;
}
if
(
flightModeChannel
>=
channelCount
)
{
return
;
}
_activeFlightMode
=
0
;
int
channelValue
=
pwmValues
[
_
flightModeChannel
-
1
];
int
channelValue
=
pwmValues
[
flightModeChannel
];
if
(
channelValue
!=
-
1
)
{
bool
found
=
false
;
int
rgThreshold
[]
=
{
1230
,
1360
,
1490
,
1620
,
1749
};
...
...
src/AutoPilotPlugins/APM/APMFlightModesComponentController.h
View file @
9868e0d5
...
...
@@ -62,7 +62,6 @@ private:
int
_channelCount
;
QVariantList
_rgChannelOptionEnabled
;
bool
_fixedWing
;
int
_flightModeChannel
;
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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