summaryrefslogtreecommitdiffstats
path: root/tradeshow/iot-sensortag/resources/base/GyroChart.qml
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2017-02-15 11:58:01 +0100
committerTitta Heikkala <titta.heikkala@qt.io>2017-02-16 08:05:16 +0000
commitc8ce4940c5be641b753ef943cf336963596705a4 (patch)
treed81cdce08c8daae30bc50951239530dc3d189608 /tradeshow/iot-sensortag/resources/base/GyroChart.qml
parent90e26ea85564f22458dbec138e91e8078371f8b2 (diff)
Move series updates to C++
Instead of jumping to and from the QML engine for each sensor update, rather stay inside C++ and let QML only do the visual updates. This only updates the items which use Charts, as updates to a series is expensive. Change-Id: Idc7a98d2865e7095264f226c0ac5bbb5a977d18a Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/resources/base/GyroChart.qml')
-rw-r--r--tradeshow/iot-sensortag/resources/base/GyroChart.qml25
1 files changed, 6 insertions, 19 deletions
diff --git a/tradeshow/iot-sensortag/resources/base/GyroChart.qml b/tradeshow/iot-sensortag/resources/base/GyroChart.qml
index 30aba64..f7d2b71 100644
--- a/tradeshow/iot-sensortag/resources/base/GyroChart.qml
+++ b/tradeshow/iot-sensortag/resources/base/GyroChart.qml
@@ -51,12 +51,12 @@ import QtQuick 2.5
import QtCharts 2.1
import SensorTag.DataProvider 1.0
import QtGraphicalEffects 1.0
+import QtQml 2.2
BaseChart {
id: gyroHolderRect
// Replace with actual gyro properties
- property int gyroSeriesIndex: 0
property int maxGyroReadings: 24
readonly property string xColor: "#15bdff"
@@ -64,12 +64,6 @@ BaseChart {
readonly property string zColor: "red"
readonly property color textColor: "white"
- onSensorChanged: {
- if (sensor) {
- sensor.rotationValuesChanged.connect(contentItem.updateRotation);
- }
- }
-
onClicked: {
if (sensor)
sensor.recalibrate();
@@ -81,19 +75,12 @@ BaseChart {
content: Item {
anchors.fill: parent
- function updateRotation() {
- gyroSeriesX.append(gyroSeriesIndex, sensor.rotationX);
- gyroSeriesY.append(gyroSeriesIndex, sensor.rotationY);
- gyroSeriesZ.append(gyroSeriesIndex, sensor.rotationZ);
-
- if (gyroSeriesIndex >= maxGyroReadings) {
- gyroSeriesX.remove(gyroSeriesX.at(gyroSeriesIndex-maxGyroReadings));
- gyroSeriesY.remove(gyroSeriesY.at(gyroSeriesIndex-maxGyroReadings));
- gyroSeriesZ.remove(gyroSeriesZ.at(gyroSeriesIndex-maxGyroReadings));
- valueAxisX.min++;
- valueAxisX.max++;
+ Connections {
+ target: mainWindow
+ onSeriesStorageChanged: {
+ if (seriesStorage)
+ seriesStorage.setGyroSeries(gyroSeriesX, gyroSeriesY, gyroSeriesZ);
}
- gyroSeriesIndex++;
}
Glow {