Accelerometer ignore accelerometerMode

asked 2015-03-12 14:59:05 +0200

blackish gravatar image

updated 2015-03-12 15:05:11 +0200

chemist gravatar image

Greetings, everyone!

I've tried to play with accelerometer in qml and ran into a problem: in the following code "accelerometerMode:" seems to be ingored. With different mode accelerometer return the same data. As i understand, the only way to solve this is simply to subtract gravity from data. Correct?

import QtQuick 2.0
import Sailfish.Silica 1.0
import QtSensors 5.2
            Label {
                id: lx
                x: Theme.paddingLarge
                color: Theme.secondaryHighlightColor
                font.pixelSize: Theme.fontSizeExtraLarge
            }
            Label {
                id: ly
                x: Theme.paddingLarge
                color: Theme.secondaryHighlightColor
                font.pixelSize: Theme.fontSizeExtraLarge
            }
            Label {
                id: lz
                x: Theme.paddingLarge
                color: Theme.secondaryHighlightColor
                font.pixelSize: Theme.fontSizeExtraLarge
            }
            Accelerometer {
                id: accel
                active: true
                accelerationMode: Accelerometer.User
                onReadingChanged: {
                    lx.text = reading.x;
                    ly.text = reading.y;
                    lz.text = reading.z;
                }
            }
edit retag flag offensive close delete