Cync
[mardrone] / mardrone / ardrone_desktop.qml
1 // uiName:Desktop
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     id:mainWindow
11     width: 1024
12     height: 800
13     maximumHeight: mainWindow.height
14     minimumHeight: 800
15     maximumWidth: 1280
16     minimumWidth: 800
17     visible: true
18
19
20     MenuBar {
21         Menu {
22             text: "File"
23             MenuItem {
24                 text: "Settings"
25                 shortcut: "Ctrl+O"
26                 onTriggered: configDialog.visible = true
27             }
28             MenuItem {
29                 text: "Close"
30                 shortcut: "Ctrl+Q"
31                 onTriggered: Qt.quit()
32             }
33         }
34         Menu {
35             text: "Edit"
36             MenuItem {
37                 text: "Copy"
38             }
39             MenuItem {
40                 text: "Paste"
41             }
42         }
43     }
44
45
46   DroneControl {
47         id:drone
48     }
49   JoyStick {
50       id:js
51       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
52       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=aileron;}
53       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
54       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
55
56   }
57
58     Column {
59         width:parent.width
60         spacing:5
61       Rectangle {
62         id:mainWiew
63         width:parent.width
64         height:480
65         //onEntered:(mainWindow.fullscreen=true)
66
67         state:"Landscape"
68         DroneVideo {
69             id:droneVideo
70             y:0
71          //       anchors.horizontalCenter: parent.horizontalCenter
72          //   anchors.horizontalCenter:parent.horizontalCenter
73             width:drone.confFullScreen? parent.width:640 ;height:width<=640 ?480*width/640:480;
74         }
75
76         EfisPFD {
77             id:hudPDF
78             y:0
79    //         anchors.horizontalCenter: parent.horizontalCenter
80             visible:drone.confShowHorizon
81             roll:drone.droneRoll
82             pitch:drone.dronePitch
83             ias:drone.droneSpeed
84             alt:drone.droneAltitude/10
85             indicatorColor:"green"
86             skyColor:"#00000000"
87             groundColor:"#00000000"
88             width:640;height:480;
89         }
90         Text {
91             y:100
92             visible:drone.confShowDebug
93             color: "#00FF00"
94             id: droneCtrlValues
95             font.pixelSize:20
96             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
97         }
98
99         Text {
100             y:115
101             visible:drone.confShowDebug
102             color: "#00FF00"
103             id: droneNavData
104             font.pixelSize:20
105             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
106         }
107
108         Text {
109             y:130
110             visible:drone.confShowDebug
111             color: "#00FF00"
112             id: droneStatus
113             font.pixelSize:20
114             text: drone.decodedStatus
115         }
116    /*     Button {
117             y:150;x:0
118             height: 50
119             width: 50
120             iconSource: "gear32x32.png"
121             onClicked:{   configDialog.visible = true }
122         }
123 */
124         JoyStickIndicator {
125
126             anchors.left:parent.left
127             anchors.bottom:parent.bottom
128             anchors.margins:10
129             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
130             border.width:1
131             color:"transparent"
132             width:100;height:100
133             xvalue:js.axis4
134             yvalue:js.axis3
135             Text {
136                 anchors.bottom: parent.bottom
137                 font.pixelSize: 10
138                 text:"       rudder"
139             }
140             Text {
141                 x:-10;y:50
142                 rotation:90
143                 font.pixelSize: 10
144                 text:"Throtle"
145             }
146         }
147
148
149         JoyStickIndicator {
150
151             anchors.right:parent.right
152             anchors.bottom:parent.bottom
153             anchors.margins:10
154             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
155             border.width:1
156             color:"transparent"
157             width:100;height:100
158             xvalue:js.axis1
159             yvalue:js.axis2
160             Text {
161                 anchors.bottom: parent.bottom
162                 font.pixelSize: 10
163                 text:"      Aileron"
164             }
165             Text {
166                 x:-15;y:50
167                 rotation:90
168                 font.pixelSize: 10
169                 text:"Elevator"
170             }
171         }
172
173             JoyStickTouch {
174                 id:lj
175                 width:280;height:280;
176                 y:200
177                 visible: !drone.confUseAccel & !drone.confUseJoyStick
178                 anchors.left:parent.left
179                 anchors.margins:50
180                 onYvChanged:{drone.pitch=yv/200.0;}
181                 onXvChanged:{drone.roll=xv/200.0;}
182
183
184             }
185
186             JoyStickTouch {
187                  visible: !drone.confUseJoyStick
188                 id:rj
189                 y:200
190                 anchors.right:parent.right
191                 width:280;height:280;
192                 anchors.margins:50
193                 onYvChanged:{drone.vVelocity=-1*yv/200.0;}
194                 onXvChanged:{drone.yaw=xv/200.0;}
195                 onPressedChanged: { drone.ctrlActive=pressed;}
196             }
197       }
198         Row {
199             spacing:5
200
201             EfisPFD {
202                 id:pDF
203                 width:300
204                 height:320
205                 showHSI:true
206                 roll:drone.droneRoll
207                 pitch:drone.dronePitch
208                 ias:drone.droneSpeed
209                 alt:drone.droneAltitude/10
210            //     bezel:"glareshield1.png"
211             }
212         Grid {
213             columns: 3
214
215
216         AltGauge {
217             width:120
218             height:120
219             id:altGauge
220             value:drone.droneAltitude/10
221             bezel:"bezel.png"
222         }
223         AttitudeGauge {
224             width:120
225             height:120
226             id:attGauge
227             roll:drone.droneRoll
228             pitch:drone.dronePitch
229             bezel:"bezel.png"
230         }
231         HeadingGauge {
232             width:120
233             height:120
234             id:hdgGauge
235             value:drone.droneYaw
236             bezel:"bezel.png"
237         }
238         GaugeArc {
239             width:120
240             height:120
241             id:fuelGauge
242             anchors.margins:10
243             displayScale:0.85
244             font.pixelSize:10
245             tickIncrement:10
246             tickSpacing:20
247             tickMinor:5
248             lowPosition:220
249             highPosition:120
250             low:0
251             high:100
252             gaugeStyle:2
253             color:"white"
254             value:drone.droneVBat
255             lineWidth:2
256             backColor:"black"
257         }
258         GaugeHSI{
259             anchors.margins:10
260             displayScale:0.7
261             width:120
262             height:120
263             font.pixelSize:10
264             tickIncrement:30
265             tickSpacing:10
266             tickMinor:5
267             gaugeStyle:2
268             color:"white"
269             backColor:"black"
270             id:hsi
271         }
272
273         Row {
274             spacing: 5
275             anchors.rightMargin: 10
276             height:100
277         BarGauge {
278            val:drone.pwm_motor1;
279            max: 255
280            height:100
281         }
282         BarGauge {
283             val:drone.pwm_motor2;
284             max: 255
285             height:100
286         }
287         BarGauge {
288             val:drone.pwm_motor3;
289             max: 255
290             height:100
291         }
292         BarGauge {
293             val:drone.pwm_motor4;
294             max: 255
295             height:100
296         }
297         BarGauge {
298             val:drone.droneVBat
299             max: 100
300             height:100
301         }
302         }
303             } // Grid if instruments
304         } // Column ( Main window content )
305
306         Dialog {
307             id:configDialog
308             width:800
309             height:600
310             data:ConfigDialogDesktop {}
311         }
312     }
313   } // Main page
314
315