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