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