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