Need help converting compass degrees into compass direction

557 views
Skip to first unread message

Dave Handler

unread,
May 15, 2014, 1:27:50 AM5/15/14
to tas...@googlegroups.com
Greetings!

Here's one that I don't quite know how to do in Tasker. In PHP I can calculate the compass direction given the degrees.


I'd have an array of N,NNE,NE,ENE,E,ESE,SE,SSE,S,SSW,SW,WSW,W,WNW,NW and NNW.

My calculation would be this:
fmod((($degrees + 11 ) / 22.5 ) , 16)

fmod in PHP gives you the floating point remainder.

In a nutshell it looks like this:

$windlabel = array ("N","NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S",
  "SSW","SW", "WSW", "W", "WNW", "NW", "NNW");
$dir = $windlabel[ fmod((($winddir + 11) / 22.5),16) ];

So from that formula I can figure out where in the array to choose from. In Tasker I haven't a clue. Never worked with arrays yet.  I also looked at javascript/scriptlet but I know squat about javascript to do anything.  That would be the easiest option I would think.

Any ideas?

The help is always appreciated!

Best Regards

Matt R

unread,
May 15, 2014, 2:54:06 AM5/15/14
to tas...@googlegroups.com
I think this is right:

Degrees To Compass Dir
A1: Variable Set [ Name:%compass To:N,NNE,NE,ENE,E,ESE,SE,SSE,S,SSW,SW,WSW,W,WNW,NW,NNW Do Maths:Off Append:Off ]
A2: Variable Split [ Name:%compass Splitter:, Delete Base:Off ]
A3: Variable Set [ Name:%angle To:-45 Do Maths:On Append:Off ]
A4: Variable Set [ Name:%index To:((floor( (%angle + 11.25) / 22.5)) % 16 + 16) % 16 + 1 Do Maths:On Append:Off ]
A5: Flash [ Text:%compass(%index) Long:Off ]

Should allow any angle (+/- infinite).

Matt

Mike Wilson

unread,
May 15, 2014, 9:21:12 AM5/15/14
to tas...@googlegroups.com
I'd like to add a direction heading to my car dock and this would be perfect, but how are you getting the data from the compass into Tasker?

Dave Handler

unread,
May 15, 2014, 9:58:52 AM5/15/14
to tas...@googlegroups.com
@Mike Wilson for me this is something that the I'm taking from splitting up a weather RSS feed and the wind direction is in degrees.

AutoLocation has a bearing variable in there.  I've seen it.  Not sure about the actual GPS function of the phone though.  Never ventured into that territory.

Wouldn't that eat your battery up though?  How often would you report to get the direction?


@Matt R thanks .. I'm going to give this a go!  And to confirm %angle is the input variable if I'm reading that right. <- way to early in the day for my brain to be engaged! =)


On Thu, May 15, 2014 at 9:21 AM, Mike Wilson <micha...@gmail.com> wrote:
I'd like to add a direction heading to my car dock and this would be perfect, but how are you getting the data from the compass into Tasker?

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/MH1QH3dATsc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Dave Handler

unread,
May 15, 2014, 10:05:20 AM5/15/14
to tas...@googlegroups.com
So when you Variable Set %compass to that it automatically becomes and array?

Interesting!


Mike Wilson

unread,
May 15, 2014, 11:48:59 AM5/15/14
to tas...@googlegroups.com
Ah, I see.  I just assumed is was for GPS, because that's what I was looking to do. A bit of personal projection on my part...

Thanks for the info.  I'm a big fan of the Auto line of plugins and already use several of them; adding AutoLocation to the mix should be pretty painless.

Battery drain might be an issue, but since this is for my car dock, I'll usually have the tablet plugged in to power anyway.

I'll give it a try.

Dave Handler

unread,
May 15, 2014, 12:42:04 PM5/15/14
to tas...@googlegroups.com

Use the car dock event.  I know I saw one.

easiuser

unread,
May 15, 2014, 12:43:37 PM5/15/14
to tas...@googlegroups.com
It becomes an array with the Variable Split action.
Reply all
Reply to author
Forward
0 new messages