Sync refactoring for multiple platforms
[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     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
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
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
91
92         Text {
93             y:100
94
95  //           visible:drone.confUseAccel
96             color: "#00FF00"
97             id: droneCtrlValues
98             font.pixelSize:20
99             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
100         }
101
102         Text {
103             y:115
104             visible:drone.confShowDebug
105             color: "#00FF00"
106             id: droneNavData
107             font.pixelSize:20
108             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
109         }
110
111         Text {
112             y:130
113             visible:drone.confShowDebug
114             color: "#00FF00"
115             id: droneStatus
116             font.pixelSize:20
117             text: drone.decodedStatus
118         }
119    /*     Button {
120             y:150;x:0
121             height: 50
122             width: 50
123             iconSource: "gear32x32.png"
124             onClicked:{   configDialog.visible = true }
125         }
126 */
127         JoyStickIndicator {
128
129             anchors.left:parent.left
130             anchors.bottom:parent.bottom
131             anchors.margins:10
132             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
133             border.width:1
134             color:"transparent"
135             width:100;height:100
136             xvalue:js.axis4
137             yvalue:js.axis3
138             Text {
139                 anchors.bottom: parent.bottom
140                 font.pixelSize: 10
141                 text:"       rudder"
142             }
143             Text {
144                 x:-10;y:50
145                 rotation:90
146                 font.pixelSize: 10
147                 text:"Throtle"
148             }
149         }
150
151
152         JoyStickIndicator {
153
154             anchors.right:parent.right
155             anchors.bottom:parent.bottom
156             anchors.margins:10
157             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
158             border.width:1
159             color:"transparent"
160             width:100;height:100
161             xvalue:js.axis1
162             yvalue:js.axis2
163             Text {
164                 anchors.bottom: parent.bottom
165                 font.pixelSize: 10
166                 text:"      Aileron"
167             }
168             Text {
169                 x:-15;y:50
170                 rotation:90
171                 font.pixelSize: 10
172                 text:"Elevator"
173             }
174         }
175
176             JoyStickTouch {
177                 id:lj
178                 width:280;height:280;
179                 y:200
180                 visible: !drone.confUseAccel & !drone.confUseJoyStick
181                 anchors.left:parent.left
182                 anchors.margins:50
183                 onYvChanged:{drone.pitch=yv/200.0;}
184                 onXvChanged:{drone.roll=xv/200.0;}
185
186
187             }
188
189             JoyStickTouch {
190                  visible: !drone.confUseJoyStick
191                 id:rj
192                 y:200
193                 anchors.right:parent.right
194                 width:280;height:280;
195                 anchors.margins:50
196                 onYvChanged:{drone.vVelocity=-1*yv/200.0;}
197                 onXvChanged:{drone.yaw=xv/200.0;}
198                 onPressedChanged: { drone.ctrlActive=pressed;}
199             }
200       }
201         Row {
202             spacing:5
203
204             EfisPFD {
205                 id:pDF
206                 width:320
207                 height:240
208                 roll:drone.droneRoll
209                 pitch:drone.dronePitch
210                 ias:drone.droneSpeed
211                 alt:drone.droneAltitude/10
212            //     bezel:"glareshield1.png"
213             }
214         Grid {
215             columns: 4
216
217
218         AltGauge {
219             width:150
220             height:150
221             id:altGauge
222             value:drone.droneAltitude/10
223             bezel:"bezel.png"
224         }
225         AttitudeGauge {
226             width:150
227             height:150
228             id:attGauge
229             roll:drone.droneRoll
230             pitch:drone.dronePitch
231             bezel:"bezel.png"
232         }
233         HeadingGauge {
234             width:150
235             height:150
236             id:hdgGauge
237             value:drone.droneYaw
238             bezel:"bezel.png"
239         }
240         Row {
241             spacing: 5
242             anchors.rightMargin: 10
243             height:100
244         BarGauge {
245            val:drone.pwm_motor1;
246            max: 255
247            height:100
248         }
249         BarGauge {
250             val:drone.pwm_motor2;
251             max: 255
252             height:100
253         }
254         BarGauge {
255             val:drone.pwm_motor3;
256             max: 255
257             height:100
258         }
259         BarGauge {
260             val:drone.pwm_motor4;
261             max: 255
262             height:100
263         }
264         BarGauge {
265             val:drone.droneVBat
266             max: 100
267             height:100
268         }
269         }
270             } // Grid if instruments
271         } // Column ( Main window content )
272
273         Dialog {
274             id:configDialog
275             width:800
276             height:600
277             data:ConfigDialogDesktop {}
278         }
279     }
280   } // Main page
281
282