From: Kate Alhola Date: Mon, 28 May 2012 08:23:14 +0000 (+0300) Subject: Symbian/Android components added X-Git-Url: http://git.maemo.org/git/?p=mardrone;a=commitdiff_plain;h=9810849a03cbb8f89bd3cbeb18c7b2005f846622 Symbian/Android components added --- diff --git a/mardrone/ConfigDialogAndroid.qml b/mardrone/ConfigDialogAndroid.qml new file mode 100644 index 0000000..d3f719f --- /dev/null +++ b/mardrone/ConfigDialogAndroid.qml @@ -0,0 +1,246 @@ +import QtQuick 1.0 +import com.nokia.android 1.1 +import JoyStick 1.0 +Page { + property color textColor:"white" + property int textSize:30 + id:dialog + tools:commonTools + Menu { + id:uiMenu + visualParent:pageStack + MenuLayout { + MenuItem { text:"MeeGo/Harmattan 854x480"; onClicked: { drone.confActiveUI="ardrone_harmattan.qml" }} + MenuItem { text:"Desktop"; onClicked: { drone.confActiveUI="ardrone_desktop.qml"}} + } + } + Component.onCompleted: { + console.debug("Appending items to choices",uiList.count()) + for(var j = 0; j < uiList.count();++j ) { + var data = {'name':uiList.get(j).name,'modelData':uiList.get(j).name,'file':uiList.get(j).file }; + console.debug("appending ",uiList.get(j).name,uiList.get(j).file); + choices.append(data); + if(uiList.get(j).file==drone.confActiveUI) { activeUIDialog.selectedIndex=j; uiDialogButton.text=uiList.get(j).name } + } + } + + ListModel { + id: choices + } + SelectionDialog { + id: activeUIDialog; + model:choices + + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + model.get(selectedIndex).name + ", " + model.get(selectedIndex).file); + drone.confActiveUI=choices.get(selectedIndex).file; + uiDialogButton.text=uiList.get(selectedIndex).name + } + } + Flickable { + id: dialogscrolarea + anchors.fill: parent + // anchors.leftMargin:50;anchors.rightMargin:50 + contentHeight: dialogcontent.height + contentWidth: parent.width + + Grid { + columns:2 + id: dialogcontent + anchors.leftMargin:50;anchors.rightMargin:150 + spacing: 20 + + Text { + font.pixelSize :textSize + text:"UI Style" + + } + Button { + width:200 + id:uiDialogButton + text:"" + anchors.right:parent.right + onClicked:activeUIDialog.open() + // onClicked:uiMenu.open() + } + Text { + width:350 + text: "Drone IP" + color:textColor + font.pixelSize :textSize + } + + TextField { + id: droneip + width: 300 + height: 40 + anchors.right: parent.right + text: drone.confDroneIp + onTextChanged:{drone.confDroneIp=text;} + } + +// } + + Text { + text: "Video 640x480/Full Screen" + color:textColor + font.pixelSize :textSize + } + Switch { + id: fullScreen + checked:drone.confFullScreen + anchors.right:parent.right + onCheckedChanged:{drone.confFullScreen=checked;} + } + Text { + text: "Acceleration Sensor controll" + color:textColor + font.pixelSize :textSize + } + Switch { + id: useAccelSw + checked:drone.confUseAccel + anchors.right:parent.right + onCheckedChanged:{drone.confUseAccel=checked;} + } + Text { + text: "Joystick" + color:textColor + font.pixelSize :textSize + } + Switch { + id: useJoySw + checked:drone.confUseJoyStick + anchors.right:parent.right + enabled:js.haveJoyStick + onCheckedChanged:{drone.confUseJoyStick=checked;} + } + + Text { + visible:drone.confUseJoyStick + font.pixelSize :textSize + text:"\"" + js.joyStickName + "\"" + + } + Button { + visible:drone.confUseJoyStick + text:"Calibrate" + anchors.right:parent.right + onClicked:{ + js.calibrate=true + pageStack.push(calibrateDialog); + } + } + Text { + visible:drone.confUseJoyStick + font.pixelSize :textSize + text:"Show JoyStick Indicators" + + } + Switch { + visible:drone.confUseJoyStick + checked:drone.confShowJSIndicators + anchors.right:parent.right + enabled:js.haveJoyStick + onCheckedChanged:{drone.confShowJSIndicators=checked;} + + } + Text { + color:textColor + text: "Show debug" + font.pixelSize :textSize + } + Switch { + id: showDebug + checked:drone.confShowDebug + anchors.right:parent.right + onCheckedChanged:{drone.confShowDebug=checked;} + } + + Text { + text: "Show engine gauges" + color:textColor + font.pixelSize :textSize + + } + Switch { + id: showGauges + checked:drone.confShowGauges + anchors.right:parent.right + onCheckedChanged:{drone.confShowGauges=checked;} + } + + Text { + text: "Show horizon" + color:textColor + font.pixelSize :textSize + + } + Switch { + id: showHorizon + checked:drone.confShowHorizon + anchors.right:parent.right + onCheckedChanged:{drone.confShowHorizon=checked;} + } + + Text { + text: "Forward/backward gain" + color:textColor + font.pixelSize :textSize + } + + Slider { + id: forwardGain + anchors.right:parent.right + maximumValue:1.0 + stepSize:0.01 + value:drone.confForwardGain + onValueChanged:{drone.confForwardGain=value;} + } + Text { + text: "Right/Left gain" + color:textColor + font.pixelSize :textSize + } + + Slider { + id: rightGain + anchors.right:parent.right + maximumValue:1.0 + stepSize:0.01 + value:drone.confRightGain + onValueChanged:{drone.confRightGain=value;} + } + Text { + text: "accel ctrl treshold" + color:textColor + font.pixelSize :textSize + } + + Slider { + id: ctrlTreshold + anchors.right:parent.right + maximumValue:25.0 + value:drone.confCtrlTrsh + onValueChanged:{drone.confCtrlTrsh=value;} + } + } + } + Page { + property color textColor:"black" + property int textSize:30 + id:calibrateDialog + tools:commonTools + /* + JoyStickCalibrator { + id:jc + // jStick:js + Component.onCompleted: { + if (jc.status != Component.Ready) + console.log("Error loading component:", jc.errorString()); + } + } +*/ + } + } + diff --git a/mardrone/ardrone_android.qml b/mardrone/ardrone_android.qml new file mode 100644 index 0000000..c035488 --- /dev/null +++ b/mardrone/ardrone_android.qml @@ -0,0 +1,293 @@ +// uiName:Android +import QtQuick 1.0 +import com.nokia.android 1.1 +import Drone 1.0 +//import gauges 1.0 +import JoyStick 1.0 + +PageStackWindow { + id:mainWindow + initialPage: mainpageComponent + showStatusBar: false +// fullscreen:true + property Component dialogComponent +// property alias m: mainPage + + /* + ToolBarLayout { + id: commonTools + visible: false + ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); } + // ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); } + ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); } + } + */ + ToolBarLayout { + id: commonTools + ToolButton { + flat: true + iconSource: "toolbar-back" + onClicked: mainWindow.pageStack.depth <= 1 ? Qt.quit() : mainWindow.pageStack.pop() + } + } + DroneControl { + id:drone + } + JoyStick { + id:js + onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;} + onAileronChanged: {if(drone.confUseJoyStick) drone.roll=-1.0*aileron;} + onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;} + onRudderChanged: {if(drone.confUseJoyStick) drone.yaw=rudder;} + + } + + Component { + id: mainpageComponent + + Page { + id:mainPage + property bool connectingBoxVisible:true + //onEntered:(mainWindow.fullscreen=true) + + state:"Landscape" + DroneVideo { + id:droneVideo + y:0 + x:0 + // anchors.horizontalCenter:parent.horizontalCenter + width:drone.confFullScreen? parent.width:640 ;height:480*width/640; + } + Binding { + target:drone + property:"logSeq" + value: droneVideo.frameSeq; + } + EfisPFD { + id:hudPDF + y:0 + anchors.horizontalCenter: parent.horizontalCenter + visible:drone.confShowHorizon + roll:drone.droneRoll + pitch:drone.dronePitch + ias:drone.droneSpeed + alt:drone.droneAltitude + indicatorColor:"#00FF00" + skyColor:"#00000000" + groundColor:"#00000000" + width:500;height:400; + } + + Text { + y:50 + visible:drone.confShowDebug + color: "#00FF00" + id: droneCtrlValues + font.pixelSize:25 + text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " + drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2) + } + + Text { + y:70 + visible:drone.confShowDebug + color: "#00FF00" + id: droneNavData + font.pixelSize:25 + text: "pitch=" + drone.dronePitch.toFixed(2) + " roll= " + drone.droneRoll.toFixed(2) + "yaw=" + drone.droneYaw.toFixed(2) + " alt= " + drone.droneAltitude.toFixed(2) + } + + Text { + y:100 + visible:drone.confShowDebug + color: "#00FF00" + id: droneStatus + font.pixelSize:20 + text: drone.decodedStatus + } + Button { + y:150;x:0 + height: 50 + width: 50 + z:2 // This is visible even connecting to drone + iconSource: "gear32x32.png" + onClicked:{ //mainWindow.fullscreen = false ; + pageStack.push(dialogComponent); + } + } + + JoyStickIndicator { + x:200;y:350 + visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick + border.width:1 + color:"transparent" + width:100;height:100 + xvalue:js.axis4 + yvalue:js.axis3 + Text { + anchors.bottom: parent.bottom + font.pixelSize: 10 + text:" rudder" + } + Text { + x:-10;y:50 + rotation:90 + font.pixelSize: 10 + text:"Throtle" + } + } + + + JoyStickIndicator { + x:500;y:350 + visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick + border.width:1 + color:"transparent" + width:100;height:100 + xvalue:js.axis1 + yvalue:js.axis2 + Text { + anchors.bottom: parent.bottom + font.pixelSize: 10 + text:" Aileron" + } + Text { + x:-15;y:50 + rotation:90 + font.pixelSize: 10 + text:"Elevator" + } + } + + JoyStickTouch { + id:lj + width:200;height:200; + + visible: !drone.confUseAccel & !drone.confUseJoyStick + anchors.left:parent.left + anchors.bottom:parent.bottom + anchors.margins:10 + joyBackground: "" + onYvChanged:{drone.vVelocity=-1*yv/200.0;} + onXvChanged:{drone.yaw=xv/200.0;} + onPressedChanged: { drone.ctrlActive=pressed;} + } + + JoyStickTouch { + visible: !drone.confUseJoyStick + id:rj + joyBackground: "" + anchors.right:parent.right + anchors.bottom:parent.bottom + width:200;height:200; + anchors.margins:10 + onYvChanged:{drone.pitch=yv/200.0;} + onXvChanged:{drone.roll=xv/200.0;} + } + + Row { + spacing: 5 + anchors.right:parent.right + anchors.rightMargin: 10 + y:100 + height:100 + BarGauge { + val:drone.pwm_motor1; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor2; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor3; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor4; + max: 255 + height:100 + } + BarGauge { + val:drone.droneVBat + max: 100 + height:100 + } + } + + Button { + x:400 + width:60 + height:50 + id:flyButton + anchors.bottom:parent.bottom + anchors.margins:15 + text:"Fly"; + checkable:true + onClicked:{drone.fly=checked; + // mainWindow.fullsecreen=checked; + } + } + Button { + x:500; + width:80 + height:50 + id:emergencyButton + anchors.bottom:parent.bottom + anchors.margins:15 + text:"Emrg"; + checkable:true + onClicked:{drone.emergency=checked;} + } + + Button { + x:600; + width:100 + height:50 + id:recordButton + anchors.bottom:parent.bottom + anchors.margins:15 + text:"Rec"; + checkable:true + onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;} + } + Text { + y:700 + anchors.bottom:parent.bottom + // visible:droneVideo.recVideo + color: "#00FF00" + id: droneFrameSeq + font.pixelSize:25 + text: droneVideo.videoFileName+ " "+droneVideo.frameSeq + } + + + Connections { + target:drone + onConnectedChanged:{ + console.log("Connected to drone"); + connectingDialog.accept();} + } + QueryDialog { + id:connectingDialog + titleText:"Connecting to Drone" + message:"Connecting to Drone "+ drone.confDroneIp + acceptButtonText:"OK" + Component.onCompleted: { + console.log("ConectionDialog Opened"); + if(!drone.connected) open(); } + } + } // Main page + } + + Component.onCompleted: { + if (mainpageComponent.status != Component.Ready) + // pageStack.push(mainpageComponent); + // else + console.log("Error loading component:", mainpageComponent.errorString()); + dialogComponent = Qt.createComponent("ConfigDialogAndroid.qml"); + + } + }