I've had a number of questions about some of the scripting in the Navi and thought rather than repeating a lot of stuff in PMs it might be best to discuss it here so everyone can participate.
As we've seen already, there's a lot of neat stuff we can do with these units as far as displays, graphics, fonts, colours and so on.
Here, I'm going to look at how we can manipulate those visual elements through the scripts. If you have a specific scripted function you would like to accomplish, feel free to ask here. I don't promise to solve everything (some things are beyond our control still) but as a group we can learn more tricks and capabilities with these units. I'd love to see things develop to a point where everyone's got their navi customized and tricked out just the way they want it.
Anyhow, on with the show.
First some boring but important facts and figures to deal with.
To save typing, any time I refer to a file which ends with 800_480.ui I am refering to a file you can find in data.zip\ui_pioneer\800_480\ui For example, navigatemap_800_480.ui is such a file.
Any time I refer to a file which ends with .ui that doesn't have the 800_480 stuff, the file will be found in data.zip\ui_pioneer\common\ui. For example, favorites.ui is such a file.
With two exceptions, the files that are in data.zip\ui_pioneer\800_480\ui contain the graphical / style elements. That is, the fonts, image references, and the x and y positional information.
All the files that we find in data.zip\ui_pioneer\common\ui generally contain state and script data - in other words, programming.
How are these scripts / programs activated? Mostly, they happen only when you do something. They don't run by themselves (as near as I can tell...) Still, there are generally two things that launch scripts:
Any time you move from one navi screen to another, you change state. For instance, when you are on the 'Destination Menu' and you tap the Favorites icon, you go from the 'main menu' state to the 'favorites' state. When you select a favorite and then 'go here now', the Navi plots the route then takes you to the 'Navigate Map' state. Every time you change state, a bunch of scripts are run.
When you tap buttons that don't cause a change of screen (like, editing settings within a settings screen) scripts are also run. Another example is the 'Delete Route' button that we've added to the map - it does not change the screen, but it does run a script.
So - I hope I haven't bored you all to tears yet, as we're now going to get to a good part: Let's make something happen!
-----------------------
For this demo, I'm going to use an example from my own system. Let's make it so that we can have our current position in Lat & Long appear on the map when we want it, then have it go away when we don't want it.
To achieve this, we're going to need to edit two files: navigatemap_800_480.ui is our main mapping file. We need to add the Lat/Long display to that file, and we need to add a method to make it appear. We also want to edit scripts_800_480.ui because we're going to need to add two small scripts, which will do the work of making our Lat/Long visible or invisible.
First off, navigatemap_800_480.ui. Edit this file and search it for the clock line. I'm going to use that, as the 'button' to call the Lat/Long. The clock display line should look something like this:
What we're going to do is add a bit of code to the end of this line (when I say 'end of the line' I mean before the ">" symbol), to make it 'clickable'. The code is this:
onrelease='run sc_my_showPos'
so our finished line will now look something like this:
Don't worry if your line does not look exactly like that - odds are your colour and font data will be different, but the main thing is to have that new stuff added at the end.
Now, we also need to add our actual Lat / Long lines too. You can put them in the same area as the clock, in fact add them directly beneath the clock line. The lines we're adding are here:
Now one thing to note is that the x position for these two lines is 1200 - this is outside the size of our screen (800x480). What this means is that these two lines will be invisible - they're way off the screen to the right. Other stuff to note is the colour - you can change the colour to anything you like. The font should be tahoma however - it has the correct 'degrees' symbol. Also note that both of these lines have an 'onrelease' function - both of them run the same script, 'sc_my_hidePos'.
That's all the changes we need to make to navigatemap_800_480.ui - next we need to edit scripts_800_480.ui. This file contains some extra scripts that were added specifically for the 800x480 resolution. We're going to add our custom scripts to this file, because it's a handy spot for them and it's in the same directory as most of the other stuff we work on.
Scroll down to the very bottom of the file, and add these lines:
What these lines do is quite simple. The is the end of the script. What happens in between is what the script is doing. The "run..." line in this case, is what will happen when the script is executed. And you can see, what we are doing is changing the X position of our Lat and Long elements. sc_my_showPos moves the X position to 200, which puts both of the text lines into the middle of our screen where we can see them. The sc_my_hidePos script changes the X position back to 1200, which moves them off screen so we can't see them.
There are other ways to hide and reveal elements, by the way. Moving them on and off screen is the method I've chosen as I've found it most reliable. But this scripting language, like many others, has numerous ways to do the same thing.
This is all that needs to be done, to make it so you can add / remove the GPS Position from your map screen. Save the two files back into the data.zip and move your new data.zip onto your Nav unit and try it out. When the map screen displays, the Lat/Long will be hidden. But if you tap the clock, your Lat/Long should appear centered in the lower part of the map. When you tap either Lat or Long, both Lat/Long should disappear again.
If you have any questions about the stuff I've covered in this post, or if you would like to find out about doing something specific with scripts on your Nav unit, please post in this thread rather than sending me a PM.
This demonstration shows how to make stuff happen in response to a direct input (tap) from you. In my next demonstration, I will show you how to make something happen "automatically".
Cheers!