[SailfishDevel] QAccelerometer availability ?
Lorn Potter
lorn.potter at jolla.com
Mon Jan 13 17:45:47 UTC 2014
On 13/01/2014, at 6:41 PM, Franck Routier (perso) <alci at mecadu.org> wrote:
> Thanks all for your help.
>
> I ended up with this QML and thought I might share with the list:
>
> - added qt5-qtdeclarative-import-sensors in Requires (.yaml)
> - created a component that checks if the device is shaked:
>
> ShakeSensor.qml
>
> import QtQuick 2.0
> import QtSensors 5.1
>
> Accelerometer {
>
> signal shaked
> property real sensitivity: 30
> property real module: 0
>
> active: true
> dataRate: 20
>
> onReadingChanged: {
> var rx = reading.x;
> var ry = reading.y;
> var rz = reading.z;
> var cmodule = Math.sqrt(rx * rx + ry * ry + rz * rz);
> var cshake = Math.sqrt(Math.pow(module,2)+Math.pow(cmodule,2));
>
> if( cshake >= sensitivity ) {
> shaked();
> }
>
> module = cmodule;
> }
> }
>
>
> This code is strongly indebted to QShake by Sebastiano Galazzo
> <sebastiano.galazzo at gmail.com> for the way to find if device was shaked
> out of accelerometer readings. Thanks to him.
You could have also used QSensorGestures :)
I have not really had time to test and make sure they all work correctly on sailfish, so your milage may vary.
>
> Check the result in my MkPokerPlanning app ! :-)
>
> Best regards,
> Franck
>
> Le 12/01/2014 17:00, Mike Sheldon a écrit :
>> On Sun, 2014-01-12 at 16:42 +0100, Franck Routier (perso) wrote:
>>> But... I get this:
>>>
>>> SensorManagerInterface::interface:78 - Requested sensor id '
>>> "accelerometersensor" ' interface not granted
>>>
>>> Any idea where this comes from ?
>>
>> The emulator doesn't simulate accelerometer sensors, for this sort of
>> thing your only option is to test on device.
>>
>> Cheers,
>> Mike.
>>
>> _______________________________________________
>> SailfishOS.org Devel mailing list
>>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
Lorn Potter
QtSensors/ Connectivity
llornkcor technologies / Jolla Mobile
More information about the Devel
mailing list