@ -60,6 +60,7 @@ Item {
@@ -60,6 +60,7 @@ Item {
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_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_assist_th ; name: "RC_ASSIST_TH" }
@ -67,6 +68,7 @@ Item {
@@ -67,6 +68,7 @@ Item {
Fact { id: rc_auto_th ; name: "RC_AUTO_TH" }
Fact { id: rc_loiter_th ; name: "RC_LOITER_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" }
@ -81,6 +83,7 @@ Item {
@@ -81,6 +83,7 @@ Item {
property int modeChannel: rc_map_mode_sw . value
property int posCtlChannel: rc_map_posctl_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 real rcThUserValue: rc_th_user . value
@ -187,15 +190,19 @@ Item {
@@ -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
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
fact . value = parent . Drag . target . channel
if ( ! singleSwitchRequired || parent . Drag . target . unassignedChannel ) {
fact . value = parent . Drag . target . channel
}
}
}
}
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
readonly property int channel: 0
property bool dropAllowed: true
readonly property int channel: 0
property bool dropAllowed: true
property bool unassignedChannel: true
id: dropArea
width: parent . width
@ -258,7 +265,9 @@ Item {
@@ -258,7 +265,9 @@ 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
if ( parent . Drag . target && parent . Drag . target . dropAllowed ) {
fact . value = parent . Drag . target . channel
if ( ! singleSwitchRequired || parent . Drag . target . unassignedChannel ) {
fact . value = parent . Drag . target . channel
}
}
}
}
@ -267,6 +276,7 @@ Item {
@@ -267,6 +276,7 @@ Item {
onModeChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onReturnChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onOffboardChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onLoiterChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onPosCtlChannelChanged: if ( ! inRedistribution ) redistributeThresholds ( )
onRcThUserValue: if ( ! inRedistribution ) redistributeThresholds ( )
@ -280,11 +290,9 @@ Item {
@@ -280,11 +290,9 @@ Item {
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 returnOnModeSwitch = modeChannel == returnChannel
var loiterOnModeSwitch = modeChannel == loiterChannel
var posCtlOnModeSwitch = modeChannel == posCtlChannel
positions += returnOnModeSwitch ? 1 : 0
positions += loiterOnModeSwitch ? 1 : 0
positions += posCtlOnModeSwitch ? 1 : 0
@ -306,75 +314,49 @@ Item {
@@ -306,75 +314,49 @@ Item {
currentThreshold += increment
rc_loiter_th . value = currentThreshold
}
if ( returnOnModeSwitch ) {
currentThreshold += increment
rc_return_th . value = currentThreshold
}
inRedistribution = false
}
if ( returnChannel != 0 && returnChannel != modeChannel ) {
var positions = 2 / / O n / o f f a l w a y s e x i s t
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
/ / 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
}
/ / M a k e s u r e w e d o n ' t r e - e n t e r
if ( returnChannel != 0 ) {
inRedistribution = true
if ( loiterOnReturnSwitch ) {
currentThreshold += increment
rc_loiter_th . value = currentThreshold
}
currentThreshold += increment
rc_return_th . value = currentThreshold
/ / 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
rc_return_th . value = 0.25
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
/ / 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
currentThreshold += increment
rc_loiter_th . value = currentThreshold
/ / 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
rc_loiter_th . value = 0.25
inRedistribution = false
}
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
currentThreshold += increment
rc_posctl_th . value = currentThreshold
/ / 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
rc_posctl_th . value = 0.25
inRedistribution = false
}
}
Column {
@ -389,9 +371,10 @@ Item {
@@ -389,9 +371,10 @@ Item {
QGCLabel {
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. " +
"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."
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 " +
"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
}
@ -420,10 +403,12 @@ Item {
@@ -420,10 +403,12 @@ Item {
property bool modeMapped: channel == modeChannel
property bool posCtlMapped: channel == posCtlChannel
property bool returnMapped: channel == returnChannel
property bool offboardMapped: channel == offboardChannel
property bool loiterMapped: channel == loiterChannel
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
width: tileWidth
@ -433,7 +418,7 @@ Item {
@@ -433,7 +418,7 @@ Item {
states: [
State {
when: dropArea . containsDrag && dropArea . dropAllowed
when: dropArea . containsDrag && dropArea . dropAllowed && ( ! dropArea . drag . source . singleSwitchRequired || dropArea . unassignedChannel )
PropertyChanges {
target: channelHeader
color: "red"
@ -522,37 +507,51 @@ Item {
@@ -522,37 +507,51 @@ Item {
sourceComponent: assignedModeTileComponent
}
Loader {
property string tileLabel: "Main Mode"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_MODE_SW"
property string tileLabel: "Main Mode"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_MODE_SW"
property bool singleSwitchRequired: false
visible: modeMapped
sourceComponent: assignedModeTileComponent
}
Loader {
property string tileLabel: "Return"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_RETURN_SW"
property string tileLabel: "Return"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_RETURN_SW"
property bool singleSwitchRequired: true
visible: returnMapped
sourceComponent: assignedModeTileComponent
}
Loader {
property string tileLabel: "Loiter"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_LOITER_SW"
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 bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_LOITER_SW"
property bool singleSwitchRequired: false
visible: loiterMapped
sourceComponent: assignedModeTileComponent
}
Loader {
property string tileLabel: "PosCtl"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_POSCTL_SW"
property string tileLabel: "PosCtl"
property bool tileVisible: visible
property bool tileDragEnabled: true
property string tileParam: "RC_MAP_POSCTL_SW"
property bool singleSwitchRequired: false
visible: posCtlMapped
sourceComponent: assignedModeTileComponent
@ -561,7 +560,8 @@ Item {
@@ -561,7 +560,8 @@ Item {
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
property bool dropAllowed: ! nonFlightModeMapping
property bool dropAllowed: ! nonFlightModeMapping && ! singleSwitchMapping
property bool unassignedChannel: unassignedMapping
property int channel: parent . channel
id: dropArea
@ -592,24 +592,34 @@ Item {
@@ -592,24 +592,34 @@ Item {
spacing: 5
Loader {
property string tileLabel: "Main Mode"
property string tileParam: "RC_MAP_MODE_SW"
sourceComponent: unassignedModeTileComponent
property string tileLabel: "Main Mode"
property string tileParam: "RC_MAP_MODE_SW"
property bool singleSwitchRequired: false
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "Loiter"
property string tileParam: "RC_MAP_LOITER_SW"
property bool singleSwitchRequired: false
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "Return"
property string tileParam: "RC_MAP_RETURN_SW"
sourceComponent: unassignedModeTileComponent
property string tileLabel: "PosCtl"
property string tileParam: "RC_MAP_POSCTL_SW"
property bool singleSwitchRequired: false
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "Loiter"
property string tileParam: "RC_MAP_LOITER_SW"
sourceComponent: unassignedModeTileComponent
property string tileLabel: "Return"
property string tileParam: "RC_MAP_RETURN_SW"
property bool singleSwitchRequired: true
sourceComponent: unassignedModeTileComponent
}
Loader {
property string tileLabel: "PosCtl"
property string tileParam: "RC_MAP_POSCTL_SW"
sourceComponent: unassignedModeTileComponent
property string tileLabel: "Offboard"
property string tileParam: "RC_MAP_OFFB_SW"
property bool singleSwitchRequired: true
sourceComponent: unassignedModeTileComponent
}
}
@ -643,9 +653,10 @@ Item {
@@ -643,9 +653,10 @@ Item {
Row {
property bool modeSwitchVisible: modeChannel != 0
property bool returnSwitchVisible: returnChannel != 0 && returnChannel != modeChannel
property bool loiterSwitchVisible: loiterChannel != 0 && loiterChannel != modeChannel && loiterChannel != returnChannel
property bool posCtlSwitchVisible: posCtlChannel != 0 && posCtlChannel != modeChannel
property bool returnSwitchVisible: returnChannel != 0
property bool offboardSwitchVisible: offboardChannel != 0
width: parent . width
spacing: 20
@ -670,14 +681,6 @@ Item {
@@ -670,14 +681,6 @@ Item {
QGCLabel {
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 )
visible: modeChannel == loiterChannel
horizontalAlignment: Text . AlignRight
@ -741,9 +744,9 @@ Item {
@@ -741,9 +744,9 @@ Item {
}
Column {
visible: parent . return SwitchVisible
visible: parent . loiter SwitchVisible
QGCLabel { text: "Return Switch" }
QGCLabel { text: "Loiter Switch" }
Row {
Item {
@ -752,48 +755,64 @@ Item {
@@ -752,48 +755,64 @@ Item {
QGCLabel {
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
text: "Auto: Return "
text: "Auto: Loiter "
}
QGCLabel {
width: parent . width
y: ( parent . height * ( 1.0 - rc_loiter_th . value ) ) - ( implicitHeight / 2 )
visible: returnChannel == loiterChannel
y: parent . height - ( implicitHeight / 2 )
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 {
width: parent . width
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel == loiterChannel
y: ( parent . height * ( 1.0 - rc_posctl_th . value ) ) - ( implicitHeight / 2 )
horizontalAlignment: Text . AlignRight
text: "Auto: Mission"
text: "Assist: PosCtl "
}
QGCLabel {
width: parent . width
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
text: "Auto: Return Off"
text: "Assist: AltCtl "
}
}
ProgressBar {
height: progressBarHeight
orientation: Qt . Vertical
value: controller . return SwitchLiveRange
value: controller . posCtl SwitchLiveRange
}
}
}
Column {
visible: parent . loiter SwitchVisible
visible: parent . return SwitchVisible
QGCLabel { text: "Loiter Switch" }
QGCLabel { text: "Return Switch" }
Row {
Item {
@ -802,31 +821,32 @@ Item {
@@ -802,31 +821,32 @@ Item {
QGCLabel {
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
text: "Auto: Loiter "
text: "Return "
}
QGCLabel {
width: parent . width
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
text: "Auto: Mission "
text: "Return Off "
}
}
ProgressBar {
height: progressBarHeight
orientation: Qt . Vertical
value: controller . loiter SwitchLiveRange
value: controller . return SwitchLiveRange
}
}
}
Column {
visible: parent . posCtl SwitchVisible
visible: parent . offboard SwitchVisible
QGCLabel { text: "PosCtl Switch" }
QGCLabel { text: "Offboard Switch" }
Row {
Item {
@ -835,23 +855,24 @@ Item {
@@ -835,23 +855,24 @@ Item {
QGCLabel {
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
text: "Assist: PosCtl "
text: "Offboad "
}
QGCLabel {
width: parent . width
y: parent . height - ( implicitHeight / 2 )
visible: returnChannel != loiterChannel
horizontalAlignment: Text . AlignRight
text: "Assist: AltCtl "
text: "Offboard Off "
}
}
ProgressBar {
height: progressBarHeight
orientation: Qt . Vertical
value: controller . posCtl SwitchLiveRange
value: controller . offboard SwitchLiveRange
}
}
}