0.2 version add desktop components multitouch, joystick, multicast
[mardrone] / mardrone / ardrone_desktop.qml
1
2 import Drone 1.0
3 import QtQuick 1.0
4 import QtDesktop 0.1
5 import gauges 1.0
6 import JoyStick 1.0
7
8 Window {
9     title: "MArdrone"
10
11     width: 1024
12     height: 480
13     maximumHeight: mainWindow.height
14     minimumHeight: 480
15     maximumWidth: 1280
16     minimumWidth: 800
17     visible: true
18
19     MenuBar {
20         Menu {
21             text: "File"
22             MenuItem {
23                 text: "Settings"
24                 shortcut: "Ctrl+O"
25                 onTriggered: configDialog.visible = true
26             }
27             MenuItem {
28                 text: "Close"
29                 shortcut: "Ctrl+Q"
30                 onTriggered: Qt.quit()
31             }
32         }
33         Menu {
34             text: "Edit"
35             MenuItem {
36                 text: "Copy"
37             }
38             MenuItem {
39                 text: "Paste"
40             }
41         }
42     }
43
44
45   DroneControl {
46         id:drone
47     }
48   JoyStick {
49       id:js
50       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
51       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=aileron;}
52       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
53       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
54
55   }
56
57       Rectangle {
58         id:mainWindow
59         width:640
60         height:480
61         //onEntered:(mainWindow.fullscreen=true)
62
63         state:"Landscape"
64         DroneVideo {
65             id:droneVideo
66             y:0
67             x:0
68          //   anchors.horizontalCenter:parent.horizontalCenter
69             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
70         }
71
72         EfisPFD {
73             id:hudPDF
74             y:0
75             x:0
76             visible:drone.confShowHorizon
77             roll:drone.droneRoll
78             pitch:drone.dronePitch
79             ias:drone.droneSpeed
80             alt:drone.droneAltitude
81             indicatorColor:"green"
82             skyColor:"#00000000"
83             groundColor:"#00000000"
84             width:640;height:480;
85         }
86
87
88         Text {
89             y:100
90  //           visible:drone.confUseAccel
91             color: "#00FF00"
92             id: droneCtrlValues
93             font.pixelSize:20
94             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
95         }
96
97         Text {
98             y:115
99             visible:drone.confShowDebug
100             color: "#00FF00"
101             id: droneNavData
102             font.pixelSize:20
103             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
104         }
105
106         Text {
107             y:130
108             visible:drone.confShowDebug
109             color: "#00FF00"
110             id: droneStatus
111             font.pixelSize:20
112             text: drone.decodedStatus
113         }
114         Button {
115             y:150;x:0
116             height: 50
117             width: 50
118             iconSource: "gear32x32.png"
119             onClicked:{   configDialog.visible = true }
120         }
121
122         JoyStickIndicator {
123             x:200;y:350
124             visible:drone.showJSIndivators
125             border.width:1
126             color:"transparent"
127             width:100;height:100
128             xvalue:js.axis4
129             yvalue:js.axis3
130             Text {
131                 anchors.bottom: parent.bottom
132                 font.pixelSize: 10
133                 text:"       rudder"
134             }
135             Text {
136                 x:-10;y:50
137                 rotation:90
138                 font.pixelSize: 10
139                 text:"Throtle"
140             }
141         }
142
143
144         JoyStickIndicator {
145             x:500;y:350
146             visible:drone.showJSIndivators
147             border.width:1
148             color:"transparent"
149             width:100;height:100
150             xvalue:js.axis1
151             yvalue:js.axis2
152             Text {
153                 anchors.bottom: parent.bottom
154                 font.pixelSize: 10
155                 text:"      Aileron"
156             }
157             Text {
158                 x:-15;y:50
159                 rotation:90
160                 font.pixelSize: 10
161                 text:"Elevator"
162             }
163         }
164
165             JoyStickTouch {
166                 id:lj
167                 width:280;height:280;
168                 y:200
169                 visible: !drone.confUseAccel & !drone.confUseJoyStick
170                 anchors.left:parent.left
171                 anchors.margins:50
172                 onYvChanged:{drone.pitch=yv/200.0;}
173                 onXvChanged:{drone.roll=xv/200.0;}
174
175
176             }
177
178             JoyStickTouch {
179                  visible: !drone.confUseJoyStick
180                 id:rj
181                 y:200
182                 anchors.right:parent.right
183                 width:280;height:280;
184                 anchors.margins:50
185                 onYvChanged:{drone.vVelocity=-1*yv/200.0;}
186                 onXvChanged:{drone.yaw=xv/200.0;}
187                 onPressedChanged: { drone.ctrlActive=pressed;}
188             }
189         Column {
190             anchors.left: droneVideo.right
191             EfisPFD {
192                 id:pDF
193                 width:320
194                 height:240
195     //            visible:drone.confShowHorizon
196                 roll:drone.droneRoll
197                 pitch:drone.dronePitch
198                 ias:drone.droneSpeed
199                 alt:drone.droneAltitude
200             }
201         Row {
202             spacing: 5
203             anchors.right:parent.right
204             anchors.rightMargin: 10
205             y:100
206             height:100
207         BarGauge {
208            val:drone.pwm_motor1;
209            max: 255
210            height:100
211         }
212         BarGauge {
213             val:drone.pwm_motor2;
214             max: 255
215             height:100
216         }
217         BarGauge {
218             val:drone.pwm_motor3;
219             max: 255
220             height:100
221         }
222         BarGauge {
223             val:drone.pwm_motor4;
224             max: 255
225             height:100
226         }
227         BarGauge {
228             val:drone.droneVBat
229             max: 100
230             height:100
231         }
232         }
233         AltGauge {
234             width:150
235             height:150
236             id:altGauge
237         //    value:drone.altitude
238             value:testAlt.value
239         }
240         Slider {
241            id: testAlt
242            maximumValue:1000
243         }
244
245         }
246         Dialog {
247             id:configDialog
248             width:800
249             height:600
250             data:ConfigDialogDesktop {}
251         }
252
253         } // Main page
254     }
255