Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qml accelerometer; accelerationMode property not working?



  • I am struggling with getting clean (with excluded gravity) readings from qml Accelerometer. It's looks like accelerationMode: Accelerometer.User takes no effects at all ( even onAccelerationModeChanged is not firing). Am I supposed to write c++ Accelerometer wrapper, or algorithm extracting user movement on my own?

    Accelerometer{
     id: acc
     active: true 
     skipDuplicates: true
     accelerationMode: Accelerometer.User
    
    onReadingChanged: {
         console.log('acc x', reading.x)
         console.log("acc y", reading.y)
         console.log('acc z', reading.z)
    } }
    

    It's a bug, or my fault?



  • @lockheed just in case, have you tried this example AccelBubble?
    In addition could you please provide more details about your environment (OS, Qt version, device where you run app, etc.)



  • AccelBubble: ball is not moving at all, readings from accelerometer are the same as in my app (z is about 9-9.5, showing gravity acceleration).

    Devices:

    • Lenovo Tab A7 Android 4.4
    • LG k8 LTE Android 6.0

    Host os: Win 10 ; Qt: 5.10.1

    To show what I am complaining about, there is a small code snippet , modified accelbubble.qml file, which shows current accelerometer readings, and allow to change accelerationMode 'on the fly'. As far as I understand, changing mode from combined, to user, to gravity, should affect readings values.

    (besides modified accelbubble.qml, I put
    <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/> in Manifest.xml)



  • My fault. I didn't notice that some hardware backends isn't supporting different accelerationModes. Problem solved.


Log in to reply