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