OSD
The On Screen Display (OSD) provides status information and controls
blended directly onto the map. These can be implemented using the <osd
... /> tag inside navit.xml Configuration.
You might try NavitConfigurator as a WYSIWYG testing environment for customizing your screen setup.
Examples
To see example layouts for a variety of platforms and screen sizes, see OSD_Layouts.
Enable/Disable
An osd item can be enabled/disabled using the following:
<osd enabled="yes" />
<osd enabled="no" />
Position
The position of an element is specified in x and y pixels or percent of screen height/width from the top-left hand corner of the screen. Negative values will position the element with respect to the bottom-right hand corner of the screen (pixels only - this does not work with percent).
For example:
<osd enabled="yes" x="0" y="0" />
<osd enabled="yes" x="10" y="10" />
<osd enabled="yes" x="-10" y="-10" />
<osd enabled="yes" x="10" y="-10" />
<osd enabled="yes" x="10%" y="30%" />
The first OSD item is placed in the top left hand corner of the screen.
The second OSD item is placed 10 pixels right from the left-hand-side of the screen and 10 pixels down from the top of the screen (i.e. top left of the screen).
The third OSD item is placed 10 pixels left from the right-hand-side of the screen and 10 pixels up from the bottom of the screen (i.e. bottom right of the screen).
The fourth OSD item is placed 10 pixels right from the left-hand-side of the screen and 10 pixels up from the bottom of the screen (i.e. bottom left of the screen).
The fifth OSD item is placed 10% of the screen width right from the left-hand-side of the screen and 30% of the screen height down from the top of the screen.
Size
The sizes of each item can be explicitly set in pixels or percent (of screen width/height) using the ‘w[idth]’ and ‘h[eight]’ attributes.
Example 1:
<osd enabled="yes" x="0" y="0" w="100" h="50" />
This will create an item of width 100 and height 50 pixels from the top-left corner of the item. The top-left corner of the item is also the point which is used when positioning the item using the ‘x’ and ‘y’ attributes.
Example 2:
<osd enabled="yes" x="0" y="0" w="50%" h="10%" />
This will create an item of width 50% of the screen width and height 10% of the screen height from the top-left corner of the item.
Example Configuration contents, based on osd items mentioned so far:
<osd type="text" osd_configuration="1" w="100" h="50" x="-100" y="0" label="${vehicle.position_speed[named]}" font_size="350" command="osd_configuration=2"/>
<osd type="text" osd_configuration="2" w="400" h="100" x="-400" y="0" label="${vehicle.position_speed[named]}" font_size="1200" command="osd_configuration=1"/>
The first osd is the small one, if you click on it, the second one (large) will get visible. If you click on the large one, you will get the small one back.
Note that not all OSD elements support w/h; some always determine their size from their content.
Some of the OSD elements that display icons also support icon_w and
icon_h attributes. When given along with w and h, the image
will have the dimensions of icon_w by icon_h, padded to a total
size of w by h.
OSD elements which support these attributes include
navigation_next_turn and navigation_status.
Alignment
Certain osd items may be aligned. For example, text may be aligned centrally within an item. Alignment is specified using:
<osd enabled="yes" x="0" y="0" w="100" h="50" align="ALIGN_NUMBER"/>
Where the alignment number can be any of the following:
“1”: Align to the top
“2”: Align to the bottom
“0” or “3”: Align to the center (vertical)
“4”: Align to the left
“8”: Align to the right
“0” or “12”: Align to the center (horizontal)
To get a combination of alignment you have to sum vertical and horizontal alignment, so align=”5” would give top left alignment.
4+1=5 |
0+1=1 |
8+1=9 |
4+0=4 |
0+0=0 |
8+0=8 |
4+2=6 |
0+2=2 |
8+2=10 |
Color
Background Color
The osd item’s background color can be changed using the ‘background_color’ attribute. For example:
<osd enabled="yes" x="0" y="0" w="100" h="50" align="0" background_color="#000000c8" />
The color is specified in standard 6-figure hexadecimal, with the last two figures specifying amount of transparency/opacity (00 = fully transparent, FF = fully opaque). The above color is a translucent black.
As can be seen, the previous attributes can be combined to create a filled box of particular dimensions and in a particular position. However, a box is useless without content, which is where the ‘type’ attribute comes in. Default seems to be transparent black (#00000060)
Text Color
The color of osd text items color can be changed using the ‘text_color’ attribute. For example:
<osd enabled="yes" type="text" x="90" y="0" w="110" h="45" align="4" font_size="400" text_color="#ff0000" label="${vehicle.position_speed}" />
The color is specified in standard 6-figure hexadecimal, red in the example above. (to be tested: transparency/opacity for text?) Default seems to be white (#ffffff). For some reason, #000000 does not work, so #111111 is the next best guess for near-black.
Icons
When OSD types use icons, they are usually specified in one of the following two attributes:
src: Filename for a static image.icon_src: Filename for a dynamic image. The string contains a%splaceholder, which will be replaced with an appropriate string (depending on the OSD type) at run time.
If these are specified without a path, Navit will look in its default image dir (platform-dependent) for a matching image. If you specify a path, Navit will look in that path.
You can specify either type of icon with a partial filename, omitting
the extension and size qualifiers, e.g. foobar instead of
foobar_48_48.png. In this case, Navit will try to find an image in a
suitable format and with suitable dimensions. On platforms which support
it, the SVG image will be used and scaled to the desired size. Otherwise
the bitmap file with the closest matching dimensions will be used and
scaled or padded/cropped (depending on the graphics driver). This should
work for all OSDs which use one of the above attributes—if not, please
report a bug.
Types
An osd type is implemented using:
<osd enabled="yes" x="10" y="10" type="OSD_TYPE" />
Current OSD types (from ):
volume
For example:
<osd enabled="yes" x="10" y="10" type="compass" />
<osd enabled="yes" x="10" y="10" type="gps_status" />
<osd enabled="yes" x="10" y="10" type="text" />
<osd enabled="yes" x="10" y="10" type="scale" />
You can determine the supported xml options for each OSD type by reading , searching for “attr_xxx” inside the osd_xxx_new() functions. Most types have at least an “x” and “y” option that determine the location of their OSD.
auxmap
The auxmap creates an additional map on the screen.
Example Configuration contents:
<osd enabled="yes" type="auxmap" x="48" y="48" w="400" h="600"/>
compass
This creates a compass indicating north whenever a GPS
signal is available (by default as a plain, red handle). In routing
mode, the compass shows a second arrow (green by default), indicating
the direction to the destination, and the direct distance to the
destination. Example:
<osd enabled="yes" type="compass" font_size="150" x="-68" y="-58" w="36" h="45"/>
By default the north is pointed by a red handle, to use another color, add the north_color attribute. Also, the default color for the direction to the destination can be set to something else than green by adding the destination_dir_color attribute. Here is an example of color customization:
<osd enabled="yes" type="compass" font_size="150" x="-68" y="-58" w="36" h="45" destination_dir_color="#ff00ff" north_color="#00a0a0"/>
cmd_interface
This is not really a visual element (although it does draw a rectangle on the screen) but can be used to run a command periodically. Example:
<osd name="my_osd_cmdif" update_period="1" enabled="yes" type="cmd_interface" w="200" h="20" x="350" y="175" command='osd_set_attr("my_osd_text","label",
route.route_status==1 ? "Dst set" :
(route.route_status==0 ? "No dst set" :
(route.route_status==3 ? "Not found" :
(route.route_status==5 ? "building path" :
(route.route_status==13 ? "building path" :
(route.route_status==17 ? "path done new" :
(route.route_status==33 ? "path done incremental" : "unhandled"
)))))))
' />
This example assumes you have also defined something like
<osd name="my_osd_text" enabled="yes" type="text" label="initializing" x="-200" y="0" />
Every second (update_period), the command specified in command will be run. In this case, the route status is evaluated and the text attribute of the text element is updated accordingly.
gps_status
This shows a bar indicating the GPS signal
strength. Example:
<osd enabled="yes" type="gps_status" x="-32" y="-58"/>
image
This draws a static image on the screen, useful for creating fancy layouts or for displaying status icons (which can be updated using a cmd_interface control). It behaves like a button but without the ability to run a command on click.
Example Configuration contents:
<osd enabled="yes" type="image" x="48" y="48" src="image.png" />
odometer
Odometer OSD can be used to measure distance and average speed of certain paths during travelling. Starting, pausing and restarting of measurement is supported. Single click toggles enabled state, double click resets distance and average speed calculations and puts odometer into stopped state. The type attribute of this osd should be set to “odometer” in the osd tag of navit.xml . The label attribute can be used to control the displayed quantities.The value of this attribute is used as a format string. In this format string:
${avg_spd}is replaced by the value of average speed (in km/h or mph)${max_spd}is replaced by the value of max speed since reset (in km/h or mph)${distance}is replaced by the measured distance value and the corresponding unit.${time}is the elapsed time with corresponding units.${acceleration}is the instant acceleration of the vehicle (i.e. at that exact time) and corresponding unit. This feature is only available in SVN versions of Navit greater or equal to .
The idle_color attribute defines the text color in
idle state. The idle_color attribute defaults to orange and can be
helpful in combination with the standard attributes
`text_color <#Text_Color>`__ and
`background_color <#Background_Color>`__. You can see an example xml
tag for navit.xml to configure odometer OSD below:
<osd enabled="yes" type="odometer" w="350" h="40" x="30" y="300" font_size="450" label="Dst:${distance} ; Spd:${avg_spd}" name="persistent_odometer_1"
disable_reset="1" />
From svn version 4736 the label string can handle newline characters also ( you can write it as in navit.xml).
Odometers can be made persistent (ie. save actual state on exit and load
state on start) by adding a name attribute with a unique value to
the osd tag (see example above). It is also possible to disable
resetting an odometer by setting the disable_reset attribute (see
example). This can be used to prevent accidental reset of persistent
odometers on certain touchscreen devices where it is easy to send double
click by misadventure.
A persistent odometer will start automatically only if it was active
when quiting Navit with Quit button in menu. When inactive and Navit
is closed, the odometer will start in an inactive state. You can enable
autostart feature by adding to item details:
`` autostart=”1”``
It is also possible to turn off double-click reset function by adding property to item:
`` disable_reset=”1”``
When disable_reset is enabled you can reset odometer by creating
button with command:
`` command=”odometer_reset("````odometer_name``")"
route_guard
route_guard OSD can be used to warn the user by announcement when she/he goes off the route by a specified distance (it also suppresses announcements outside another given limit) so the user should not check the device all the time if she/he is still on the correct path. This can save time finding the correct way when walking on unmarked pathes. The usage is the following. One should create a texfile or binfile map from the route points(see the example textfile map below). For track logs it is recommended to do polygon simplification before to reduce the number of route points. (for example the gpsbabel tool can do this) The name attribute of the map item that contains the route waypoints should be set so the OSD can distinguish the used item from other items. Any item type can be used that supports multiple coordinates (type track is recommended since is is not used for routing for any vehicles). The map entry in the active mapset of navit.xml should also have its unique name set:
<map name="route_guard_test" type="textfile" enabled="yes" active="1" data="/home/dandor/tmp/navit_path_guard_test/route_guard_example_map.txt"/>
An OSD entry should be set up with the appropriate item and map names and with a type=”route_guard” attribute:
<osd enabled="yes" type="route_guard" item_name="route_guard_test" map_name="route_guard_test" x="-200" y="650" min_dist="10" max_dist="200" update_period="10" />
At distances greater than min_dist meters from the route polyline a warning will be announced. At distances greater than max_dist meters from the route polyline no warning will be announced to avoid annoyance of the user when she/he intentionally leaves the route. The update_period parameter is used to set the periodicity of the distance checks.
An example textfile mapthat can be used with route_guard is shown below:
scale
The ‘scale’ type overlays a simple ruler and scale on
the current map. This updates as you zoom in or out. For example:
<osd enabled="yes" x="0" y="-84" w="240" h="26" font_size="150" type="scale"/>
speed_cam
The speed_cam OSD item is capable of providing both audible and
visual information related to speed cameras in the near vicinity. The
OSD item is capable of detecting cameras in OSM-derived
binfiles, IGO8-derived binfiles (see method below),
or (perhaps the easiest) directly from IGO8 files themselves.
IGO8 Format
An IGO8 file is a type of csv. The format defines the latitude and longitude of a speed camera, the type of camera, speed-limit and direction in which the camera is facing. Country-specific IGO8 files can be downloaded from http://speedcamerapoi.com/download.php. An example extract is shown below:
X,Y,TYPE,SPEED,DIRTYPE,DIRECTION
13.74132,51.04641,2,50,0,0
8.34681,49.62934,2,50,0,0
12.11390,49.02778,3,0,0,0
8.83805,53.08262,3,0,0,0
9.14767,47.68987,3,0,0,0
6.94611,51.12167,1,30,0,0
7.82556,51.46417,1,70,0,0
14.17350,51.12366,5,50,0,0
13.89502,52.25109,5,100,0,0
Use
To use the speed_cam OSD type, the following OSD item must be added
to navit.xml.
<osd enabled="yes" type="speed_cam" w="550" h="40" x="30" y="350" font_size="450" text_color="#00FF00" label="${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" />
Most parts are self explanatory:
announce_onby default is 1 (i.e. this osd item will announce upcoming cameras with a “Look out! Camera!” warning) if this attribute is not set.labelcan display the following variables. The values in ${STRING} are replaced with the appropriate number or word when running Navit:${distance} - straight-line distance to the camera
${camera_type} - type of camera
${camera_dir} - direction in which the camera operates: all, single direction or both directions
${direction} - direction which the camera is facing, in degrees (0-360, i.e. north, east, south, west etc)
${speed_limit} - the active speed limit which the camera may be enforcing
The label string may contain line breaks. These must be written as in navit.xml.
Note:
When using an OSM-derived binfile this OSD can only determine the distance to the camera. This is due to limitations of the OSM data.
When there is no camera nearby, the OSD will automatically disappear.
Camera Types
When used together with IGO8 files, or IGO8-derived binfiles, the OSD can recognise the following camera types:
None
Fix
Enforces: Speed
Description: Probably the most common type of traffic enforcement camera. Usually located on the side of the road, and uses radar to detect vehicle speed. Can take photos from either the front or the rear. Front facing cameras tend to use IR flash guns, instead of traditional bulb flashes, to ensure that the driver does not get blinded.
Suggested English name: Fixed.
Traffic lamp
Type: Traffic light enforcement camera
Enforces: Speed and/or red light (unsure)
Description: These cameras seem to be located inside (?) traffic lights. It is unknown whether these are for speed, red light or both.
Suggested English name: Traffic light.
Red detect
Enforces: Red light
Description: Located close to traffic light controlled junctions, these cameras will detect if a car has run a red light. Usually, these cameras will face down the flow of traffic, thus take a picture from the rear.
Suggested English name: Red light.
Section
Enforces: Speed
Description: In the UK at least, these cameras are used a lot on motorway roadwork sections. CCTV ANPR cameras are located at strategic locations along the works, and take average speed readings of vehicles by reading their number plates. Nightime use is facilitated through the use of IR lamps.
Suggested English name: Avg speed
Mobile
Type: Mobile speed enforcement camera
Enforces: Speed
Description: There are many types of mobile cameras: common ones are hand-held cameras, either held by an officer from the police car window, or mounted on a tripod. Other types include those mounted on the police car dashboard or rear parcel shelf, or those which point through windows of special speed camera vans (common in the UK)
Suggested English name: Mobile
Rail
Type: Railway level crossing enforcement camera
Enforces: barriers/access
Description: Used at railway level crossings, to enforce any barriers or warning lights. It’s usually an offence to enter the level crossing once you’ve been warned not to (however far away the train is), hence the cameras.
Suggested English name: Level crossing
Traffipax(non persistent)
Type: Mobile speed enforcement camera
Enforces: Speed (?)
Description: Note: this is conjecture at the moment. This seems to be a specific type of mobile speed camera.
Suggested English name: Mobile
Note: It is possible to enable warnings selectively for each camera type by the usage of the flags attribute. By default announcements are enabled for each camera types. flags should be the sum of the required camera types’ values from the table below. (Eg. to enable warnings for fixed, and section cams the value should be 9 (1 + 8) )
CAM_FIXED |
1 |
CAM_TRAFFIC_LAMP |
2 |
CAM_RED |
4 |
CAM_SECTION |
8 |
CAM_MOBILE |
16 |
CAM_RAIL |
32 |
CAM_TRAFFIPAX |
64 |
speed_warner
Speed warner osd module notifies the user about
exceeding speed limits either visually or by announcement. The validity
of speed limit data and the exceeding of limit determines the color of
the displayed limit. When the limit is exceeded with some tolerance an
announcement is emitted. Percentage (speed_exceed_limit_percent
attribute of the osd tag) and fixed (speed_exceed_limit_offset
attribute of the osd tag) tolerance value can be set. When both limits
are exceeded an announcement is done. One can use the maxspeed
attribute in roadprofile tag to set country specific max speed for
that road type. To determine the used speed limit, the speed limit in
OSM data is taken into account in the first place if exists, if not
maxspeed attribute is checked in roadprofile. Announcement can be
disabled or enabled using the announce_on attribute. Text only mode
can be enabled by adding label=”text_only” in the osd tag. For correct
operation of speed warner tracking (Lock on road) needs to be
enabled. An example xml entry to enable speed warner can be seen below:
<osd enabled="yes" type="speed_warner" w="50" h="50" x="30" y="-300" font_size="350" speed_exceed_limit_offset="15" speed_exceed_limit_percent="10" announce_on="1" label="text_only" />
Status dependent background images can be set for speed warner by setting the label attribute of the osd tag like this:
`` label=”images:red_img.xpm:green_img.xpm:grey_img.xpm:”``
After “images:” the image filenames are listed for red green and grey states in this order. The filenames are separated by colon (:) character (see example above).
stopwatch
This OSD displays a stopwatch which can be useful for measuring time needed to take certain paths. Pausing, restarting and resetting counter is supported. Single click toggles counting, double click resets the counter. The osd accepts the standard osd attributes. The idle_color attribute defines the text color in idle state. The idle_color attribute defaults to orange and can be helpful in combination with the standard attributes text_color and background_color. The following example shows how to enable stopwatch osd:
<osd enabled="yes" type="stopwatch" x="100" y="200" font_size="400" w="100" h="30" disable_reset="1" />
It is also possible to disable resetting a stopwatch by setting the disable_reset attribute (see example). This can be used to prevent accidental reset on certain touchscreen devices where it is easy to send double click by misadventure.
text
The text type is useful for displaying static text,
current GPS data, routing information or status information on the map
view (viewable in the status bar in GTK mode). This is implemented in
the following manner:
<osd enabled="yes" type="text" label="${GPS_OR_ROUTE_DATA}" x="-200" y="0" />
The label attribute can hold any combination of static text and
placeholders, which will be replaced with data and updated in real time
when displaying. The resulting text is cropped to the box dimensions
given and there is no automatic line wrapping. Nevertheless labels may
span multiple lines – explicitely insert a \n where you want a
linebreak. The multi-line text obeys alignment settings.
When using the text type, it is useful to set the width and height of each item, in addition to aligning the text using the ‘align’ attribute.
Placeholders are specified as ${section.attribute}. Attributes which can be used in labels include:
Attribute |
Value |
|---|---|
navigation |
Section containing routing information, available only when routing |
navigation.item |
Information related to the entire route |
navigatio n.item.destination_length[named] |
Remaining distance to destination. Use navigatio n.item.destination_length[value] to get the bare value (without units) or navigati on.item.destination_length[unit] to get just the unit. Useful for displaying the value and the unit in two rows, or in different font sizes. |
navigatio n.item.destination_time[arrival] |
Estimated time of arrival |
navigation. item.destination_time[remaining] |
Estimated remaining time |
navigation.item.street_name |
Name of the road which the vehicle is currently on (e.g. Via Gallarate) |
naviga tion.item.street_name_systematic |
Number/reference of the road which the vehicle is currently on, if available (e.g. SS33) |
navigation.item[1] |
Information related to the next navigation item (from the next maneuver to the one following it) |
navigation.item[1].length[named] |
Distance to next maneuver. Use navigation.item[1].length[value] and navigation.item[1].length[unit] in the same manner as for nav igation.item.destination_length. |
navigation.item[1].street_name |
Name of the road following the next maneuver (cf. navigation.item.street_name) |
navigatio n.item[1].street_name_systematic |
Name of the road following the next maneuver (cf. navigat ion.item.street_name_systematic) |
navigati on.item[1].navigation_long_exact |
Sentence explaining the next maneuver (e.g. ‘Turn left in 2.2 miles into Main Street’) |
navit |
|
navit.messages |
|
tracking |
Section containing information on current track, available whenever valid GPS information and corresponding map data is available. The difference to navigation is that tracking data is also available when not routing. Ensure that tracking=”1” is set in the tag to use these attributes. |
tracking.item |
Information related to the road the vehicle is currently traveling along |
tracking.item.route_speed |
Speed limit on the road which the vehicle is currently on |
tracking.item.street_name |
Name of the road which the vehicle is currently on (cf. navigation.item.street_name) |
trac king.item.street_name_systematic |
Number/reference of the road which the vehicle is currently on (cf. navigat ion.item.street_name_systematic) |
vehicle |
Section containing GPS information, available whenever valid GPS information is available |
vehicle.position_coord_geo |
Current position. Use vehi cle.position_coord_geo[format] to control the output format of the coordinates (works reliably from onwards). Valid format values are:
If omitted, pos_degminsec will be assumed. |
vehicle.position_direction |
Current orientation (direction of travel) in degrees |
vehicle.position_height |
Current altitude in m |
vehicle.position_qual |
Number of satellites which your GPS receiver can see. However, your receiver may not be using all of them for positioning due to low signal etc… |
vehicle.position_sats_used |
Number of satellites used |
vehicle.position_speed |
Current speed in km/h |
vehicle.position_time_iso8601 |
Current GPS time (roughly the same as UTC, with a few seconds of difference) |
vehicle .position_time_iso8601[string] |
Current GPS time with formatting string: { iso8601 | [ local; | offset ; ] format }
Examples:
|
Examples:
<!-- ALWAYS AVAILABLE (if GPS connected) -->
<!-- Current Speed (integer in km/h) -->
<osd enabled="yes" type="text" label="${vehicle.position_speed}" x="-200" y="0" />
<!-- Current Coordinate Position -->
<osd enabled="yes" type="text" label="${vehicle.position_coord_geo}" x="-200" y="0" />
<!-- Current Altitude (in metres)-->
<osd enabled="yes" type="text" label="${vehicle.position_height}m" x="-60" y="-80" />
<!-- Current Direction of Travel (integer from 0-360) -->
<osd enabled="yes" type="text" label="${vehicle.position_direction}" x="-60" y="-80" />
<!-- Number of Satellites Used / Number of Satellites Available -->
<osd enabled="yes" type="text" label="${vehicle.position_sats_used}/${vehicle.position_qual}" x="-50" y="40" />
<!-- ONLY AVAILABLE WHEN ROUTING (i.e in Sat-Nav mode) -->
<!-- Currently on ROADNAME -->
<osd enabled="yes" type="text" label="Currently on ${navigation.item.street_name_systematic}" x="0" y="0" />
<!-- Distance to next turn (in metres) -->
<osd enabled="yes" type="text" label="${navigation.item[1].length[named]}" x="0" y="-105" />
<!-- Next turn is onto ROADNAME -->
<osd enabled="yes" type="text" label="Turn onto ${navigation.item[1].street_name_systematic}" x="0" y="-105" />
<!-- Estimated time of arrival (HH:mm) -->
<osd enabled="yes" type="text" label="ETA ${navigation.item.destination_time[arrival]}" x="-150" y="-30" />
<!-- Entire route distance remaining (in km) -->
<osd enabled="yes" type="text" label="DR ${navigation.item.destination_length[named]}" x="-85" y="-60" />
<!-- Time remaining until destination is reached (HH:mm) -->
<osd enabled="yes" type="text" label="TR ${navigation.item.destination_time[remaining]}" x="-85" y="-90" />
toggle_announcer
Displays a button to enable/disable speech
output.
<osd enabled="yes" type="toggle_announcer" x="-65" y="95" w="60" h="60"/>
You can specify custom bitmaps for the icon: Create two bitmap files named gui_sound.png and gui_sound_off.png. Then modify your OSD entry like this:
<osd enabled="yes" type="toggle_announcer" x="-65" y="95" w="60" h="60" icon_src="/path/to/%s.png"/>
(replacing /path/to with the path to the two files). Other filenames
will also work, as long as both filenames follow a common format,
distinguished only by gui_sound vs. gui_sound_off somewhere in the
filename. The part “%s” will be replaced with one of these two strings
when loading the images.
Font
Face
The font can be specified using the font attribute, as below:
<osd enabled="yes" type="text" label="${vehicle.position_coord_geo}" x="0" y="0" w="360" font="Arial" />
Size
The size of font used in an osd item can be set using the ‘font_size’ attribute, for example:
<osd enabled="yes" type="text" label="${vehicle.position_coord_geo}" x="0" y="0" w="360" font_size="300" />
This creates an osd item displaying the current position coordinates with a font size of 300. Default font size is currently 200.
For text color, see the section Color on this wiki page.
osd_configuration
An osd item can have configuration flags using the following:
<osd osd_configuration="1" />
The OSD item will only be visible if the value of osd_configuration
from the navit tag bitwise ANDed with the value of
osd_configuration of the OSD is not zero. So you can have up to 32
dynamically changeable osd layouts. Don’t overuse this feature, since a
non-visible osd will still consume memory and cpu cycles.
Note that osd_configuration cannot be used together with
enable_expression: when both are specified for the same OSD item,
only the enable_expression will take effect. See
#enable_expression for a workaround.
enable_expression
An OSD item can be shown conditionally (visible only if the condition is true) with the following syntax:
<osd enable_expression="navigation.nav_status&gt;=3"/>
In this example the OSD will be shown only when Navit is in routing mode.
Expressions use the syntax described in #command and can use the attributes in #Attributes (currently not an exhaustive list).
Not all OSD elements honor this command. Those that do currently (as of
r5904) include button, compass, text,
navigation_next_turn. OSD items that ignore this attribute include
image.
Where enable_expression is set and supported, it overrides any
osd_configuration attribute that may be set for the same OSD item.
However, you can add a condition to your enable_expression to get
the same functionality. The equivalent of osd_configuration="1" is
enable_expression="osd_configuration&1".
This even allows you to do things which are not possible with a simple
osd_configuration:
Testing for an exact set of flags:
osd_configuration="1"will enable the OSD wheneverosd_configurationhas the least significant bit set (in other words, when it evaluates to an odd number such as 1, 3, 5…). Withenable_expression="osd_configuration==1"you can have an OSD show only whenosd_configurationis 1 and remain hidden for any other number.Combining multiple expressions: For example,
enable_expression="navigation.nav_status>=3 || osd_configuration&1"will cause an OSD item to show when the least significant bit ofosd_configurationis set or when Navit is in routing mode, in which case the OSD configuration doesn’t matter. On the other hand,enable_expression="navigation.nav_status>=3 && osd_configuration&1"requires both conditions to be true in order for the OSD item to show.
command
An osd item can contain a command as in those examples:
<osd command="osd_configuration=2" />
<osd command="zoom_in()" />
The command will be called when the item is clicked.
Commands can contain expressions or one of the commands listed under Commands.
Expressions may use the following operators:
~ ! Bit-wise and logical NOT
* / % Multiplication, division, modulo
+ - Addition, subtraction
== != <= >= < > Comparison (equal, not equal, less than or equal, greater than or equal, less than, greater than)
& | ^ Bit-wise AND, OR, XOR
&& || Logical AND, OR
? : Conditional (a?b:c will return b if a is true, else it will return c)
= Assignment
, Comma operator
The + is overloaded to work as string concatenation, when both arguments are strings/text.
A command attribute may contain a sequence of expressions or commands, separated by comma “,” or semicolon “;”.
Examples
#1
The following will change osd config to 32 and display the route description (text-version)
<osd type="text" label="sth" command="osd_configuration=32,gui.route_description()/>
Available attributes for use in expressions are listed under Attributes.
#2
<osd name="autozoom_button" enabled="yes" type="button" src="$HOME/.navit/buttons/autozoom.xpm" x="-68" y="235" use_overlay="1" accesskey="a" command='autozoom_active=autozoom_active==0?1:0;
osd[@name=="autozoom_button"].src = autozoom_active==0?"$HOME/.navit/buttons/autozoom.xpm":"$HOME/.navit/buttons/autozoom2.xpm";
' />
src=”$HOME/.navit/buttons/autozoom.xpm” is the xpm at program start.
Command means: if autozoom_active equals 0, then set it to 1, otherwise set it to 0.
osd.src means: if autozoom_active equals 0, then use autozoom.xpm, otherwise use autozoom.2xpm.
Keybindings
It is possible to bind keyboard keys to On Screen Display items. This is
especially useful for those OSD items which include the command=
attribute, so that a press of the key will perform that command.
For example, to use the space bar to zoom out, the OSD item should be:
<osd enabled="yes" type="button" x="0" y="-96" use_overlay="1" command="zoom_out()" accesskey="&#20;" src="zoom_out.xpm"/>
As you can see, the original zoom out OSD button has been altered
slightly using the use_overlay and accesskey attributes. The
accesskey attribute takes the ascii code of the key, in html format.
To find out the code of a particular keyboard key, use the following site (codes from   to ~ should work fine): http://www.w3schools.com/tags/ref_ascii.asp.
Using the above site, we find that the code for the tab key is 	
(note that this is outside the range of codes shown above - experiment a
little!). Therefore, the final accesskey code is 	. We can
now use tab for zooming in:
<osd enabled="yes" type="button" x="-96" y="-96" use_overlay="1" command="zoom_in()" accesskey="&#09;" src="zoom_in.xpm"/>
The following codes are internally defined within Navit, and cannot be used (defined in keys.h):
``           ``
Transparent Icons and Overlays
Configurable keybindings will usually be used with OSD buttons, which will probably have an icon configured. Overlays do not work that well with png icons, especially those with transparent sections in it - it is worth converting any png icons which you might be using in the OSD button to xpm icons. In Linux, you can use imagemagick to convert between the two:
`` $ convert my_custom_icon.png my_custom_icon.xpm``
Don’t forget to change the src attribute so that it points to the
xpm instead of the png! Note: This may or may not work on Windows
builds
Example
An example implementation is shown below.
Navit-internal-osd-fon.png
Top left is type=”compass”
Middle left are three OSD elements of type=”button”
Bottom left is type=”navigation_next_turn”
Top right is type=”text” with label=”${navigation.item.destination_time[arrival]}” and label=”${navigation.item.destination_length[named]}”
More osd layouts can be found at OSD_Layouts.
Toggle day/night layout
Displays a button to change the current active layout from day to night and vice versa (from svn 5875).
<osd enabled="yes" type="button" x="500" y="500" command='layout_name=layout.nightlayout?layout.nightlayout:layout.daylayout' src="zoom_in.png"/>
Show route status
This example displays the status of the routing engine. It assumes the
following bitmaps to be present in $HOME/.navit/buttons:
def.png: No destination set, not routing
set.png: Destination has been set (this will usually be shown when GPS is not available)
no_destination.png: No route to the destination found (this happens when no road connection between position and destination could be found in the map data)
calculate.png: Route is being calculated
up.png: Routing (new)
route.png: Routing (incremental)
<osd name="status" enabled="yes" use_overlay="1" w="102" h="102" type="button" command="" src="$HOME/.navit/buttons/def.png" x="2" y="-213" />
<osd name="status1" h="1" w="1" update_period="1" enabled="yes" type="cmd_interface" x="11" y="416" command='osd[@name=="status"].src = route.route_status==1 ? "$HOME/.navit/buttons/set.png" :
(route.route_status==0 ? "$HOME/.navit/buttons/def.png" :
(route.route_status==3 ? "$HOME/.navit/buttons/no_destination.png" :
(route.route_status==5 ? "$HOME/.navit/buttons/calculate.png" :
(route.route_status==13 ? "$HOME/.navit/buttons/calculate.png" :
(route.route_status==17 ? "$HOME/.navit/buttons/up.png" :
(route.route_status==33 ? "$HOME/.navit/buttons/route.png" : "unhandled"
))))))' />
</pre>
</code>
==Show name of current street==
<source lang="xml">
<osd enabled="yes" type="text" label="${tracking.item.street_name_systematic} ${tracking.item.street_name}" font_size="200" x="0" y="-22" w="100%" h="22"/>
Show name of street after next maneuver
<osd enabled="yes" type="text" label="${navigation.item[1].street_name_systematic} ${navigation.item[1].street_name}" font_size="200" x="0" y="0" w="100%" h="22"/>
Icon source setting for OSD
The Nokia N8x0 platform (and possibly others) is not very supportive of .svg image files. Navit on the other hand relies heavily on svg. The result is often missing images from your display. In the examples above you may need to replace the .svg with .png. The solution for Next Turn is to use the following config addition:
<osd enabled="yes" type="navigation_next_turn" x="325" y="-135" w="150" h="100" align="15"
background_color="#a60c0f00" icon_src="$NAVIT_SHAREDIR/xpm/%s_wh_48_48.png" />
Note the icon_src parameter specifies the template for the image file names. This should work for all OSD items.
If you don’t have the .png files already, you can create them this way:
$ cd $NAVIT_SHAREDIR/xpm$ for f in *wh.svg; do convert -background none -resize 48x48 $f `basename $f .svg`_48_48.png; donePlease note that the OSD layer is still under development, and content on this page may be out-of-date.
Commands
GUI commands
GUI commands can be used within from GUI menu items by specifying the function name as shown below. If you want to call them from elsewhere (e.g. from OSD items), prefix them with gui. (e.g. gui.menu()) The following are available (from ):
Command |
Meaning |
|---|---|
abort_navigation() |
Cancels navigation: The route is cleared and Navit switches to tracking mode. |
about() |
Displays the About screen. |
back() |
FIXME: description to be completed. |
back_to_map() |
Leaves the menu and returns to map view. |
bookmarks() |
Shows bookmarks. |
get_data() |
FIXME: description to be completed |
locale() |
Shows locale information. |
log |
FIXME: description to be completed |
menu() |
Brings up the menu (used as gui.menu() in OSD items in order to have a dedicated menu button). |
position( position, text, flags ) |
Presents possible operations on
a position (set as current
location, set as destination
etc.). |
quit() |
Closes Navit. |
refresh() |
Redraws the currently active
menu. Typically used by menu
items which change parameters
used in |
route_description() |
Shows a turn-by-turn description of the active route when in navigation mode. |
route_height_profile() |
Shows a height profile of the active route when in navigation mode. |
set( pattern, args ) |
Save an option to be recovered next time navit is opened. Pattern is used to search the old value to delete it, and also it’s used to write the new value. The ‘*’ character inside pattern will match with any string when searching for the old value, and it will also be substituted by the values from ‘args’ when writing the new value. For example:
|
img( class, src, text, onclick_pre, onclick_set_pattern, [onclick_set_replaces…,] onclick_post ) |
Generate and print the code of a button with the selected image, text and actions
EXAMPLE: In this example, gui_active and gui_inactive images are used to indicate if the option is enabled or not. No onclick_pre command is executed, set is used to save user choice and finally refresh command is executed. |
setting_layout() |
Presents a selection of available screen layouts. |
setting_maps() |
Presents a dialog to switch between available mapsets. |
setting_rules() |
Presents a dialog for setting various internal options. |
setting_vehicle() |
Presents a dialog for selecting the active vehicle. |
town() |
Presents a dialog for selecting an address, starting with a town. |
write( attribute ) |
Writes an attribute. Used by the GUI menu in conjunction with ‘’’ |
The button type creates a placeholder in which a
specified image is clickable; this is usually accompanied by a
This osd item displays an image of the
next turn which the vehicle will have to undertake. Nothing is displayed
if routing is not on (i.e when just using navit for GPS instead of
sat-nav).
This OSD item displays the
current status of the routing engine, e.g. the route is being calculated
or Navit is still waiting for a GPS fix.