Jump to content

Beep and/or Imageblink according distance to zone


SaMar Team

Recommended Posts

Hello,

 

I'm trying to build my first Wherigo.

One of the ideas I have is to lead the player to a zone through Beeps and/or image blinks according to their distance to the zone.

If the player is closer it will beep faster, if it is farest it will beep slower. I've also to hide the compass and distance.

 

Is this possible? Can you give me some hints?

 

Thanks

Link to comment

possible but difficult.

biggest problem is that your best granularity (i.e. how often you can run code and check stuff) is one second.

so if you want beeps more frequent than that, you'd have to include several different wav/fld (for colorado) files with different beep frequencies.

(image blinking probably won't work too well. beeps are better.)

 

you would most likely have to write custom code to do it. basic idea is to set up a repeating ("interval") timer with 1s frequency, in each tick read the distance to the zone (there is a property or method for that, i don't remember it ... somebody else?), determine how big it is, and either play (or possibly keep count and not play) one beep, or play 1s long sound of many beeps.

 

hope this helps (and i'm pretty sure that somebody else will jump in and provide much more detailed instructions ;e) )

Link to comment
You would most likely have to write custom code to do it. basic idea is to set up a repeating ("interval") timer with 1s frequency, in each tick read the distance to the zone (there is a property or method for that, i don't remember it ... somebody else?), determine how big it is, and either play (or possibly keep count and not play) one beep, or play 1s long sound of many beeps.

You'd most likely use the following to get the distance:

local dist,bearing = Wherigo.VectorToPoint(Player.ObjectLocation, zoneMyZone.Points[1])

I would not suggest using an interval timer for this, matejcik. I'd rather use a countdown timer. I believe the feature would be better done if both the beep and beep interval were to change depending upon how close you are to a zone. If you're far away, a 1.5 second, low beep would sound every five seconds. If you're within a few feet of a zone, a high pitched quarter-second beep could sound every three-quarters of a second. This would lend to greater realism. You don't want the next beep to sound closer or out of order to the current one, so you'd change and start the next countdown only after the current beep has played.

 

SaMar Team, as you may have guessed, adding this feature will require some custom programming. It's not something easily done in a builder application. If someone here has some time, you might be able to ask that person to help write this part of the cartridge. You'd have to ask very nicely. (I don't have that sort of free time until the end of October because I'm working on SeeYouScream.com.)

 

It's a nice idea and I'd be interested in seeing a working generic author script.

Link to comment

Thank you very much for your answers.

I'll try to do this development. If I have any doubt, what is very probable, I'll ask it here, but will try not asking too much.

If I can achieve a final release, it will surelly be posted in the forum, if you think is good enough.

 

Thanks Again

 

Marco

SaMar Team

Link to comment

I agree, both pitch and frequency of sound should be changed, however the sound file should remain the same length e.g. 2 seconds long. This gives the GPS time to do other stuff between processing the countdown events. You might get away with 1 second, depending on what else you want the Wherigo to do.

 

The countdown time is good because that will prevent the sound files overlapping and crashing the Wherigo.

 

So, all doable and doesn't actually require much code - to get the distance is only a few lines which could be put in a numerical variable for you to play with. I should warn you that I have done distance calculations in the past, and for some reason some GPS's (even the same make and model) have for some reason given distances I think in kilometers instead of meters (or it seemed like that anyway). Never got to the bottom of that, hopefully its a bug somewhere in my code. I can have a look at it for you if you want - let me know if you just want an example, or to modify your lua code.

 

The biggest problem I see is the removal of the compass and distance. I'm guessing you still want to see the object in the list of items. Sadly I don't think that will be possible, however you can make the object invisible and it remain active so that the code for making the sound can calculate the distance. Any information you needed to say about the object your navigating too could be put in a zone description.

Link to comment

Wright now I'm just testing Timer, Sounds, Events, etc. Remember that this is my first Wherigo so I've not done any code yet. Any help, contribution, example will be appreciated. I just had that idea, feel free to use it.

 

The biggest problem I'm seeing is that the Timer object does not accept decimal values. What makes me think of two possible solutions:

- Have many sound files and play then according to distance ranges (bigger work, bigger compiled file)

- Play with two sounds: beep and silence of 100ms each (or other duration). If I put two "Wherigo.PlayAudio(zmediaBeep)" it will play it sequencially, so I can use for example:

 

Wherigo.PlayAudio(zmediaBeep)

for i=1 to 9 -- Sorry I haven't study the for statement yet

Wherigo.PlayAudio(zmediaSilence)

 

Please tell me if I'm Wrong.

Link to comment

I didn't spot that this was your first Wherigo earlier and I don't want to put you off, but generally I would suggest starting simple, learn the main pitfalls, limitations and the importance of frequent backups before trying to do something like this, given this sort of stuff is quite advanced.

 

I think I can see what your trying to do with this and its a good idea and well worth pursuing, I always like to see people pushing the boundaries of Wherigos and using it in new ways, but perhaps not as your first Wherigo.

 

If you feel brave, and your used to programming, you may want to have a look at http://www.Wherigo.com/cartridge/details.a...e6-d61b0eab877a its a cartridge I wrote called SNAKES!!! which contains most of what your likely to need. You can download the source and have a look at what I did and pick out the bits you want.

 

Anyway, to answer your comments:

 

You are correct, the timer only accepts whole numbers, hence using sound files containing multiple beeps.

 

It depends on how much other stuff you have, but on the whole I don't think your going to run into too much problem with the size as long as you don't go crazy with sound files. Sticking to a couple of 100K in total of sound file should be fine, especially given each file is probably going to be between 20k and 50k in size.

 

I would need to try the for loop to find out exactly what would happen, but I would suggest you just play the one sound file each time the event is triggered, then start a new countdown timer. This is to ensure you don't get sound files overlapping or overloading the processor.

Link to comment

Maybe your wright about "Shouldn't complicate while being new to this", but i've liked the idea and came here to see if anyone had done already something similar...

 

I'll try to do it anyway... and will keep you informed.

 

The for cicle apparently will not work. It takes some time to start playing each sound file and they become overlapping... as you said...

 

I've this question

Is there any Wherigo programming reference (Classes and Functions)?

Can I use all lua libraries, or just some of them?

 

I'll see you cartdrige, thanks for all your help.

Link to comment

Have a look at:

http://www.lua.org/manual/5.1/manual.html

for the general lua stuff. Not all the stuff will work, especialy the IO file handling, but it will point you in the right direction. Always try something from here first before relying on it.

 

For the Wherigo specific stuff have a look at:

http://wherigobuilder.wikispaces.com/Object+Classes

 

Snakes and Wack a lacky are the two best downloadable examples for this sort of thing.

 

I'm not suprised about the overlapping sound. Some devices may crash if you try to do that. Generally the FOR loop is a bad idea for this sort of thing because what I suspect your trying to do is run things sequentially i.e. in the order you want things to happen, however, the Wherigo code is very much multitasking where you issue the command and carry on to the next statement in your code straight away. The command (play a sound in this case) will take on a life of its own and probably in parallel with your code hence you having lots of sound files running at the same time. Very important fact to consider when doing your user interface. Its also one of the main reasons for crashes typically when the same thing tries to run in parallel with its self or there is a user interface conflict (one very good reason for a countdown timer rather than an interval timer).

The main benefit for this approach is that all the underlying code like tracking where you are, which direction your going, which zone your in, etc etc can run in the background.

Edited by a_snail
Link to comment

Hello Again,

 

I've finally arrived to a first version of this cartdrige. After all, it wasn't too difficult.

I've tested it via builder and in the terrain and it appears to work. I would ask you to test it and give your opinion and/or possible improvements. I've also made a Garmin version, but I can't test it, would someone please test it for me.

 

Some considerations:

- Minimum Timer Interval for this to work without crashing was 2 seconds.

- The maximum time to each beep sound file is 1 second.

- This was made considering a 100 meters radius from the zone.

- the zone remains invisible until you enter it

 

As I told before, feel free to use all the files posted here in what ever you want.

 

Thanks for all your help,

 

Marco

ProxBeepPocketPC.zip

ProxBeepGarmin.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...