@ -60,6 +60,7 @@ Item {
Fact { id: rc_map_mode_sw ; name: "RC_MAP_MODE_SW" }
Fact { id: rc_map_mode_sw ; name: "RC_MAP_MODE_SW" }
Fact { id: rc_map_posctl_sw ; name: "RC_MAP_POSCTL_SW" }
Fact { id: rc_map_posctl_sw ; name: "RC_MAP_POSCTL_SW" }
Fact { id: rc_map_return_sw ; name: "RC_MAP_RETURN_SW" }
Fact { id: rc_map_return_sw ; name: "RC_MAP_RETURN_SW" }
Fact { id: rc_map_offboard_sw ; name: "RC_MAP_OFFB_SW" }
Fact { id: rc_map_loiter_sw ; name: "RC_MAP_LOITER_SW" }
Fact { id: rc_map_loiter_sw ; name: "RC_MAP_LOITER_SW" }
Fact { id: rc_assist_th ; name: "RC_ASSIST_TH" }
Fact { id: rc_assist_th ; name: "RC_ASSIST_TH" }
@ -67,6 +68,7 @@ Item {
Fact { id: rc_auto_th ; name: "RC_AUTO_TH" }
Fact { id: rc_auto_th ; name: "RC_AUTO_TH" }
Fact { id: rc_loiter_th ; name: "RC_LOITER_TH" }
Fact { id: rc_loiter_th ; name: "RC_LOITER_TH" }
Fact { id: rc_return_th ; name: "RC_RETURN_TH" }
Fact { id: rc_return_th ; name: "RC_RETURN_TH" }
Fact { id: rc_offboard_th ; name: "RC_OFFB_TH" }
Fact { id: rc_th_user ; name: "RC_TH_USER" }
Fact { id: rc_th_user ; name: "RC_TH_USER" }
@ -81,6 +83,7 @@ Item {
property int modeChannel: rc_map_mode_sw . value
property int modeChannel: rc_map_mode_sw . value
property int posCtlChannel: rc_map_posctl_sw . value
property int posCtlChannel: rc_map_posctl_sw . value
property int returnChannel: rc_map_return_sw . value
property int returnChannel: rc_map_return_sw . value
property int offboardChannel: rc_map_offboard_sw . value
property int loiterChannel: rc_map_loiter_sw . value
property int loiterChannel: rc_map_loiter_sw . value
property real rcThUserValue: rc_th_user . value
property real rcThUserValue: rc_th_user . value
@ -187,15 +190,19 @@ Item {
/ / I f d r o p p e d o v e r a c h a n n e l t a r g e t r e m a p s w i t c h
/ / I f d r o p p e d o v e r a c h a n n e l t a r g e t r e m a p s w i t c h
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
if ( ! singleSwitchRequired || parent . Drag . target . unassignedChannel ) {
fact . value = parent . Drag . target . channel
fact . value = parent . Drag . target . channel
}
}
}
}
}
}
}
DropArea {
DropArea {
/ / T h i s w i l l c a u s e t o t i l e t o g o b a c k t o u n a s s i g n e d i f d r o p p e d h e r e
/ / T h i s w i l l c a u s e t o t i l e t o g o b a c k t o u n a s s i g n e d i f d r o p p e d h e r e
readonly property int channel: 0
readonly property int channel: 0
property bool dropAllowed: true
property bool dropAllowed: true
property bool unassignedChannel: true
id: dropArea
id: dropArea
width: parent . width
width: parent . width
@ -258,15 +265,18 @@ Item {
/ / I f d r o p p e d o v e r a c h a n n e l t a r g e t r e m a p s w i t c h
/ / I f d r o p p e d o v e r a c h a n n e l t a r g e t r e m a p s w i t c h
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
if ( ! singleSwitchRequired || parent . Drag . target . unassignedChannel ) {
fact . value = parent . Drag . target . channel
fact . value = parent . Drag . target . channel
}
}
}
}
}
}
}
}
}
}
}
onModeChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onModeChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onReturnChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onReturnChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onOffboardChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onLoiterChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onLoiterChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onPosCtlChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onPosCtlChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onRcThUserValue: if ( ! inRedistribution ) redistributeThresholds ( )
onRcThUserValue: if ( ! inRedistribution ) redistributeThresholds ( )
@ -280,11 +290,9 @@ Item {
if ( modeChannel != 0 ) {
if ( modeChannel != 0 ) {
var positions = 3 / / M a n u a l / A s s i s t / A u t o a l w a y s e x i s t
var positions = 3 / / M a n u a l / A s s i s t / A u t o a l w a y s e x i s t
var returnOnModeSwitch = modeChannel == returnChannel
var loiterOnModeSwitch = modeChannel == loiterChannel
var loiterOnModeSwitch = modeChannel == loiterChannel
var posCtlOnModeSwitch = modeChannel == posCtlChannel
var posCtlOnModeSwitch = modeChannel == posCtlChannel
positions += returnOnModeSwitch ? 1 : 0
positions += loiterOnModeSwitch ? 1 : 0
positions += loiterOnModeSwitch ? 1 : 0
positions += posCtlOnModeSwitch ? 1 : 0
positions += posCtlOnModeSwitch ? 1 : 0
@ -306,75 +314,49 @@ Item {
currentThreshold += increment
currentThreshold += increment
rc_loiter_th . value = currentThreshold
rc_loiter_th . value = currentThreshold
}
}
if ( returnOnModeSwitch ) {
currentThreshold += increment
rc_return_th . value = currentThreshold
}
inRedistribution = false
inRedistribution = false
}
}
if ( returnChannel != 0 && returnChannel != modeChannel ) {
if ( returnChannel != 0 ) {
var positions = 2 / / O n / o f f a l w a y s e x i s t
inRedistribution = true
var loiterOnReturnSwitch = returnChannel == loiterChannel
positions += loiterOnReturnSwitch ? 1 : 0
var increment = 1.0 / positions
var currentThreshold = 0.0
if ( positions == 2 ) {
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
increment = 0.25
rc_return_th . value = 0.25
}
/ / M a k e s u r e w e d o n ' t r e - e n t e r
inRedistribution = true
if ( loiterOnReturnSwitch ) {
currentThreshold += increment
rc_loiter_th . value = currentThreshold
}
currentThreshold += increment
rc_return_th . value = currentThreshold
inRedistribution = false
inRedistribution = false
}
}
if ( loiterChannel != 0 && loiterChannel != modeChannel && loiterChannel != returnChannel ) {
if ( offboardChannel != 0 ) {
inRedistribution = true
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
var increment = 0.25
rc_offboard_th . value = 0.25
var currentThreshold = 0.0
inRedistribution = false
}
/ / M a k e s u r e w e d o n ' t r e - e n t e r
if ( loiterChannel != 0 && loiterChannel != modeChannel ) {
inRedistribution = true
inRedistribution = true
currentThreshold += increment
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
rc_loiter_th . value = currentThreshold
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
rc_loiter_th . value = 0.25
inRedistribution = false
inRedistribution = false
}
}
if ( posCtlChannel != 0 & posCtlChannel != modeChannel ) {
if ( posCtlChannel != 0 & posCtlChannel != modeChannel ) {
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
var increment = 0.25
var currentThreshold = 0.0
/ / M a k e s u r e w e d o n ' t r e - e n t e r
inRedistribution = true
inRedistribution = true
currentThreshold += increment
/ / I f o n l y t w o p o s i t i o n s d o n ' t s e t t h r e s h o l d a t m i d r a n g e . S e t t i n g t o 0 . 2 5
rc_posctl_th . value = currentThreshold
/ / a l l o w s f o r t h i s c h a n n e l t o w o r k w i t h e i t h e r t w o o r t h r e e p o s i t i o n s w i t c h
rc_posctl_th . value = 0.25
inRedistribution = false
inRedistribution = false
}
}
}
}
Column {
Column {
@ -389,7 +371,8 @@ Item {
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
text: "Flight Mode switches can be assigned to any channel which is not currently being used for attitude control. All channels are displayed below. " +
text: "The Main Mode, Loiter and PostCtl switches can be assigned to any channel which is not currently being used for attitude control. The Return and Offboard switches must be assigned to their seperate channel. " +
"All channels are displayed below. " +
"You can drag Flight Modes from the Flight Modes section below to a channel and drop it there. You can also drag switches assigned to a channel " +
"You can drag Flight Modes from the Flight Modes section below to a channel and drop it there. You can also drag switches assigned to a channel " +
"to another channel or back to the Unassigned Switches section. The Switch Display section at the very bottom will show you the results of your Flight Mode setup."
"to another channel or back to the Unassigned Switches section. The Switch Display section at the very bottom will show you the results of your Flight Mode setup."
wrapMode: Text . WordWrap
wrapMode: Text . WordWrap
@ -420,10 +403,12 @@ Item {
property bool modeMapped: channel == modeChannel
property bool modeMapped: channel == modeChannel
property bool posCtlMapped: channel == posCtlChannel
property bool posCtlMapped: channel == posCtlChannel
property bool returnMapped: channel == returnChannel
property bool returnMapped: channel == returnChannel
property bool offboardMapped: channel == offboardChannel
property bool loiterMapped: channel == loiterChannel
property bool loiterMapped: channel == loiterChannel
property bool nonFlightModeMapping: throttleMapped | yawMapped | pitchMapped | rollMapped | flapsMapped | aux1Mapped | aux2Mapped
property bool nonFlightModeMapping: throttleMapped | yawMapped | pitchMapped | rollMapped | flapsMapped | aux1Mapped | aux2Mapped
property bool unassignedMapping: ! ( nonFlightModeMapping | modeMapped | posCtlMapped | returnMapped | loiterMapped )
property bool unassignedMapping: ! ( nonFlightModeMapping | modeMapped | posCtlMapped | returnMapped | offboardMapped | loiterMapped )
property bool singleSwitchMapping: returnMapped | offboardMapped
id: channelTarget
id: channelTarget
width: tileWidth
width: tileWidth
@ -433,7 +418,7 @@ Item {
states: [
states: [
State {
State {
when: dropArea . containsDrag && dropArea . dropAllowed
when: dropArea . containsDrag && dropArea . dropAllowed && ( ! dropArea . drag . source . singleSwitchRequired || dropArea . unassignedChannel )
PropertyChanges {
PropertyChanges {
target: channelHeader
target: channelHeader
color: "red"
color: "red"
@ -526,6 +511,7 @@ Item {
property bool tileVisible: visible
property bool tileVisible: visible
property bool tileDragEnabled: true
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_MODE_SW"
property string tileParam: "RC_MAP_MODE_SW"
property bool singleSwitchRequired: false
visible: modeMapped
visible: modeMapped
sourceComponent: assignedModeTileComponent
sourceComponent: assignedModeTileComponent
@ -535,15 +521,27 @@ Item {
property bool tileVisible: visible
property bool tileVisible: visible
property bool tileDragEnabled: true
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_RETURN_SW"
property string tileParam: "RC_MAP_RETURN_SW"
property bool singleSwitchRequired: true
visible: returnMapped
visible: returnMapped
sourceComponent: assignedModeTileComponent
sourceComponent: assignedModeTileComponent
}
}
Loader {
Loader {
property string tileLabel: "Offboard"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_OFFB_SW"
property bool singleSwitchRequired: true
visible: offboardMapped
sourceComponent: assignedModeTileComponent
}
Loader {
property string tileLabel: "Loiter"
property string tileLabel: "Loiter"
property bool tileVisible: visible
property bool tileVisible: visible
property bool tileDragEnabled: true
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_LOITER_SW"
property string tileParam: "RC_MAP_LOITER_SW"
property bool singleSwitchRequired: false
visible: loiterMapped
visible: loiterMapped
sourceComponent: assignedModeTileComponent
sourceComponent: assignedModeTileComponent
@ -553,6 +551,7 @@ Item {
property bool tileVisible: visible
property bool tileVisible: visible
property bool tileDragEnabled: true
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_POSCTL_SW"
property string tileParam: "RC_MAP_POSCTL_SW"
property bool singleSwitchRequired: false
visible: posCtlMapped
visible: posCtlMapped
sourceComponent: assignedModeTileComponent
sourceComponent: assignedModeTileComponent
@ -561,7 +560,8 @@ Item {
DropArea {
DropArea {
/ / D r o p s a r e n o t a l l o w e d o n c h a n n e l s w h i c h a r e m a p p e d t o n o n - f l i g h t m o d e s w i t c h e s
/ / D r o p s a r e n o t a l l o w e d o n c h a n n e l s w h i c h a r e m a p p e d t o n o n - f l i g h t m o d e s w i t c h e s
property bool dropAllowed: ! nonFlightModeMapping
property bool dropAllowed: ! nonFlightModeMapping && ! singleSwitchMapping
property bool unassignedChannel: unassignedMapping
property int channel: parent . channel
property int channel: parent . channel
id: dropArea
id: dropArea
@ -594,21 +594,31 @@ Item {
Loader {
Loader {
property string tileLabel: "Main Mode"
property string tileLabel: "Main Mode"
property string tileParam: "RC_MAP_MODE_SW"
property string tileParam: "RC_MAP_MODE_SW"
sourceComponent: unassignedModeTileComponent
property bool singleSwitchRequired: false
}
Loader {
property string tileLabel: "Return"
property string tileParam: "RC_MAP_RETURN_SW"
sourceComponent: unassignedModeTileComponent
sourceComponent: unassignedModeTileComponent
}
}
Loader {
Loader {
property string tileLabel: "Loiter"
property string tileLabel: "Loiter"
property string tileParam: "RC_MAP_LOITER_SW"
property string tileParam: "RC_MAP_LOITER_SW"
property bool singleSwitchRequired: false
sourceComponent: unassignedModeTileComponent
sourceComponent: unassignedModeTileComponent
}
}
Loader {
Loader {
property string tileLabel: "PosCtl"
property string tileLabel: "PosCtl"
property string tileParam: "RC_MAP_POSCTL_SW"
property string tileParam: "RC_MAP_POSCTL_SW"
property bool singleSwitchRequired: false
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "Return"
property string tileParam: "RC_MAP_RETURN_SW"
property bool singleSwitchRequired: true
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "Offboard"
property string tileParam: "RC_MAP_OFFB_SW"
property bool singleSwitchRequired: true
sourceComponent: unassignedModeTileComponent
sourceComponent: unassignedModeTileComponent
}
}
}
}
@ -643,9 +653,10 @@ Item {
Row {
Row {
property bool modeSwitchVisible: modeChannel != 0
property bool modeSwitchVisible: modeChannel != 0
property bool returnSwitchVisible: returnChannel != 0 && returnChannel != modeChannel
property bool loiterSwitchVisible: loiterChannel != 0 && loiterChannel != modeChannel && loiterChannel != returnChannel
property bool loiterSwitchVisible: loiterChannel != 0 && loiterChannel != modeChannel && loiterChannel != returnChannel
property bool posCtlSwitchVisible: posCtlChannel != 0 && posCtlChannel != modeChannel
property bool posCtlSwitchVisible: posCtlChannel != 0 && posCtlChannel != modeChannel
property bool returnSwitchVisible: returnChannel != 0
property bool offboardSwitchVisible: offboardChannel != 0
width: parent . width
width: parent . width
spacing: 20
spacing: 20
@ -670,14 +681,6 @@ Item {
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: ( parent . height * ( 1.0 - rc_return_th . value ) ) - ( implicitHeight / 2 )
visible: modeChannel == returnChannel
horizontalAlignment: Text . AlignRight
text: "Auto: Return"
}
QGCLabel {
width: parent . width
y: ( parent . height * ( 1.0 - rc_loiter_th . value ) ) - ( implicitHeight / 2 )
y: ( parent . height * ( 1.0 - rc_loiter_th . value ) ) - ( implicitHeight / 2 )
visible: modeChannel == loiterChannel
visible: modeChannel == loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
@ -741,9 +744,9 @@ Item {
}
}
Column {
Column {
visible: parent . return SwitchVisible
visible: parent . loiter SwitchVisible
QGCLabel { text: "Return Switch" }
QGCLabel { text: "Loiter Switch" }
Row {
Row {
Item {
Item {
@ -752,48 +755,64 @@ Item {
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: ( parent . height * ( 1.0 - rc_return _th . value ) ) - ( implicitHeight / 2 )
y: ( parent . height * ( 1.0 - rc_loiter _th . value ) ) - ( implicitHeight / 2 )
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Return "
text: "Auto: Loiter "
}
}
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: ( parent . height * ( 1.0 - rc_loiter_th . value ) ) - ( implicitHeight / 2 )
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel == loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Loiter"
text: "Auto: Mission"
}
}
}
ProgressBar {
height: progressBarHeight
orientation: Qt . Vertical
value: controller . loiterSwitchLiveRange
}
}
}
Column {
visible: parent . posCtlSwitchVisible
QGCLabel { text: "PosCtl Switch" }
Row {
Item {
height: progressBarHeight
width: 150
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: parent . height - ( implicitHeight / 2 )
y: ( parent . height * ( 1.0 - rc_posctl_th . value ) ) - ( implicitHeight / 2 )
visible: returnChannel == loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Mission"
text: "Assist: PosCtl "
}
}
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: parent . height - ( implicitHeight / 2 )
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Return Off"
text: "Assist: AltCtl "
}
}
}
}
ProgressBar {
ProgressBar {
height: progressBarHeight
height: progressBarHeight
orientation: Qt . Vertical
orientation: Qt . Vertical
value: controller . return SwitchLiveRange
value: controller . posCtl SwitchLiveRange
}
}
}
}
}
}
Column {
Column {
visible: parent . loiter SwitchVisible
visible: parent . return SwitchVisible
QGCLabel { text: "Loiter Switch" }
QGCLabel { text: "Return Switch" }
Row {
Row {
Item {
Item {
@ -802,31 +821,32 @@ Item {
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: ( parent . height * ( 1.0 - rc_loiter _th . value ) ) - ( implicitHeight / 2 )
y: ( parent . height * ( 1.0 - rc_return _th . value ) ) - ( implicitHeight / 2 )
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Loiter "
text: "Return "
}
}
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: parent . height - ( implicitHeight / 2 )
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Auto: Mission "
text: "Return Off "
}
}
}
}
ProgressBar {
ProgressBar {
height: progressBarHeight
height: progressBarHeight
orientation: Qt . Vertical
orientation: Qt . Vertical
value: controller . loiter SwitchLiveRange
value: controller . return SwitchLiveRange
}
}
}
}
}
}
Column {
Column {
visible: parent . posCtl SwitchVisible
visible: parent . offboard SwitchVisible
QGCLabel { text: "PosCtl Switch" }
QGCLabel { text: "Offboard Switch" }
Row {
Row {
Item {
Item {
@ -835,23 +855,24 @@ Item {
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: ( parent . height * ( 1.0 - rc_posctl _th . value ) ) - ( implicitHeight / 2 )
y: ( parent . height * ( 1.0 - rc_return _th . value ) ) - ( implicitHeight / 2 )
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Assist: PosCtl "
text: "Offboad "
}
}
QGCLabel {
QGCLabel {
width: parent . width
width: parent . width
y: parent . height - ( implicitHeight / 2 )
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
horizontalAlignment: Text . AlignRight
text: "Assist: AltCtl "
text: "Offboard Off "
}
}
}
}
ProgressBar {
ProgressBar {
height: progressBarHeight
height: progressBarHeight
orientation: Qt . Vertical
orientation: Qt . Vertical
value: controller . posCtl SwitchLiveRange
value: controller . offboard SwitchLiveRange
}
}
}
}
}
}