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