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