Cync
[mardrone] / mardrone / ardrone_symbian.qml
1 // uiName:Symbian
2 import QtQuick 1.0
3 import com.nokia.symbian 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     /*
17     ToolBarLayout {
18             id: commonTools
19             visible: false
20             ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
21         //    ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); }
22             ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); }
23         }
24         */
25     ToolBarLayout {
26         id: commonTools
27         ToolButton {
28             flat: true
29             iconSource: "toolbar-back"
30             onClicked: mainWindow.pageStack.depth <= 1 ? Qt.quit() : mainWindow.pageStack.pop()
31         }
32    }
33   DroneControl {
34         id:drone
35     }
36   JoyStick {
37       id:js
38       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
39       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=-1.0*aileron;}
40       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
41       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
42
43   }
44
45     Component {
46       id: mainpageComponent
47
48       Page {
49         id:mainPage
50         property bool connectingBoxVisible:true
51         //onEntered:(mainWindow.fullscreen=true)
52
53         state:"Landscape"
54         DroneVideo {
55             y:0
56             x:0
57            // anchors.horizontalCenter:parent.horizontalCenter
58             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
59         }
60
61         EfisPFD {
62             id:hudPDF
63             y:0
64             x:100
65             visible:drone.confShowHorizon
66             roll:drone.droneRoll
67             pitch:drone.dronePitch
68             ias:drone.droneSpeed
69             alt:drone.droneAltitude
70             indicatorColor:"#00FF00"
71             skyColor:"#00000000"
72             groundColor:"#00000000"
73 //            value:lj.xv
74 //            value2:lj.yv
75             width:640;height:480;
76         }
77
78
79         Text {
80             y:50
81  //           visible:drone.confUseAccel
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:400
221             width:60
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:400;y:100
233             width:120
234             id:emergencyButton
235             anchors.top:parent.top
236
237             anchors.margins:15
238             text:"Energency";
239             checkable:true
240             onClicked:{drone.emergency=checked;}
241         }
242
243
244             Connections {
245                 target:drone
246                 onConnectedChanged:{
247                     console.log("Connected to drone");
248                     connectingDialog.accept();}
249             }
250             QueryDialog {
251                 id:connectingDialog
252                 titleText:"Connecting to Drone"
253                 message:"Connecting to Drone "+ drone.confDroneIp
254                 acceptButtonText:"OK"
255                 Component.onCompleted: {
256                     console.log("ConectionDialog Opened");
257                     if(!drone.connected) open(); }
258             }
259         } // Main page
260     }
261
262      Component.onCompleted: {
263          if (mainpageComponent.status != Component.Ready)
264              //        pageStack.push(mainpageComponent);
265              //  else
266                      console.log("Error loading component:", mainpageComponent.errorString());
267          dialogComponent = Qt.createComponent("ConfigDialogSymbian.qml");
268
269         }
270  }