Device orientation within a range?

Post your questions and help other users.

Moderator: Martin

Post Reply
Ghlave
Posts: 28
Joined: 06 Aug 2013 18:06

Device orientation within a range?

Post by Ghlave » 20 Aug 2014 17:25

I know we can trigger and condition using the preset values for device orientation. Is it possible to set up a condition/expression so that if we have defined a maximum value for azimuth/pitch/roll and a minimum, then we test to see if we've fallen into that range?

I'm aiming to determine when I've got my phone resting on various mounts (desk cradle, car mount, etc) and then behave accordingly. I have two sets of min/max, but I do not see a clear way to test if I'm between them since I'm dealing with both positives and negatives.

Code: Select all

19.08.2014 12:12:14.248 [Flow4] Action 'Init Variables Device Orientation: in azimuth pitch roll' Measured azimuth=1.8208153547798112, pitch=1.0245795449671986, roll=72.01081992092307
19.08.2014 12:12:02.609 [Flow4] Action 'Init Variables Device Orientation: in azimuth pitch roll' Measured azimuth=344.03620128529883, pitch=339.1025039217734, roll=56.276156145297065
Perhaps there is a setting to adjust the sensitivity of the predefined values instead?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Device orientation within a range?

Post by Martin » 21 Aug 2014 17:01

You could use a condition Expression to check a range. Something like this should work:

Code: Select all

azimuth>90 && azimuth<130
The condition will execute the true-branch whenever the variable azimuth contains a value between 90 and 130. You could also check multiple ranges in one condition, e.g.:

Code: Select all

(azimuth>20 && azimuth<50) || (azimuth>100 && azimuth<140)
I just saw that the condition Device Orientation does not provide the measured values of the accelerometer to the flow which would be suited quite well for the purpose of measuring the plain device orientation (without using the magnetometer). I will change the condition so that it will also provide the measured values to the flow starting with the next update of Automagic.

Post Reply