Jump to content
AVIC411.com

Scripting Tips, Q & A: Making Stuff Happen


Recommended Posts

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!

Link to post
Share on other sites

Demo #2 - this time we're going to make some stuff happen "automatically". Now, I know I said earlier that

How are these scripts / programs activated? Mostly, they happen only when you do something. They don't run by themselves.
and this is still true. So when I say we're going to make something happen automatically, what I really mean is, we're going to make things happen, that get triggered by other things.

 

Or put it another way: In the first example, we made text appear and disappear when touching a button. That was something happening, based on us tapping/clicking things. The other way to make something happen, is to have it get launched by another script, instead of us.

 

Specifically: We're going to build on the first example, by making the colour of our Lat/Long text change automatically, depending on if the map is in Day or Night mode!

 

In this post, we'll be working again with our file scripts_800_480.ui but we will also be working with a new file: navigatemap.ui. Please refer to the first post in this thread, for where to find these two files and the differences between them. Both of these files contain scripts, we do not need to edit navigatemap_800_480.ui at all to make the changes we're going to do today.

 

First, edit scripts_800_480.ui and scroll all the way to the bottom. We're going to add the following lines of code to the end of this file.




 

What we've done here is added three complete scripts. The first one, sc_my_night changes the colour and the outline colour of both the Lat and Long text elements, to a light cyan fill with a dark blue outline. The second script, sc_my_day changes the colour and outline colour of both the Lat and Long text elements, to a dark purple colour with a very light purple outline. Obviously, the 'night' version is supposed to stand out and be readable on a dark map, and the 'day' version is meant to stand out and be readable on a light map.

 

These first two scripts are not really anything new - they are basicaly variations of the scripts we did in the first example; in that they can be called directly and they are modifying properties of visual elements on our map screen. The only difference is, instead of moving them around (changing the x position) we're changing the colours.

 

The third script -- sc_my_daynight -- introduces two important new functions. The first line starts with "runif", which basicaly means, "run this line, if the equation is true." The next thing that happens is a variable name is given, and after that, a value. The variable bNightMode is an internal variable that the nav unit uses to remember if it's in Day mode or Night mode. Literally, if bNightMode = 0 (zero) then nightmode is *not* active. If bNightMode = 1 (one) then nightmode *is* active.

 

So this line is saying, "if we're in nightmode, do this..." or literally, "do this if bnightmode = 1" What follows on that line, enclosed in single quotes, is the command which is to be run. In this case, 'run sc_my_night' which is the script we have to set the lat/long colours to night mode.

 

The second line in this script starts with "elserun" which is literally carrying on from the line above "... or else, do this:" So if the expression evaluated in the "runif" command is false, then the "runelse" line is chosen. What follows is another 'run' command, this time pointing to our sc_my_day script.

 

So far, so good? We have made one script to change the text colours to a day mode, and one script to change the text colours to a night mode, and one script which automatically chooses, based on the map's day/night mode, which of the other two scripts to call. You can save the changes to this file and put it back into the correct folder inside data.zip

 

However, we still need our sc_my_daynight script itself to be called - it has to get launched from somewhere, otherwise it will never run. Now, we know from our first example above, that we could just run it manually - put an "onrelease='run sc_my_daynight'" into an element on the map, and tap that to toggle the text colours. But that's not the goal here -- we want this to happen by itself.

 

So what we need to do, is find some other scripts which run "by themselves" as soon as the map screen comes on. To do this, we look in navigatemap.ui. You see, for almost every file in the 800_480/ui directory, there is a corresponding file in the common/ui directory. The corresponding files are the states and scripts that work with the graphical/display elements in the 800_480 files.

 

Go ahead and open up navigatemap.ui and have a quick look through it. It's pretty messy IMHO with a lot of stuff going on. To help dispell some of the mystery here, I'll provide a quick guide of what happens.

 

When you press the "Map" button, some software in the Nav Unit sends a command to the navi software, which reads "NEXTSTATE st_NavigateMap". This tells the navi software that you want to enter the state "st_NavigateMap". That 'state' exists in navigatemap.ui. If you search the file for "st_NavigateMap" you will find this line:


After that line, come a bunch of "uselayer" commands. These commands tell the program what graphical layers are required. (The layers exist in the 800_480 files, and these specific layers are all in navigatemap_800_480.ui).

 

After the "uselayer" commands, we get a "

 

Scroll down through all the lines, and find the spot that looks like this:

;****************************6.4************************
runif vFitToScreen 1 'run Sc_FitToScreen'

 

It may not look exactly like that, but it will be close. What we want to do now, is add a line before the "" which will point to our sc_my_daynight script. So we're going to edit this area so it now looks like this:

;****************************6.4************************
runif vFitToScreen 1 'run Sc_FitToScreen'
run sc_my_daynight

 

With this change made, save the file, and put it back into the correct folder in data.zip

 

Go ahead and upload data.zip into your nav unit. (You're keeping an unmodified backup, right?!)

 

From now on, every time the map page is accessed, the script is automatically checking your daynight script and changing the text colour of the Lat/Long elements accordingly.

 

--------------------

 

Now, a bit of discussion.

 

With this example, you can change the colour of any text on your map page, based on if it's night or day. All you need to know is the 'id' of the element in question. For our lat and long files, we had named them myLat and myLong. You'll see a lot of stuff in the navigatemap_800_480.ui has unique names, but also a lot of stuff just has "xxx" as it's name. For any element that you want to control with scripting, it is best to assign it a unique name. You can use any name format you like, but it should be unique and descriptive, so you won't forget or make mistakes.

 

Any script that addresses an element name which does not exist, will cause the nav unit to throw a windows error and might cause it to freeze or stop working (until the script is corrected.)

 

You are not limited to changing the colour and the x coordinates either - for static text, you can change the text. For buttons or sprites, you can change the graphic image. For text, you can change the font size, or the font face. The format is like this:

run 'myLat.fontsize 48, myLat.font "tahoma"'
run 'myStaticText.text "text changed to this"'
run 'myButton.bmp "newbutton.bmp"'

 

As you can see, the possibilities are almost endless. You can also see, that it's possible through scripting, to override almost anything in the graphic/display files. You can't add elements, but you can manipulate existing elements in almost every way.

 

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.

 

I've now covered both making stuff happen through direct input (tapping, button pushing) and how to make stuff happen on its own (when changing screens). At the moment I don't have any plans for the next topic, so hopefully there'll be some questions or requests.

 

Cheers!

Link to post
Share on other sites

Stephanie, great job with the scripting info.

 

Question, I read on the blue box thread to open the .ui files in notepad, that is not working for me. I don't see any script. Maybe I'm doing something wrong? Maybe Windows Vista is a little different? Can someone help me out?

Link to post
Share on other sites

Are you opening them in the data.zip file? Use explorer to 'open' (Not extract) the data.zip file, and then inside it, navigate to ui_pioneer\800_480\ui and there you should find a bunch of files that end with .ui which you can open in notepad.

Link to post
Share on other sites

I am opening the file in notepad while it is still zipped, all that it will show in notepad is..

 

 

     Mac OS X            	   2  °     â                                    ATTR;šÉÿ  â   ˜   J                  ˜   J  com.apple.quarantine 0000;48b2fd27;Safari;9AE13D01-D4EE-4707-8ABC-E2EC6F8D87A1|com.apple.Safari         

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   This resource fork intentionally left blank                                                                                                                                                                                                                            ÿÿ

 

I have tried notepad, wordpad, office, openoffice.org, adobe toolkit, I can't seem to find a program that will read the .ui properly. all of the .ini files work great in notepad.

 

thanks for the help,

Jeff

Link to post
Share on other sites

I just figured it out, newb mistake.

 

In DATA.zip/ui_pioneer/800_480/ui there are some ui files with a name that starts off with "._" - for example ._scripts_800_480.ui. That was the file I was trying to open. I didn't notice until I scrolled down there is another scripts_800_480.ui without the "._" at the beginning, that one opened up just fine.

 

Any idea what those ._???.ui files are for?

Link to post
Share on other sites
I just figured it out, newb mistake.

 

In DATA.zip/ui_pioneer/800_480/ui there are some ui files with a name that starts off with "._" - for example ._scripts_800_480.ui. That was the file I was trying to open. I didn't notice until I scrolled down there is another scripts_800_480.ui without the "._" at the beginning, that one opened up just fine.

 

Any idea what those ._???.ui files are for?

 

Since Stephanie is using a Macintosh, those are Mac-specific resource fork files... You can safely remove them from the ZIP file (the file will be quite a bit smaller, too, which is always good)...

Link to post
Share on other sites

Speaking of iGO hacking...

 

Have anyone managed to get the PC version of IGO 8 to work with Pioneer's DATA.ZIP?

 

I've taken it as far as starting with a properly sized Pioneer loading screen, but then it crashes with FFUIERROR: Code = 8 error and quits.

 

If we could get it working on a PC, it would make testing skin changes out so much easier...

Link to post
Share on other sites
Since Stephanie is using a Macintosh, those are Mac-specific resource fork files... You can safely remove them from the ZIP file (the file will be quite a bit smaller, too, which is always good)...

 

I don'tknow how those files are getting into the data.zip... I'm doing all that editing in Windows XP running in Parallels... unless Parallels is creating resource forks for some reason then concealing them (I can't see them). Grrrr.

Link to post
Share on other sites

I don'tknow how those files are getting into the data.zip... I'm doing all that editing in Windows XP running in Parallels... unless Parallels is creating resource forks for some reason then concealing them (I can't see them). Grrrr.

 

Most probably, I would think. Unless you just tried redoing the archive under OSX natively...

Link to post
Share on other sites

I'm completely baffled with this.

 

I've just tried unzipping the zip file on a linux computer and searched it and I can't find any resource forks in it.

 

I don't understand how they are appearing or where they are coming from. I have not unzipped and rezipped the data.zip file in the mac os, (or in windows for that matter) I've only ever explored it in windows and edited it with notepad.

 

And as I said, I can't find the resource forks when I check the file in linux.

 

It's very frustrating.

 

This is the data.zip I'm looking at, the same one I'm using on my F700.

Link to post
Share on other sites

This is all exciting stuff.

 

Have you found any sort of system startup script yet? I have a feeling these units take so long to boot up because they're trying to load too many processes all at once.

 

If you could control what processes start when the system is turned on then you could probably slim it down to the basics and get a faster boot time.

 

I bet that every time my unit turns on it loads all the Navi software in the background. Well, maybe I only use that once or twice a month. I'd rather only wait for the Navi software to load if I press the MAP button or Destination button.

 

I'm also quite sure it's scanning my entire USB hard drive every time it boots up. I'd rather it only scan my USB drive if I select the USB drive from one of the menus.

 

I would just like it to load the main UI and connect my Bluetooth automaticly. Everything else can load as it's needed.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...