summaryrefslogtreecommitdiffstats
path: root/tradeshow
diff options
context:
space:
mode:
authorKari Hautamäki <kari.hautamaki@qt.io>2017-02-10 09:54:09 +0200
committerTitta Heikkala <titta.heikkala@qt.io>2017-02-10 08:18:39 +0000
commitadac5cfd26e86b792574eb7751e19f072de3e400 (patch)
tree1e270e19e46287f8ebcfbe349189d660068dfab6 /tradeshow
parent3bfd8426a8e5bb84516101b14398a0bc34f7ef71 (diff)
iot-sensortag: Fix RotationPage 'no rotation' bug
- Conditional binding to sensor values only when sensor is available - Set and recalibrate sensor for RotationPage when the sensor becomes available Change-Id: I3729faa482abdd17bf0d0a850a3eef528cd5a6b6 Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'tradeshow')
-rw-r--r--tradeshow/iot-sensortag/resources/base/RotationPage.qml17
-rw-r--r--tradeshow/iot-sensortag/resources/small/MainSmall.qml9
2 files changed, 13 insertions, 13 deletions
diff --git a/tradeshow/iot-sensortag/resources/base/RotationPage.qml b/tradeshow/iot-sensortag/resources/base/RotationPage.qml
index 6f42058..6ba29d3 100644
--- a/tradeshow/iot-sensortag/resources/base/RotationPage.qml
+++ b/tradeshow/iot-sensortag/resources/base/RotationPage.qml
@@ -53,7 +53,10 @@ import QtQuick.Particles 2.0
Item {
id: dialerRoot
- property var sensor: null
+
+ property var sensor
+ property var rotationUpdateInterval: sensor ? sensor.rotationUpdateInterval : 0
+
focus: true
Image {
@@ -65,11 +68,11 @@ Item {
id: outerRing
anchors.centerIn: parent
source: pathPrefix + "Gyro/gyro_ring3.png"
- rotation: sensor.rotationX
+ rotation: sensor ? sensor.rotationX : 0
Behavior on rotation {
RotationAnimation {
easing.type: Easing.Linear
- duration: sensor.rotationUpdateInterval
+ duration: rotationUpdateInterval
direction: RotationAnimation.Shortest
}
}
@@ -78,11 +81,11 @@ Item {
id: largeRing
anchors.centerIn: parent
source: pathPrefix + "Gyro/gyro_ring2.png"
- rotation: sensor.rotationY
+ rotation: sensor ? sensor.rotationY : 0
Behavior on rotation {
RotationAnimation {
easing.type: Easing.Linear
- duration: sensor.rotationUpdateInterval
+ duration: rotationUpdateInterval
direction: RotationAnimation.Shortest
}
}
@@ -91,11 +94,11 @@ Item {
id: mediumRing
anchors.centerIn: parent
source: pathPrefix + "Gyro/gyro_ring1.png"
- rotation: sensor.rotationZ
+ rotation: sensor ? sensor.rotationZ : 0
Behavior on rotation {
RotationAnimation {
easing.type: Easing.Linear
- duration: sensor.rotationUpdateInterval
+ duration: rotationUpdateInterval
direction: RotationAnimation.Shortest
}
}
diff --git a/tradeshow/iot-sensortag/resources/small/MainSmall.qml b/tradeshow/iot-sensortag/resources/small/MainSmall.qml
index 377acd1..df4a868 100644
--- a/tradeshow/iot-sensortag/resources/small/MainSmall.qml
+++ b/tradeshow/iot-sensortag/resources/small/MainSmall.qml
@@ -71,6 +71,7 @@ Item {
magnetometer.sensor = dataProviderPool.getProvider(SensorTagData.Magnetometer);
rotation.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
accelometer.sensor = dataProviderPool.getProvider(SensorTagData.Accelometer);
+ rotationMain.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
}
}
@@ -155,7 +156,7 @@ Item {
}
RotationPage {
- id: mainContainer
+ id: rotationMain
anchors.top: topToolbar.bottom
anchors.left: leftPane.right
@@ -163,11 +164,7 @@ Item {
anchors.right: rightPane.left
anchors.rightMargin: 32
anchors.bottom: parent.bottom
-
- Component.onCompleted: {
- sensor = rotation.sensor;
- sensor.recalibrate();
- }
+ onSensorChanged: if (sensor) sensor.recalibrate()
}