Link here

GPS Forth Demo


This section presents the Forth version of the demonstration program source code. This instrumentation example shows how to acquire global positioning system (GPS) data and display it on the serial port. This program is a good starting point if you are building your own GPS data logger.

GPS Forth Demo

\ Filename: GPS_WC_Demo.c
\ Date: Feb 27, 2007
\ copyright 2007 Mosaic Industries, Inc.  All rights reserved.
 
\ This is a demonstration program for the GPS Wildcard.
\ Make sure that GPS_MODULE_NUM matches your hardware jumper settings.
\ Note: in real applications, the GPS service should be invoked from a separate task.
 
HEX
FIND WHICH.MAP        \ do this only for page-swapping platforms!
IFTRUE                \ nesting is allowed if ends are sequential
  EXECUTE  0=         ( -- standard.map? ) \ run which.map
  IFTRUE 4 PAGE.TO.RAM  \ if in standard.map, transfer to download map
         5 PAGE.TO.RAM
         6 PAGE.TO.RAM
        DOWNLOAD.MAP
  ENDIFTRUE
ENDIFTRUE
 
\ if your memory map is not already set, set it here after load of GPS driver:
\ 800 4 DP X!  5800 4 NP X!  \ for kernel V4.xx
\ 0x8000 1 DP X!  0x8000 0x11 NP X!  \ for kernel V6.xx
 
F WIDTH !      \ set width of names stored in dictionary
 
ANEW GPSDemo_Code   \ define forget marker for easy re-loading
 
 
4 CONSTANT GPS_MODULE_NUM  \ MUST match hardware jumper settings!
 
: GPS_RUN   ( local_hour_offset\module_num -- )
\ this function initializes the GPS Wildcard board and prints a formatted summary
\ of GPS info to the terminal every 5 seconds.  Type any key to terminate the function.
\ Note: in real applications, the GPS service should be invoked from a separate task.
   2 NEEDED DUP 0
   LOCALS{ &print_counter &module } ( local_hour_offset\module_num -- )
   GPS_INIT 0= ( ok? -- )
   IF CR ." Starting GPS info dump.  Type any key to exit this function."
      CR ." This function gets a data frame from the GPS once per second,"
      CR ." and prints a statement telling of the fix validity."
      CR ." If the fix is not valid, make sure your antenna is outside,"
      CR ." and give the GPS some time (5 minutes worst case) to acquire its satellites."
      CR ." This function periodically calls GPS_Info_Dump to summarize the GPS data."
      CR CR
      BEGIN
         &module GPS_UPDATE  CR CR ." Valid fix?: " ( error -- ) \ runs every second
         IF ." NO"
         ELSE ." YES"
         ENDIF
         &print_counter 1+ DUP TO &print_counter
         5 =                           \ detailed print every 5 seconds
         IF 0 TO &print_counter
            GPS_INFO_DUMP                 \ print extracted info
            CR CR
         ENDIF
         ?KEY UNTIL  \ type any key to end this routine
   ELSE CR ." GPS_INIT FAILED!"
   ENDIF
;
 
: GPS_DEMO  ( -- )
\ this function initializes the GPS Wildcard, powered by Garmin, with a specified time zone and module number,
\ and prints a formatted summary of GPS info to the terminal every 5 seconds.
\ Type any key to terminate the function.
\ Note: in real applications, the GPS service should be invoked from a separate task.
   GPS_PACIFIC_TIME GPS_MODULE_NUM ( local_hour_offset\module_num -- )
   GPS_RUN
;
 
 
FIND WHICH.MAP
IFTRUE                \ for kernel V4.xx platforms...
    XDROP             ( -- ) \ drop xcfa
   4 PAGE.TO.FLASH
   5 PAGE.TO.FLASH
   6 PAGE.TO.FLASH
   STANDARD.MAP
   SAVE
OTHERWISE            \ for V6.xx kernels, store to shadow flash and save pointers
    SAVE.ALL .     \ this takes some time, should print FFFF for success
ENDIFTRUE



More Examples → GPS Wildcard User Guide
GPS Glossary
GPS C Demo

 
This page is about: Forth GPS Data Logger Example, Embedded Device Tracking – Forth example program shows printing GPS data in loop, perfect for instrumentation of a remote device. GPS, Global Positioning System, Embedded location, Altitude, longitude latitude finder
 
 
Navigation