From c8ce4940c5be641b753ef943cf336963596705a4 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 15 Feb 2017 11:58:01 +0100 Subject: 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 --- .../resources/base/MagnetometerChart.qml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'tradeshow/iot-sensortag/resources/base/MagnetometerChart.qml') diff --git a/tradeshow/iot-sensortag/resources/base/MagnetometerChart.qml b/tradeshow/iot-sensortag/resources/base/MagnetometerChart.qml index 6c4ba79..3bac8e6 100644 --- a/tradeshow/iot-sensortag/resources/base/MagnetometerChart.qml +++ b/tradeshow/iot-sensortag/resources/base/MagnetometerChart.qml @@ -55,7 +55,6 @@ import QtGraphicalEffects 1.0 BaseChart { id: magnetHolderRect - property int magneticSeriesIndex: 0 property int maxNumOfMagnReadings: 24 readonly property color chartColor: "#15bdff" @@ -64,28 +63,18 @@ BaseChart { readonly property string zColor: "red" readonly property color textColor: "white" - onSensorChanged: if (sensor) sensor.magnetometerMicroTChanged.connect(contentItem.updateMagneticGraph) - title: qsTr("Magnetometer") rightSide: true content: Item { anchors.fill: parent - function updateMagneticGraph() - { - magnSeriesX.append(magneticSeriesIndex, sensor.magnetometerMicroT_xAxis); - magnSeriesY.append(magneticSeriesIndex, sensor.magnetometerMicroT_yAxis); - magnSeriesZ.append(magneticSeriesIndex, sensor.magnetometerMicroT_zAxis); - - if (magneticSeriesIndex >= maxNumOfMagnReadings) { - magnSeriesX.remove(magnSeriesX.at(magneticSeriesIndex-maxNumOfMagnReadings)); - magnSeriesY.remove(magnSeriesY.at(magneticSeriesIndex-maxNumOfMagnReadings)); - magnSeriesZ.remove(magnSeriesY.at(magneticSeriesIndex-maxNumOfMagnReadings)); - valueAxisX.min++; - valueAxisX.max++; + Connections { + target: mainWindow + onSeriesStorageChanged: { + if (seriesStorage) + seriesStorage.setMagnetoMeterSeries(magnSeriesX, magnSeriesY, magnSeriesZ); } - magneticSeriesIndex++; } Image { -- cgit v1.2.3