Joinig to video broadcast group on OSX improved
[mardrone] / mardrone / ardrone_android.qml
1 // uiName:Android
2 import QtQuick 1.0
3 import com.nokia.android 1.1
4 import Drone 1.0
5 //import gauges 1.0
6 import JoyStick 1.0
7
8 PageStackWindow {
9     id:mainWindow
10     initialPage: mainpageComponent
11     showStatusBar: false
12 //    fullscreen:true
13     property Component dialogComponent
14 // property alias m: mainPage
15
16     ToolBarLayout {
17         id: commonTools
18         ToolButton {
19             flat: true
20             iconSource: "toolbar-back"
21             onClicked: mainWindow.pageStack.depth <= 1 ? Qt.quit() : mainWindow.pageStack.pop()
22         }
23    }
24   DroneControl {
25         id:drone
26     }
27   JoyStick {
28       id:js
29       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
30       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=-1.0*aileron;}
31       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
32       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
33
34   }
35   Keys.onUpPressed: {
36                 console.debug("QML:Keys.onUpPressed",event.key)
37                 if (event.key == Qt.Key_TopMenu)
38                     console.debug("QML: opening menu!")
39                 else if (event.key == Qt.Key_MediaPrevious) {
40                     console.debug("QML: closing! (maybe)")
41                     pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
42                 }
43             }
44   Keys.onPressed: {
45                 console.debug("QML:Keys.onPressed",event.key)
46                 if (event.key == Qt.Key_TopMenu)
47                     console.debug("QML: opening menu!")
48                 else if (event.key == Qt.Key_MediaPrevious) {
49                     console.debug("QML: closing! (maybe)")
50                     pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
51                 }
52             }
53
54   function backKey() {
55        console.debug("QML: backKey")
56       pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
57     }
58
59
60     Component {
61       id: mainpageComponent
62
63       Page {
64         id:mainPage
65         property bool connectingBoxVisible:true
66         //onEntered:(mainWindow.fullscreen=true)
67
68         state:"Landscape"
69         DroneVideo {
70             id:droneVideo
71             y:0
72             x:0
73            // anchors.horizontalCenter:parent.horizontalCenter
74             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
75         }
76         Binding {
77           target:drone
78           property:"logSeq"
79           value: droneVideo.frameSeq;
80         }
81         EfisPFD {
82             id:hudPDF
83             y:0
84             anchors.horizontalCenter: parent.horizontalCenter
85             visible:drone.confShowHorizon
86             roll:drone.droneRoll
87             pitch:drone.dronePitch
88             ias:drone.droneSpeed
89             alt:drone.droneAltitude
90             heading:drone.droneYaw
91             indicatorColor:"#00FF00"
92             skyColor:"#00000000"
93             groundColor:"#00000000"
94             width:500;height:400;
95         }
96
97         Text {
98             y:50
99             visible:drone.confShowDebug
100             color: "#00FF00"
101             id: droneCtrlValues
102             font.pixelSize:25
103             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
104         }
105
106         Text {
107             y:70
108             visible:drone.confShowDebug
109             color: "#00FF00"
110             id: droneNavData
111             font.pixelSize:25
112             text: "pitch=" + drone.dronePitch.toFixed(2) + " roll= " +  drone.droneRoll.toFixed(2) + "yaw=" + drone.droneYaw.toFixed(2) + " alt= " +  drone.droneAltitude.toFixed(2)
113         }
114
115         Text {
116             y:100
117             visible:drone.confShowDebug
118             color: "#00FF00"
119             id: droneStatus
120             font.pixelSize:20
121             text: drone.decodedStatus
122         }
123         Button {
124             y:150;x:0
125             height: 50
126             width: 50
127             z:2 // This is visible even connecting to drone
128             iconSource: "gear32x32.png"
129             onClicked:{   //mainWindow.fullscreen = false ;
130                      pageStack.push(dialogComponent);
131             }
132         }
133
134         JoyStickIndicator {
135             x:200;y:350
136             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
137             border.width:1
138             color:"transparent"
139             width:100;height:100
140             xvalue:js.axis4
141             yvalue:js.axis3
142             Text {
143                 anchors.bottom: parent.bottom
144                 font.pixelSize: 10
145                 text:"       rudder"
146             }
147             Text {
148                 x:-10;y:50
149                 rotation:90
150                 font.pixelSize: 10
151                 text:"Throtle"
152             }
153         }
154
155
156         JoyStickIndicator {
157             x:500;y:350
158             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
159             border.width:1
160             color:"transparent"
161             width:100;height:100
162             xvalue:js.axis1
163             yvalue:js.axis2
164             Text {
165                 anchors.bottom: parent.bottom
166                 font.pixelSize: 10
167                 text:"      Aileron"
168             }
169             Text {
170                 x:-15;y:50
171                 rotation:90
172                 font.pixelSize: 10
173                 text:"Elevator"
174             }
175         }
176
177         JoyStickTouch {
178             id:lj
179             width:200;height:200;
180
181             visible: !drone.confUseAccel & !drone.confUseJoyStick
182             anchors.left:parent.left
183             anchors.bottom:parent.bottom
184             anchors.margins:10
185             joyBackground: ""
186             onYvChanged:{drone.vVelocity=-1*yv/200.0;}
187             onXvChanged:{drone.yaw=xv/200.0;}
188             onPressedChanged: { drone.ctrlActive=pressed;}
189         }
190
191         JoyStickTouch {
192              visible: !drone.confUseJoyStick
193             id:rj
194             joyBackground: ""
195             anchors.right:parent.right
196             anchors.bottom:parent.bottom
197             width:200;height:200;
198             anchors.margins:10
199             onYvChanged:{drone.pitch=yv/200.0;}
200             onXvChanged:{drone.roll=xv/200.0;}
201         }
202
203         Row {
204             spacing: 5
205             anchors.right:parent.right
206             anchors.rightMargin: 10
207             y:100
208             height:100
209         BarGauge {
210            val:drone.pwm_motor1;
211            max: 255
212            height:100
213         }
214         BarGauge {
215             val:drone.pwm_motor2;
216             max: 255
217             height:100
218         }
219         BarGauge {
220             val:drone.pwm_motor3;
221             max: 255
222             height:100
223         }
224         BarGauge {
225             val:drone.pwm_motor4;
226             max: 255
227             height:100
228         }
229         BarGauge {
230             val:drone.droneVBat
231             max: 100
232             height:100
233         }
234         }
235
236         Button {
237             x:400
238             width:80
239             height:50
240             id:flyButton
241             anchors.bottom:parent.bottom
242             anchors.margins:15
243             text:"Fly";
244             checkable:true
245             onClicked:{drone.fly=checked;
246             // mainWindow.fullsecreen=checked;
247             }
248         }
249         Button {
250             x:500;
251             width:90
252             height:50
253             id:emergencyButton
254             anchors.bottom:parent.bottom
255             anchors.margins:15
256             text:"Emrg";
257             checkable:true
258             onClicked:{drone.emergency=checked;}
259         }
260
261         Button {
262             x:600;
263             width:100
264             height:50
265             id:recordButton
266             anchors.bottom:parent.bottom
267             anchors.margins:15
268             text:"Rec";
269             checkable:true
270             onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;}
271         }
272         Text {
273             y:700
274             anchors.bottom:parent.bottom
275        //     visible:droneVideo.recVideo
276             color: "#00FF00"
277             id: droneFrameSeq
278             font.pixelSize:25
279             text: droneVideo.videoFileName+ " "+droneVideo.frameSeq
280         }
281
282
283             Connections {
284                 target:drone
285                 onConnectedChanged:{
286                     console.log("Connected to drone");
287                     connectingDialog.accept();}
288             }
289             QueryDialog {
290                 id:connectingDialog
291                 titleText:"Connecting to Drone"
292                 message:"Connecting to Drone "+ drone.confDroneIp
293                 acceptButtonText:"OK"
294                 Component.onCompleted: {
295                     console.log("ConectionDialog Opened");
296                     if(!drone.connected) open(); }
297             }
298         } // Main page
299     }
300
301      Component.onCompleted: {
302          if (mainpageComponent.status != Component.Ready)
303              //        pageStack.push(mainpageComponent);
304              //  else
305                      console.log("Error loading component:", mainpageComponent.errorString());
306          dialogComponent = Qt.createComponent("ConfigDialogAndroid.qml");
307
308         }
309  }