From 1ce9c5aa3d911963b05daf1194f2ad7daab8e491 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 10 Jun 2014 13:46:52 +0200 Subject: sensors: Display only 2 decimals Currently on Nexus2013 there are so many decimals printed that the label for the value is out of the screen. Change-Id: Ic6bb1a265a978cfbab0f42d6237b22e42b460818 Reviewed-by: Gatis Paeglis --- basicsuite/sensors/Light.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'basicsuite/sensors') diff --git a/basicsuite/sensors/Light.qml b/basicsuite/sensors/Light.qml index f997efd..0cff8e6 100644 --- a/basicsuite/sensors/Light.qml +++ b/basicsuite/sensors/Light.qml @@ -83,7 +83,7 @@ Item { LightSensor { active: true onReadingChanged: { - illuminanceLevel.text = "Illuminance: " + reading.illuminance + illuminanceLevel.text = "Illuminance: " + reading.illuminance.toFixed(2); } } } -- cgit v1.2.3 From 0d56278af6eace6747bd7c91215f6e5daef8b84e Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Wed, 11 Jun 2014 11:25:47 +0200 Subject: Show sensors example in landscape view Show sensors example in landscape view to match the way all the other examples are presented in the qtlauncher. Also the calculation is more pysically correct. Task-number: QTEE-569 Change-Id: I12e1b27e62dfa082d9d768598891a5ce91109436 Reviewed-by: Gatis Paeglis --- basicsuite/sensors/Accelbubble.qml | 116 +++++++++++++++---------------------- basicsuite/sensors/Light.qml | 77 ++++++++++++------------ basicsuite/sensors/main.qml | 34 ++++++----- basicsuite/sensors/preview_l.jpg | Bin 19464 -> 16715 bytes 4 files changed, 103 insertions(+), 124 deletions(-) (limited to 'basicsuite/sensors') diff --git a/basicsuite/sensors/Accelbubble.qml b/basicsuite/sensors/Accelbubble.qml index c5aeefc..f70aa32 100644 --- a/basicsuite/sensors/Accelbubble.qml +++ b/basicsuite/sensors/Accelbubble.qml @@ -41,90 +41,68 @@ import QtQuick 2.0 import QtSensors 5.0 -Item { - function calc() { - if (xAnimation.running || yAnimation.running) - return +Rectangle { + id: area + color: "lightblue" + border.width: 1 + border.color: "darkblue" + property real velocityX: 0 + property real velocityY: 0 - var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .8) - var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .8) + function updatePosition() { + velocityX += accel.reading.y + velocityY += accel.reading.x - if (newX < 0) + velocityX *= 0.95 + velocityY *= 0.95 + + var newX = bubble.x + velocityX + var newY = bubble.y + velocityY + var right = area.width - bubble.width + var bottom = area.height - bubble.height + + if (newX < 0) { newX = 0 - if (newY < 0) + velocityX = -velocityX * 0.9 + } + if (newY < 0) { newY = 0 + velocityY = -velocityY * 0.9 + } - var right = field.width - bubble.width - var bottom = field.height - bubble.height - - if (newX > right) + if (newX > right) { newX = right - if (newY > bottom) + velocityX = -velocityX * 0.9 + } + if (newY > bottom) { newY = bottom + velocityY = -velocityY * 0.9 + } bubble.x = newX bubble.y = newY - - yBehavior.enabled = true - xBehavior.enabled = true } - Rectangle { - id: field - color: "lightblue" - border.width: 1 - border.color: "darkblue" - width: parent.width - height: parent.height - Accelerometer { - id: accel - active:true - } - - Timer { - interval: 100 - running: true - repeat: true - onTriggered: calc() - } + Accelerometer { + id: accel + active:true + } - Image { - id: bubble - source: "bluebubble.png" - property real centerX: parent.width / 2 - property real centerY: parent.height / 2; - property real bubbleCenter: bubble.width / 2 - x: centerX - bubbleCenter - y: centerY - bubbleCenter - smooth: true + Component.onCompleted: timer.running = true - Behavior on y { - id: yBehavior - enabled: false - SmoothedAnimation { - id: yAnimation - easing.type: Easing.Linear - duration: 40 - onRunningChanged: calc() - } - } - Behavior on x { - id: xBehavior - enabled: false - SmoothedAnimation { - id: xAnimation - easing.type: Easing.Linear - duration: 40 - onRunningChanged: calc() - } - } - } + Timer { + id: timer + interval: 16 + running: false + repeat: true + onTriggered: updatePosition() } - function calcPitch(x,y,z) { - return Math.atan(y / Math.sqrt(x*x + z*z)) * 57.2957795; - } - function calcRoll(x,y,z) { - return Math.atan(x / Math.sqrt(y*y + z*z)) * 57.2957795; + Image { + id: bubble + source: "bluebubble.png" + smooth: true + x: parent.width/2 - bubble.width/2 + y: parent.height/2 - bubble.height/2 } } diff --git a/basicsuite/sensors/Light.qml b/basicsuite/sensors/Light.qml index 0cff8e6..24f3bd9 100644 --- a/basicsuite/sensors/Light.qml +++ b/basicsuite/sensors/Light.qml @@ -41,50 +41,47 @@ import QtQuick 2.0 import QtSensors 5.0 -Item { - rotation: 180 - Rectangle { - id: bg - width: parent.width - height: parent.height - Text { - id: illuminanceLevel - anchors.horizontalCenter: parent.horizontalCenter - font.pointSize: 26 - anchors.top: parent.top - } - Image { - id: avatar - anchors.top: illuminanceLevel.bottom - anchors.topMargin: 30 - anchors.centerIn: parent - } +Rectangle { + id: bg + Image { + id: avatar + width: parent.width * 0.9 + height: parent.height * 0.9 + fillMode: Image.PreserveAspectFit + anchors.centerIn: parent + } + Text { + id: illuminanceLevel + font.pointSize: 20 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 60 + } - AmbientLightSensor { - active: true - onReadingChanged: { - if (reading.lightLevel === AmbientLightReading.Dark) { - avatar.source = "3.png" - bg.color = "midnightblue" - } else if (reading.lightLevel === AmbientLightReading.Twilight - || reading.lightLevel === AmbientLightReading.Light) { - avatar.source = "2.png" - bg.color = "steelblue" - } else if (reading.lightLevel === AmbientLightReading.Bright - || reading.lightLevel === AmbientLightReading.Sunny) { - avatar.source = "1.png" - bg.color = "yellow" - } else { - avatar.text = "Unknown light level" - } + AmbientLightSensor { + active: true + onReadingChanged: { + if (reading.lightLevel === AmbientLightReading.Dark) { + avatar.source = "3.png" + bg.color = "#1947A3" + } else if (reading.lightLevel === AmbientLightReading.Twilight + || reading.lightLevel === AmbientLightReading.Light) { + avatar.source = "2.png" + bg.color = "steelblue" + } else if (reading.lightLevel === AmbientLightReading.Bright + || reading.lightLevel === AmbientLightReading.Sunny) { + avatar.source = "1.png" + bg.color = "#FFFF75" + } else { + avatar.text = "Unknown light level" } } + } - LightSensor { - active: true - onReadingChanged: { - illuminanceLevel.text = "Illuminance: " + reading.illuminance.toFixed(2); - } + LightSensor { + active: true + onReadingChanged: { + illuminanceLevel.text = "Illuminance: " + reading.illuminance.toFixed(2); } } } diff --git a/basicsuite/sensors/main.qml b/basicsuite/sensors/main.qml index b5a1207..d6e0e9d 100644 --- a/basicsuite/sensors/main.qml +++ b/basicsuite/sensors/main.qml @@ -42,30 +42,30 @@ import QtQuick 2.0 import QtSensors 5.0 import QtSensors 5.0 as Sensors -Item { +Rectangle { id: root - width: 800 - height: 1280 + anchors.fill: parent Component { id: sensorExample Rectangle { id: main - width: root.height - height: root.width - rotation: 90 + width: root.width + height: root.height + anchors.centerIn: parent + color: "blue" border.width: 1 + Accelbubble { + id: bubble + width: parent.width / 2 + height: parent.height + } Light { - id: lys - width: main.width - height: main.height / 2 + anchors.left: bubble.right + width: parent.width / 2 + height: parent.height } - Accelbubble { - width: main.width - height: main.height / 2 - anchors.top: lys.bottom - } } } @@ -74,10 +74,14 @@ Item { Rectangle { width: root.width height: root.height + color: "black" Text { - font.pixelSize: 22 + font.pixelSize: 80 + width: parent.width * 0.8 anchors.centerIn: parent + color: "white" text: "It appears that this device doesn't provide the required sensors!" + wrapMode: Text.WordWrap } } } diff --git a/basicsuite/sensors/preview_l.jpg b/basicsuite/sensors/preview_l.jpg index 7ce979d..d87d757 100644 Binary files a/basicsuite/sensors/preview_l.jpg and b/basicsuite/sensors/preview_l.jpg differ -- cgit v1.2.3 From e029852de438d1509ea067f05e9a026b41375f89 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Tue, 24 Jun 2014 13:59:28 +0300 Subject: disable camera and sensor demo from Toradex Apalis iMX6 Change-Id: I12d72339a1071500a92b87e7c62fe3d7de6b9b25 Reviewed-by: Eirik Aavitsland --- basicsuite/sensors/exclude.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'basicsuite/sensors') diff --git a/basicsuite/sensors/exclude.txt b/basicsuite/sensors/exclude.txt index 7ced997..4d1d7ec 100644 --- a/basicsuite/sensors/exclude.txt +++ b/basicsuite/sensors/exclude.txt @@ -5,3 +5,4 @@ linux-raspberrypi linux-beagleboard linux-beaglebone linux-imx6qsabresd +linux-apalis-imx6 -- cgit v1.2.3