From 632e35db6d6ef6bf15891e486da983aabfb740b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kari=20Hautam=C3=A4ki?= Date: Mon, 30 Jan 2017 16:30:32 +0200 Subject: Display rotation values in GyroChart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Displays rotation values in GyroChart instead of *_degPerSec values. Also, elapsed time between measurements given a meaningful initial value in BluetoothDataProvider. Change-Id: Id4aa8820d8e45ac72d85cc963e993941ccacd599 Reviewed-by: Otto Ryynänen --- tradeshow/iot-sensortag/bluetoothdataprovider.cpp | 5 ++++- tradeshow/iot-sensortag/bluetoothdevice.cpp | 1 + tradeshow/iot-sensortag/resources/base/GyroChart.qml | 6 +++--- tradeshow/iot-sensortag/resources/base/TemperatureChart.qml | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tradeshow/iot-sensortag/bluetoothdataprovider.cpp b/tradeshow/iot-sensortag/bluetoothdataprovider.cpp index 8e4f152..4737987 100644 --- a/tradeshow/iot-sensortag/bluetoothdataprovider.cpp +++ b/tradeshow/iot-sensortag/bluetoothdataprovider.cpp @@ -142,9 +142,12 @@ void BluetoothDataProvider::motionReceived(MotionSensorData &data) gyroscopeX_degPerSec = data.gyroScope_x; gyroscopeY_degPerSec = data.gyroScope_y; gyroscopeZ_degPerSec = data.gyroScope_z; + emit gyroscopeDegPerSecChanged(); + rotation_x += countRotationDegrees(data.gyroScope_x, data.msSincePreviousData); rotation_y += countRotationDegrees(data.gyroScope_y, data.msSincePreviousData); rotation_z += countRotationDegrees(data.gyroScope_z, data.msSincePreviousData); + if (rotation_x > 360) rotation_x -= 360; else if (rotation_x < 0) @@ -157,13 +160,13 @@ void BluetoothDataProvider::motionReceived(MotionSensorData &data) rotation_z -= 360; else if (rotation_z < 0) rotation_z += 360; - emit gyroscopeDegPerSecChanged(); emit rotationXChanged(); emit rotationYChanged(); emit rotationZChanged(); // Signal that all values have changed, for easier // value change handling in clients emit rotationValuesChanged(); + accelometer_mG_xAxis = data.accelometer_x; accelometer_mG_yAxis = data.accelometer_y; accelometer_mG_zAxis = data.accelometer_z; diff --git a/tradeshow/iot-sensortag/bluetoothdevice.cpp b/tradeshow/iot-sensortag/bluetoothdevice.cpp index 0e43956..66faf5a 100644 --- a/tradeshow/iot-sensortag/bluetoothdevice.cpp +++ b/tradeshow/iot-sensortag/bluetoothdevice.cpp @@ -309,6 +309,7 @@ void BluetoothDevice::serviceScanDone() connect(motionService, &QLowEnergyService::characteristicRead, this, &BluetoothDevice::characteristicsRead); motionService->discoverDetails(); } + attitudeChangeInterval.restart(); } } diff --git a/tradeshow/iot-sensortag/resources/base/GyroChart.qml b/tradeshow/iot-sensortag/resources/base/GyroChart.qml index 681d218..37ee21f 100644 --- a/tradeshow/iot-sensortag/resources/base/GyroChart.qml +++ b/tradeshow/iot-sensortag/resources/base/GyroChart.qml @@ -195,21 +195,21 @@ BaseChart { Text { id: xLabel horizontalAlignment: Text.AlignHCenter - text: "Roll
" + (sensor ? sensor.rotationX : 0) + text: "Roll
" + (sensor ? sensor.rotationX.toFixed(0) : 0) lineHeight: 0.7 width: (gyroHolderRect.width - xLabelRow.x) / 3 } Text { horizontalAlignment: Text.AlignHCenter - text: "Pitch
" + (sensor ? sensor.rotationY : 0) + text: "Pitch
" + (sensor ? sensor.rotationY.toFixed(0) : 0) lineHeight: 0.7 width: xLabel.width } Text { horizontalAlignment: Text.AlignHCenter - text: "Yaw
" + (sensor ? sensor.rotationZ : 0) + text: "Yaw
" + (sensor ? sensor.rotationZ.toFixed(0) : 0) lineHeight: 0.7 width: xLabel.width } diff --git a/tradeshow/iot-sensortag/resources/base/TemperatureChart.qml b/tradeshow/iot-sensortag/resources/base/TemperatureChart.qml index 0e0b94c..d4878a4 100644 --- a/tradeshow/iot-sensortag/resources/base/TemperatureChart.qml +++ b/tradeshow/iot-sensortag/resources/base/TemperatureChart.qml @@ -122,7 +122,7 @@ BaseChart { Text { anchors.centerIn: parent - text: sensor.barometerCelsiusTemperature + text: sensor ? sensor.barometerCelsiusTemperature : "" color: "white" } } @@ -139,7 +139,7 @@ BaseChart { } Text { - text: "Avg\n" + sensor.barometerTemperatureAverage.toFixed(1) + text: "Avg\n" + (sensor ? sensor.barometerTemperatureAverage.toFixed(1) : "") lineHeight: 0.8 width: 60 horizontalAlignment: Text.Center -- cgit v1.2.3