GPS4Palm

Source Code Documentation


Utils.c File Reference

#include <PalmOS.h>
#include "ResourceDefines.h"

Include dependency graph for Utils.c:

Go to the source code of this file.

Defines

#define PGDATA   ((volatile UInt8 *)0xFFFFF431L)
#define BLDATA   PGDATA
#define BLMASK   ((UInt8) 0x01)
#define BACKLIGHT_ON   (*BLDATA &= ~BLMASK)
#define BACKLIGHT_OFF   (*BLDATA |= BLMASK)
#define MUXDATA   (MUXDIR+1)
#define MUXPUEN   (MUXDIR+2)
#define MUXSEL   (MUXDIR+3)

Functions

void * GetObjectFromForm (FormPtr form, UInt16 objectID)
 Get pointer to object of specified form.
void * GetObjectFromActiveForm (UInt16 objectID)
 Get pointer to object of active form.
UInt16 MyFrmGetObjectIndexFromPtr (const FormPtr frmP, void *objP)
 Get ID of object of active form given an object pointer.
void Die (const Char *msg)
 generate SysFatalAlert and stop application
void Dopage (UInt16 tbl_id, Boolean down, UInt16 nr_items, Int32 *top_row)
 Table paging function using scrollbar.
void Doscroll (UInt16 tbl_id, UInt16 scl_id, UInt16 nr_items, Int32 *top_row)
 Table scrolling function (using scrollbar).
void UpdateScrollbar (FormPtr form, UInt16 fieldID, UInt16 scrollbarID)
 Field scrolling function (using scrollbar).
void ScrollLines (FormPtr form, UInt16 fieldID, UInt16 scrollbarID, Int16 numLinesToScroll, Boolean redraw)
 Field scrolling function (using scrollbar).
void PageScroll (FormPtr form, UInt16 fieldID, UInt16 scrollbarID, WinDirectionType direction)
 Field scrolling function (using scrollbar).
UInt32 GetRomVersion ()
 Get PalmOS ROM version.
Err SetFieldTextFromStr (FieldPtr field, Char *s, Boolean redraw)
 Set field object's text handle.
void SetFieldText (UInt16 fldID, Char *srcP, Boolean append, Boolean redraw)
 Set field object's text handle.
Err RomVersionCompatible (UInt32 requiredVersion, UInt16 launchFlags)
 Check if appropriate ROM version is available.
char nibble2hex (const char nibble)
 Convert nibble value to hex digit (upper case).
void backlight (Boolean on)
 Switch backlight on/off.
void sermux_enable (Boolean enable)
 Enable serial multiplexer select output.
void sermux_select (Boolean sel)
 Set serial multiplexer select output.

Variables

UInt16 gPortID
 Serial port ID.
Boolean gNewSerialManager
 New Serial Manager available.


Define Documentation

#define BACKLIGHT_OFF   (*BLDATA |= BLMASK)
 

Definition at line 97 of file Utils.c.

Referenced by backlight().

#define BACKLIGHT_ON   (*BLDATA &= ~BLMASK)
 

Definition at line 96 of file Utils.c.

Referenced by backlight().

#define BLDATA   PGDATA
 

Definition at line 93 of file Utils.c.

#define BLMASK   ((UInt8) 0x01)
 

Definition at line 94 of file Utils.c.

#define MUXDATA   (MUXDIR+1)
 

Definition at line 145 of file Utils.c.

Referenced by sermux_select().

#define MUXPUEN   (MUXDIR+2)
 

Definition at line 146 of file Utils.c.

Referenced by sermux_enable().

#define MUXSEL   (MUXDIR+3)
 

Definition at line 147 of file Utils.c.

Referenced by sermux_enable().

#define PGDATA   ((volatile UInt8 *)0xFFFFF431L)
 

Definition at line 92 of file Utils.c.


Function Documentation

void backlight Boolean  on  ) 
 

Switch backlight on/off.

Note:
The function directly accesses hardware registers, this will work on specific devices only.
Parameters:
on true: on / false: off

Definition at line 632 of file Utils.c.

References BACKLIGHT_OFF, and BACKLIGHT_ON.

void Die const Char *  msg  ) 
 

generate SysFatalAlert and stop application

Parameters:
msg pointer to error message string

Definition at line 225 of file Utils.c.

Referenced by InitializeWaypoints(), PackRouteHdr(), PackRouteWpt(), PackWaypoint(), store_rte(), store_trk(), store_wpt(), StoreTrkHdr(), StoreTrkPoint(), and TrackWriteLog().

void Dopage UInt16  tbl_id,
Boolean  down,
UInt16  nr_items,
Int32 *  top_row
 

Table paging function using scrollbar.

Parameters:
tbl_id table ID
down paging direction (up/down)
nr_items number of items
top_row ptr to variable containing top row

Definition at line 245 of file Utils.c.

Referenced by RouteEditFormHandleEvent(), RouteFormHandleEvent(), TrackFormHandleEvent(), and WaypointFormHandleEvent().

void Doscroll UInt16  tbl_id,
UInt16  scl_id,
UInt16  nr_items,
Int32 *  top_row
 

Table scrolling function (using scrollbar).

Parameters:
tbl_id table ID
scl_id scrollbar ID
nr_items number of items
top_row ptr to variable containing top row

Definition at line 275 of file Utils.c.

Referenced by RouteEditFormHandleEvent(), RouteFormHandleEvent(), TrackFormHandleEvent(), and WaypointFormHandleEvent().

void* GetObjectFromActiveForm UInt16  objectID  ) 
 

Get pointer to object of active form.

Parameters:
objectID object ID
Returns:
ptr to object

Definition at line 182 of file Utils.c.

References GetObjectFromForm().

Referenced by AboutFormHandleEvent(), MiscOptsFormHandleEvent(), NavigationFormHandleEvent(), PortFormHandleEvent(), RouteEditFormHandleEvent(), RouteFormHandleEvent(), store_trk(), TrackFormHandleEvent(), and WaypointFormHandleEvent().

void* GetObjectFromForm FormPtr  form,
UInt16  objectID
 

Get pointer to object of specified form.

Parameters:
form form ptr
objectID object ID
Returns:
ptr to object

Definition at line 168 of file Utils.c.

Referenced by GetObjectFromActiveForm(), PortFormHandleEvent(), routeDrawTable(), RouteFormHandleEvent(), trackDrawTable(), TrackFormHandleEvent(), WaypointFormHandleEvent(), and wayptDrawTable().

UInt32 GetRomVersion void   ) 
 

Get PalmOS ROM version.

Returns:
Encoded ROM version.

Definition at line 415 of file Utils.c.

Referenced by RomVersionCompatible().

UInt16 MyFrmGetObjectIndexFromPtr const FormPtr  frmP,
void *  objP
 

Get ID of object of active form given an object pointer.

Parameters:
frmP form ptr
objP object ptr
Returns:
object ID
Note:
This function implements FrmGetObjectIndexFromPtr() on PalmOS versions < 4.0

Definition at line 200 of file Utils.c.

char nibble2hex const char  nibble  ) 
 

Convert nibble value to hex digit (upper case).

This function can be used instead of the PalmOS functions StrAToH (which always returns a 32 bit hex string) and StrPrintF (which ignores the field width specified in the format string).

Parameters:
nibble nibble value
Returns:
0..9, A..F if nibble is valid, else ''.

Definition at line 609 of file Utils.c.

Referenced by ReadFromGPS(), and TrackDBName().

void PageScroll FormPtr  form,
UInt16  fieldID,
UInt16  scrollbarID,
WinDirectionType  direction
 

Field scrolling function (using scrollbar).

Scroll field's contents by entire page size.

Parameters:
form form ptr
fieldID field ID
scrollbarID scrollbar ID
direction winUp/winDown

Definition at line 392 of file Utils.c.

References ScrollLines().

Referenced by AboutFormHandleEvent().

Err RomVersionCompatible UInt32  requiredVersion,
UInt16  launchFlags
 

Check if appropriate ROM version is available.

Parameters:
requiredVersion required version
launchFlags application launch flags
Returns:
0 on success, sysErrRomIncompatible on failure

Definition at line 563 of file Utils.c.

References GetRomVersion(), and RomIncompatibleAlert.

Referenced by PilotMain().

void ScrollLines FormPtr  form,
UInt16  fieldID,
UInt16  scrollbarID,
Int16  numLinesToScroll,
Boolean  redraw
 

Field scrolling function (using scrollbar).

Scroll field's contents by specified number of lines.

Parameters:
form form ptr
fieldID field ID
scrollbarID scrollbar ID
numLinesToScroll number of lines to scroll (negative means up)
redraw flag: redraw field if true

Definition at line 359 of file Utils.c.

References UpdateScrollbar().

Referenced by AboutFormHandleEvent(), and PageScroll().

void sermux_enable Boolean  enable  ) 
 

Enable serial multiplexer select output.

Note:
If any of the SERMUX_* flags is defined, the function directly accesses hardware registers, this will work on specific devices only. If the new serial manager is available (and the PDA hardware supports it), the RTS pin is used instead.
Parameters:
enable true: enable / false: disable

Definition at line 655 of file Utils.c.

References gNewSerialManager, gPortID, MUXPUEN, and MUXSEL.

Referenced by PortFormHandleEvent().

void sermux_select Boolean  sel  ) 
 

Set serial multiplexer select output.

Note:
If any of the SERMUX_* flags is defined, the function directly accesses hardware registers, this will work on specific devices only. If the new serial manager is available (and the PDA hardware supports it), the RTS pin is used instead.
Parameters:
sel true: set output high / false: set output low

Definition at line 720 of file Utils.c.

References gNewSerialManager, gPortID, and MUXDATA.

Referenced by PortFormHandleEvent().

void SetFieldText UInt16  fldID,
Char *  srcP,
Boolean  append,
Boolean  redraw
 

Set field object's text handle.

Will reuse an existing text handle, if any.

Note:
Set srcP to NULL to free memory allocated for text.
Parameters:
fldID field object id
srcP source text pointer
append true: append / false: replace
redraw if true, field will be redrawn

Definition at line 489 of file Utils.c.

References StrCopy, and StrLen.

Referenced by AboutFormHandleEvent(), ApproachFormHandleEvent(), FileSelFormHandleEvent(), HandleMessage(), MainFormHandleEvent(), NavigationFormHandleEvent(), RouteEditFormHandleEvent(), RouteFormHandleEvent(), SkyviewFormHandleEvent(), TrackFormHandleEvent(), UpdateStatus(), WaypointFormHandleEvent(), and WayptEditFormHandleEvent().

Err SetFieldTextFromStr FieldPtr  field,
Char *  s,
Boolean  redraw
 

Set field object's text handle.

Will reuse an existing text handle, if any.

Parameters:
field field object pointer
s source text pointer
redraw if true, field will be redrawn
Returns:
Zero if successful, memory manager error code if allocation/resizing of memory chunk failed.

Definition at line 442 of file Utils.c.

References h, StrCopy, and StrLen.

Referenced by WaypointFormHandleEvent().

void UpdateScrollbar FormPtr  form,
UInt16  fieldID,
UInt16  scrollbarID
 

Field scrolling function (using scrollbar).

Update scrollbar according to field's values.

Parameters:
form form ptr
fieldID field ID
scrollbarID scrollbar ID

Definition at line 312 of file Utils.c.

Referenced by AboutFormHandleEvent(), and ScrollLines().


Variable Documentation

Boolean gNewSerialManager
 

New Serial Manager available.

Definition at line 48 of file Serial.c.

Referenced by DoClose(), DoReceive(), DoReceiveCheck(), DoReceiveFlush(), DoReceiveWait(), DoSetReceiveBuffer(), MainFormHandleEvent(), MapFormHandleEvent(), MapOptsFormHandleEvent(), MiscOptsFormHandleEvent(), NavigationFormHandleEvent(), RouteFormHandleEvent(), sermux_enable(), sermux_select(), SkyviewFormHandleEvent(), TrackFormHandleEvent(), and WaypointFormHandleEvent().

UInt16 gPortID
 

Serial port ID.

Definition at line 54 of file Serial.c.


Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke