sync repository
[mardrone] / mardrone / JoyStickCalibratorDesktop.qml
1 import QtQuick 1.0
2 import JoyStick 1.0
3 import QtDesktop 0.1
4
5 Item {
6     width: 600
7     height: 800
8     property int textSize:22
9     property int ctrlSize:40
10     ListModel {
11           id: axisMapModel
12           ListElement{ text:"Aileron";  mapAxis:1 }
13           ListElement { text:"Elevator"; mapAxis:2 }
14           ListElement { text:"Throtle";  mapAxis:3 }
15           ListElement { text:"Rudder";   mapAxis:4 }
16           ListElement { text:"none";     mapAxis:0 }
17    }
18      /*
19     ComboBox {
20         id: axisMap1UICombo;
21         model:  ListModel {
22           id: choicesMapAxis1
23           ListElement{ text:"Aileron";  mapAxis:1 }
24           ListElement { text:"Elevator"; mapAxis:2 }
25           ListElement { text:"Throtle";  mapAxis:3 }
26           ListElement { text:"Rudder";   mapAxis:4 }
27           ListElement { text:"none";     mapAxis:0 }
28           }
29         onSelectedIndexChanged: {
30             console.debug("onSelectedIndexChanged " + selectedText + ", " + choicesMapAxis1.get(selectedIndex).mapAxis);
31             js.mapAxis1=choicesMapAxis1.get(selectedIndex).mapAxis
32         }
33         selectedText:js.mapAxis1
34         KeyNavigation.tab: t1
35         KeyNavigation.backtab: button2
36      }
37
38     Menu {
39         id:js1map
40         visualParent:pageStack
41         MenuLayout {
42             MenuItem { text:"Aileron";  onClicked: { js.mapAxis1=1 }}
43             MenuItem { text:"Elevator"; onClicked: { js.mapAxis1=2 }}
44             MenuItem { text:"Throtle";  onClicked: { js.mapAxis1=3 }}
45             MenuItem { text:"Rudder";   onClicked: { js.mapAxis1=4 }}
46             MenuItem { text:"none";     onClicked: { js.mapAxis1=0 }}
47
48        }
49     }
50     Menu {
51         id:js2map
52         visualParent:pageStack
53         MenuLayout {
54             MenuItem { text:"Aileron";  onClicked: { js.mapAxis2=1 }}
55             MenuItem { text:"Elevator"; onClicked: { js.mapAxis2=2 }}
56             MenuItem { text:"Throtle";  onClicked: { js.mapAxis2=3 }}
57             MenuItem { text:"Rudder";   onClicked: { js.mapAxis2=4 }}
58             MenuItem { text:"none";     onClicked: { js.mapAxis2=0 }}
59
60        }
61     }
62     Menu {
63         id:js3map
64         visualParent:pageStack
65         MenuLayout {
66             MenuItem { text:"Aileron";  onClicked: { js.mapAxis3=1 }}
67             MenuItem { text:"Elevator"; onClicked: { js.mapAxis3=2 }}
68             MenuItem { text:"Throtle";  onClicked: { js.mapAxis3=3 }}
69             MenuItem { text:"Rudder";   onClicked: { js.mapAxis3=4 }}
70             MenuItem { text:"none";     onClicked: { js.mapAxis3=0 }}
71
72        }
73     }
74     Menu {
75         id:js4map
76         visualParent:pageStack
77         MenuLayout {
78             MenuItem { text:"Aileron";  onClicked: { js.mapAxis4=1 }}
79             MenuItem { text:"Elevator"; onClicked: { js.mapAxis4=2 }}
80             MenuItem { text:"Throtle";  onClicked: { js.mapAxis4=3 }}
81             MenuItem { text:"Rudder";   onClicked: { js.mapAxis4=4 }}
82             MenuItem { text:"none";     onClicked: { js.mapAxis4=0 }}
83
84        }
85     }
86     Menu {
87         id:js5map
88         visualParent:pageStack
89         MenuLayout {
90             MenuItem { text:"Aileron";  onClicked: { js.mapAxis5=1 }}
91             MenuItem { text:"Elevator"; onClicked: { js.mapAxis5=2 }}
92             MenuItem { text:"Throtle";  onClicked: { js.mapAxis5=3 }}
93             MenuItem { text:"Rudder";   onClicked: { js.mapAxis5=4 }}
94             MenuItem { text:"none";     onClicked: { js.mapAxis5=0 }}
95
96        }
97     }
98     Menu {
99         id:js6map
100         visualParent:pageStack
101         MenuLayout {
102             MenuItem { text:"Aileron";  onClicked: { js.mapAxis6=1 }}
103             MenuItem { text:"Elevator"; onClicked: { js.mapAxis6=2 }}
104             MenuItem { text:"Throtle";  onClicked: { js.mapAxis6=3 }}
105             MenuItem { text:"Rudder";   onClicked: { js.mapAxis6=4 }}
106             MenuItem { text:"none";     onClicked: { js.mapAxis6=0 }}
107
108        }
109     }
110 */
111  //   property Item jStick:
112     Column {
113         Text {
114             text:" "
115         }
116
117         Row {
118             Text {
119                 text:"                  "
120             }
121             JoyStickIndicator {
122                 border.width:1
123                 width:100;height:100
124                 xvalue:js.axis4
125                 yvalue:js.axis3
126                 Text {
127                     anchors.bottom: parent.bottom
128                     font.pixelSize: 10
129                     text:"       rudder"
130                 }
131                 Text {
132                     x:-10;y:50
133                     rotation:90
134                     font.pixelSize: 10
135                     text:"Throtle"
136                 }
137             }
138
139             spacing:50
140             JoyStickIndicator {
141                 border.width:1
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             Column {
158                 Button{
159                     text:"Reset"
160                     onClicked:{
161                         js.calibrate=false
162                         pageStack.pop();
163                     }
164                 }
165                 Button{
166                     text:"Save"
167                     onClicked:{
168                         js.calibrate=false
169                         pageStack.pop();
170                     }
171                 }
172         }
173         }
174         Grid {
175             spacing:10
176             columns:7
177             Text {
178                 font.pixelSize  :textSize
179                 text:"     Raw"
180             }
181             Text {
182                 font.pixelSize  :textSize
183                 text:"     Max"
184             }
185             Text {
186                 font.pixelSize  :textSize
187                 text:"     Min"
188             }
189             Text {
190                 font.pixelSize  :textSize
191                 text:"Calib"
192             }
193             Text {
194                 font.pixelSize  :textSize
195                 text:"value"
196             }
197             Text {
198                 font.pixelSize  :textSize
199                 text:"reverse"
200             }
201             Text {
202                 font.pixelSize  :textSize
203                 text:"mapping " + js.mapAxis1 + js.mapAxis2 + js.mapAxis3 + js.mapAxis4 +js.mapAxis5 +js.mapAxis6
204             }
205
206
207             Text {
208                 font.pixelSize  :textSize
209                 text:js.rawAxis1
210             }
211             Text {
212                 font.pixelSize  :textSize
213                 text:js.maxAxis1
214             }
215             Text {
216                 font.pixelSize  :textSize
217                 text:js.minAxis1
218             }
219             Text {
220                 font.pixelSize  :textSize
221                 text:js.calAxis1.toFixed(2)
222             }
223             BarGauge {
224                 width:100
225                 height:20
226                 val:js.calAxis1+1.0
227                 max:2.0
228                 horiz:true
229             }
230             CheckBox {
231                 width:60
232        //         scale:0.8
233                 checked:js.invertAxis1
234                 onCheckedChanged:{js.invertAxis1=checked;}
235             }
236             ComboBox {
237                 id: axisMap1UICombo;
238                 model:  axisMapModel
239                 onSelectedIndexChanged: {
240                     console.debug("onSelectedIndexChanged " + selectedText + ", " + axisMap1UICombo.get(selectedIndex).mapAxis);
241                     js.mapAxis1=caxisMap1UICombo.get(selectedIndex).mapAxis
242                 }
243                 selectedText:js.mapAxis1
244              }
245 /*            Button{
246                 width:200;height:ctrlSize
247                 text:js.mapAxis1==1?"Aileron":js.mapAxis1==2?"Elevator":js.mapAxis1==3?"Throtle":js.mapAxis1==4?"Rudder":"none"
248                 onClicked:js1map.open()
249             }
250 */
251
252
253             Text {
254                 font.pixelSize  :textSize
255                 text:js.rawAxis2
256             }
257             Text {
258                 font.pixelSize  :textSize
259                 text:js.maxAxis2
260             }
261             Text {
262                 font.pixelSize  :textSize
263                 text:js.minAxis2
264             }
265             Text {
266                 font.pixelSize  :textSize
267                 text:js.calAxis2.toFixed(2)
268             }
269             BarGauge {
270                 width:100
271                 height:20
272                 val:js.calAxis2+1.0
273                 max:2.0
274                 horiz:true
275             }
276             CheckBox {
277                 checked:js.invertAxis2
278                 onCheckedChanged:{js.invertAxis2=checked;}
279             }
280             Button{
281                 width:200;height:ctrlSize
282                 text:js.mapAxis2==1?"Aileron":js.mapAxis2==2?"Elevator":js.mapAxis2==3?"Throtle":js.mapAxis2==4?"Rudder":"none"
283                 onClicked:js2map.open()
284             }
285
286
287
288             Text {
289                 font.pixelSize  :textSize
290                 text:js.rawAxis3
291             }
292             Text {
293                 font.pixelSize  :textSize
294                 text:js.maxAxis3
295             }
296             Text {
297                 font.pixelSize  :textSize
298                 text:js.minAxis3
299             }
300             Text {
301                 font.pixelSize  :textSize
302                 text:js.calAxis3.toFixed(2)
303             }
304             BarGauge {
305                 width:100
306                 height:20
307                 val:js.calAxis3+1.0
308                 max:2.0               
309                 horiz:true
310             }
311             CheckBox {
312                 checked:js.invertAxis3
313                 onCheckedChanged:{js.invertAxis3=checked;}
314             }
315             Button{
316                 width:200;height:ctrlSize
317                 text:js.mapAxis3==1?"Aileron":js.mapAxis3==2?"Elevator":js.mapAxis3==3?"Throtle":js.mapAxis3==4?"Rudder":"none"
318                 onClicked:js3map.open()
319             }
320
321             Text {
322                 font.pixelSize  :textSize
323                 text:js.rawAxis4
324             }
325             Text {
326                 font.pixelSize  :textSize
327                 text:js.maxAxis4
328             }
329             Text {
330                 font.pixelSize  :textSize
331                 text:js.minAxis4
332             }
333             Text {
334                 font.pixelSize  :textSize
335                 text:js.calAxis4.toFixed(2)
336             }
337             BarGauge {
338                 width:100
339                 height:20
340                 val:js.calAxis4+1.0
341                 max:2.0
342                 horiz:true
343             }
344             CheckBox {
345                 checked:js.invertAxis4
346                 onCheckedChanged:{js.invertAxis4=checked;}
347             }
348             Button{
349                 width:200;height:ctrlSize
350                 text:js.mapAxis4==1?"Aileron":js.mapAxis4==2?"Elevator":js.mapAxis4==3?"Throtle":js.mapAxis4==4?"Rudder":"none"
351                 onClicked:js4map.open()
352             }
353
354             Text {
355                 font.pixelSize  :textSize
356                 text:js.rawAxis5
357             }
358             Text {
359                 font.pixelSize  :textSize
360                 text:js.maxAxis5
361             }
362             Text {
363                 font.pixelSize  :textSize
364                 text:js.minAxis5
365             }
366             Text {
367                 font.pixelSize  :textSize
368                 text:js.calAxis5.toFixed(2)
369             }
370             BarGauge {
371                 width:100
372                 height:20
373                 val:js.calAxis5+1.0
374                 max:2.0
375                 horiz:true
376             }
377             CheckBox {
378                 checked:js.invertAxis5
379                 onCheckedChanged:{js.invertAxis5=checked;}
380             }
381             Button{
382                 width:200;height:ctrlSize
383                 text:js.mapAxis5==1?"Aileron":js.mapAxis5==2?"Elevator":js.mapAxis5==3?"Throtle":js.mapAxis5==4?"Rudder":"none"
384                 onClicked:js5map.open()
385             }
386
387             Text {
388                 font.pixelSize  :textSize
389                 text:js.rawAxis6
390             }
391             Text {
392                 font.pixelSize  :textSize
393                 text:js.maxAxis6
394             }
395             Text {
396                 font.pixelSize  :textSize
397                 text:js.minAxis6
398             }
399             Text {
400                 font.pixelSize  :textSize
401                 text:js.calAxis6.toFixed(2)
402             }
403             BarGauge {
404                 width:100
405                 height:20
406                 val:js.calAxis6+1.0
407                 max:2.0
408                 horiz:true
409             }
410             CheckBox {
411                 checked:js.invertAxis6
412                 onCheckedChanged:{js.invertAxis6=checked;}
413             }
414             Button{
415                 width:200;height:ctrlSize
416                 text:js.mapAxis6==1?"Aileron":js.mapAxis6==2?"Elevator":js.mapAxis6==3?"Throtle":js.mapAxis6==4?"Rudder":"none"
417                 onClicked:js6map.open()
418             }
419         }
420
421     }
422 }
423
424