0.2 version add desktop components multitouch, joystick, multicast
[mardrone] / mardrone / ardrone_harmattan.qml
1 import QtQuick 1.0
2 import com.nokia.meego 1.0
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     ToolBarLayout {
16             id: commonTools
17             visible: false
18             ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
19         //    ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); }
20             ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); }
21
22         }
23
24
25   DroneControl {
26         id:drone
27
28     }
29   JoyStick {
30       id:js
31       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
32       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=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       Page {
41         id:mainPage
42         //onEntered:(mainWindow.fullscreen=true)
43
44         state:"Landscape"
45         DroneVideo {
46             y:0
47             x:0
48            // anchors.horizontalCenter:parent.horizontalCenter
49             width:drone.confFullScreen? parent.width:640 ;height:480*width/640;
50         }
51         EfisPFD {
52             id:hudPDF
53             y:0
54             x:100
55             visible:drone.confShowHorizon
56             roll:drone.droneRoll
57             pitch:drone.dronePitch
58             ias:drone.droneSpeed
59             alt:drone.droneAltitude
60             indicatorColor:"#00FF00"
61             skyColor:"#00000000"
62             groundColor:"#00000000"
63 //            value:lj.xv
64 //            value2:lj.yv
65             width:640;height:480;
66         }
67
68
69         Text {
70             y:100
71  //           visible:drone.confUseAccel
72             color: "#00FF00"
73             id: droneCtrlValues
74             font.pixelSize:20
75             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
76         }
77
78         Text {
79             y:115
80             visible:drone.confShowDebug
81             color: "#00FF00"
82             id: droneNavData
83             font.pixelSize:20
84             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
85         }
86
87         Text {
88             y:130
89             visible:drone.confShowDebug
90             color: "#00FF00"
91             id: droneStatus
92             font.pixelSize:20
93             text: drone.decodedStatus
94         }
95         Button {
96             y:150;x:0
97             height: 50
98             width: 50
99             iconSource: "gear32x32.png"
100             onClicked:{   //mainWindow.fullscreen = false ;
101                      pageStack.push(dialogComponent);
102             }
103         }
104
105         JoyStickIndicator {
106             x:200;y:350
107             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
108             border.width:1
109             color:"transparent"
110             width:100;height:100
111             xvalue:js.axis4
112             yvalue:js.axis3
113             Text {
114                 anchors.bottom: parent.bottom
115                 font.pixelSize: 10
116                 text:"       rudder"
117             }
118             Text {
119                 x:-10;y:50
120                 rotation:90
121                 font.pixelSize: 10
122                 text:"Throtle"
123             }
124         }
125
126
127         JoyStickIndicator {
128             x:500;y:350
129             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
130             border.width:1
131             color:"transparent"
132             width:100;height:100
133             xvalue:js.axis1
134             yvalue:js.axis2
135             Text {
136                 anchors.bottom: parent.bottom
137                 font.pixelSize: 10
138                 text:"      Aileron"
139             }
140             Text {
141                 x:-15;y:50
142                 rotation:90
143                 font.pixelSize: 10
144                 text:"Elevator"
145             }
146         }
147
148         JoyStickTouch {
149             id:lj
150             width:280;height:280;
151             y:200
152             visible: !drone.confUseAccel & !drone.confUseJoyStick
153             anchors.left:parent.left
154             anchors.margins:50
155             onYvChanged:{drone.pitch=yv/200.0;}
156             onXvChanged:{drone.roll=xv/200.0;}
157
158
159         }
160
161         JoyStickTouch {
162              visible: !drone.confUseJoyStick
163             id:rj
164             y:200
165             anchors.right:parent.right
166             width:280;height:280;
167             anchors.margins:10
168             onYvChanged:{drone.vVelocity=-1*yv/200.0;}
169             onXvChanged:{drone.yaw=xv/200.0;}
170             onPressedChanged: { drone.ctrlActive=pressed;}
171         }
172
173         Row {
174             spacing: 5
175             anchors.right:parent.right
176             anchors.rightMargin: 10
177             y:100
178             height:100
179         BarGauge {
180            val:drone.pwm_motor1;
181            max: 255
182            height:100
183         }
184         BarGauge {
185             val:drone.pwm_motor2;
186             max: 255
187             height:100
188         }
189         BarGauge {
190             val:drone.pwm_motor3;
191             max: 255
192             height:100
193         }
194         BarGauge {
195             val:drone.pwm_motor4;
196             max: 255
197             height:100
198         }
199         BarGauge {
200             val:drone.droneVBat
201             max: 100
202             height:100
203         }
204         }
205
206         Button {
207             x:400
208             width:60
209             id:flyButton
210             anchors.bottom:parent.bottom
211             anchors.margins:15
212             text:"Fly";
213             checkable:true
214             onClicked:{drone.fly=checked;
215             // mainWindow.fullsecreen=checked;
216             }
217         }
218         Button {
219             x:400;y:100
220             width:120
221             id:emergencyButton
222             anchors.top:parent.top
223             anchors.margins:15
224             text:"Energency";
225             checkable:true
226             onClicked:{drone.emergency=checked;}
227         }
228
229         } // Main page
230     }
231
232      Component.onCompleted: {
233          if (mainpageComponent.status != Component.Ready)
234              //        pageStack.push(mainpageComponent);
235              //  else
236                      console.log("Error loading component:", mainpageComponent.errorString());
237          dialogComponent = Qt.createComponent("ConfigDialog.qml");
238
239         }
240 //      Component.onCompleted: {
241 //            mainWindow.fullscreen = true ;
242 //            dialogComponent = Qt.createComponent("ConfigDialog.qml");
243 //            mainWindow.nextPage(mainpageComponent)
244 //      }
245  }