7451b9a082ff679f37a8a22e6d63c47f7530c76d
[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
39     Component {
40       id: mainpageComponent
41
42       Page {
43         id:mainPage
44         property int frameSeq:0
45         property bool connectingBoxVisible:true
46         //onEntered:(mainWindow.fullscreen=true)
47
48         state:"Landscape"
49         DroneVideo {
50             id:droneVideo
51             y:0
52             x:0
53            // anchors.horizontalCenter:parent.horizontalCenter
54             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
55
56         }
57         Binding {
58           target:drone
59           property:"logSeq"
60           value: droneVideo.frameSeq;
61         }
62         EfisPFD {
63             id:hudPDF
64             y:0
65             anchors.horizontalCenter: parent.horizontalCenter
66             visible:drone.confShowHorizon
67             roll:drone.droneRoll
68             pitch:drone.dronePitch
69             ias:drone.droneSpeed
70             alt:drone.droneAltitude
71             indicatorColor:"#00FF00"
72             skyColor:"#00000000"
73             groundColor:"#00000000"
74             width:500;height:400;
75         }
76
77
78         Text {
79             y:50
80  //           visible:drone.confUseAccel
81             visible:drone.confShowDebug
82             color: "#00FF00"
83             id: droneCtrlValues
84             font.pixelSize:25
85             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
86         }
87
88         Text {
89             y:70
90             visible:drone.confShowDebug
91             color: "#00FF00"
92             id: droneNavData
93             font.pixelSize:25
94             text: "pitch=" + drone.dronePitch.toFixed(2) + " roll= " +  drone.droneRoll.toFixed(2) + "yaw=" + drone.droneYaw.toFixed(2) + " alt= " +  drone.droneAltitude.toFixed(2)
95         }
96
97         Text {
98             y:100
99             visible:drone.confShowDebug
100             color: "#00FF00"
101             id: droneStatus
102             font.pixelSize:20
103             text: drone.decodedStatus
104         }
105         Button {
106             y:150;x:0
107             height: 50
108             width: 50
109             z:2 // This is visible even connecting to drone
110             iconSource: "gear32x32.png"
111             onClicked:{   //mainWindow.fullscreen = false ;
112                      pageStack.push(dialogComponent);
113             }
114         }
115
116         JoyStickIndicator {
117             x:200;y:350
118             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
119             border.width:1
120             color:"transparent"
121             width:100;height:100
122             xvalue:js.axis4
123             yvalue:js.axis3
124             Text {
125                 anchors.bottom: parent.bottom
126                 font.pixelSize: 10
127                 text:"       rudder"
128             }
129             Text {
130                 x:-10;y:50
131                 rotation:90
132                 font.pixelSize: 10
133                 text:"Throtle"
134             }
135         }
136
137
138         JoyStickIndicator {
139             x:500;y:350
140             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
141             border.width:1
142             color:"transparent"
143             width:100;height:100
144             xvalue:js.axis1
145             yvalue:js.axis2
146             Text {
147                 anchors.bottom: parent.bottom
148                 font.pixelSize: 10
149                 text:"      Aileron"
150             }
151             Text {
152                 x:-15;y:50
153                 rotation:90
154                 font.pixelSize: 10
155                 text:"Elevator"
156             }
157         }
158
159         JoyStickTouch {
160             id:lj
161             width:200;height:200;
162
163             visible: !drone.confUseAccel & !drone.confUseJoyStick
164             anchors.left:parent.left
165             anchors.bottom:parent.bottom
166             anchors.margins:10
167             joyBackground: ""
168             onYvChanged:{drone.vVelocity=-1*yv/200.0;}
169             onXvChanged:{drone.yaw=xv/200.0;}
170             onPressedChanged: { drone.ctrlActive=pressed;}
171         }
172
173         JoyStickTouch {
174              visible: !drone.confUseJoyStick
175             id:rj
176
177             joyBackground: ""
178             anchors.right:parent.right
179             anchors.bottom:parent.bottom
180             width:200;height:200;
181             anchors.margins:10
182             onYvChanged:{drone.pitch=yv/200.0;}
183             onXvChanged:{drone.roll=xv/200.0;}
184         }
185
186         Row {
187             spacing: 5
188             anchors.right:parent.right
189             anchors.rightMargin: 10
190             y:100
191             height:100
192         BarGauge {
193            val:drone.pwm_motor1;
194            max: 255
195            height:100
196         }
197         BarGauge {
198             val:drone.pwm_motor2;
199             max: 255
200             height:100
201         }
202         BarGauge {
203             val:drone.pwm_motor3;
204             max: 255
205             height:100
206         }
207         BarGauge {
208             val:drone.pwm_motor4;
209             max: 255
210             height:100
211         }
212         BarGauge {
213             val:drone.droneVBat
214             max: 100
215             height:100
216         }
217         }
218
219         Button {
220             x:300
221             width:80
222             id:flyButton
223             anchors.bottom:parent.bottom
224             anchors.margins:15
225             text:"Fly";
226             checkable:true
227             onClicked:{drone.fly=checked;
228             // mainWindow.fullsecreen=checked;
229             }
230         }
231         Button {
232             x:450
233             width:100
234             id:emergencyButton
235             anchors.bottom:parent.bottom
236
237             anchors.margins:15
238             text:"Emrg";
239             checkable:true
240             onClicked:{drone.emergency=checked;}
241         }
242         Button {
243             x:600;
244             width:100
245             id:recordButton
246             anchors.bottom:parent.bottom
247             anchors.margins:15
248             text:"Rec";
249             checkable:true
250             onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;}
251         }
252         Text {
253             y:700
254             anchors.bottom:parent.bottom
255        //     visible:droneVideo.recVideo
256             color: "#00FF00"
257             id: droneFrameSeq
258             font.pixelSize:25
259             text: droneVideo.videoFileName+ " "+droneVideo.frameSeq
260         }
261
262             Connections {
263                 target:drone
264                 onConnectedChanged:{
265                     console.log("Connected to drone");
266                     connectingDialog.accept();}
267             }
268             QueryDialog {
269                 id:connectingDialog
270                 message:"Connecting to Drone "+ drone.confDroneIp
271                 acceptButtonText:"OK"
272                 Component.onCompleted: {
273                     console.log("ConectionDialog Opened");
274                     if(!drone.connected) open(); }
275             }
276         } // Main page
277     }
278
279      Component.onCompleted: {
280          if (mainpageComponent.status != Component.Ready)
281                      console.log("Error loading component:", mainpageComponent.errorString());
282          dialogComponent = Qt.createComponent("ConfigDialog.qml");
283
284         }
285  }