MICILE EZ_GPS Documentation
version: 0.9
A few notes about our documentation:
  • The intentions of this documentation are to keep things simple.
  • Please see the examples at the end of each section for concrete examples of how to use each function.
  • If in doubt how to use a function, experiment!
  • We don't believe in writing more words just to make the documentation look more substantial
  • Quick Reference
    Function List
    Compatible Devices
    GlobalSat BT-308 Bluetooth GPS Receiver

    Any NMEA protocol GPS receiver using bluetooth or serial USB should be compatible.

    * Please contact us for information on adding support for a device.


    GPS Functions
    gps_connect_bluetooth(device_addr, pincode)
    Connects to a bluetooth based GPS receiver. The device_addr should contain the bluetooth address
    of the GPS receiver in a string, i.e. "00:0D:B5:02:E1:18". The pincode should contain the pincode
    in string format to authenticate with the GPS receiver, i.e. "1234"
    gps_connect_serialport(serial_port)
    Connects to serial port based GPS receiver, either through a USB to serial converter or
    a USB based GPS receiver which exposes a serial port. A typical serial_port value would
    be "/dev/ttyUSB0".
    gps_get_elevation()
    Returns the elevation of the last position acquired in meters.
    Returns None if no position has been acquired since the GPS receiver was powered on.
    gps_get_latitude()
    Returns the longitude of the last position acquired.
    Returns None if no position has been acquired since the GPS receiver was powered on.
    gps_get_latitude()
    Returns the latitude of the last position acquired.
    Returns None if no position has been acquired since the GPS receiver was powered on.
    gps_get_satellites_used()
    Returns the number of satellites used to obtain the last acquired position. A minimum of 3 satellites is
    needed to find longitude and latitude. A minimum of 4 satellites is needed to find longitude, latitude
    and elevation.
    Returns None if no position has been acquired since the GPS receiver was powered on.
    gps_get_time()
    Returns a python datetime object containing the time that the last position was acquired.
    The time will be returned in the UTC timezone
    Returns None if no position has been acquired since the GPS receiver was powered on.
    Note: Some GPS receivers return incorrect times
    gps_process()
    Processes GPS messages received by the GPS receiver. This functions should be called before calling any of
    the position functions such as gps_get_elevation, gps_get_latitude, gps_get_longitude,
    gps_get_satellites_used, or gps_get_time
    # --------------------------------------------------
    # gps_demo.py
    # --------------------------------------------------
     
    # import the graphics library and the gps library
    from ez_graphics_09 import *
    from ez_gps_09 import *
    import time
    import urllib2
     
    # clear the screen
    clear_screen('black')
    set_color('white')
    draw_text('Connecting to GPS...'1010)
     
    # pair with the Globalsat BT-308
    # change the bluetooth address and pincode to match that of your GPS receiver
    try:
        gps_connect_bluetooth("00:0D:B5:02:E1:18""2003")
    except Exceptione:
        draw_text("Fatal Error! %s" % e1030)
        exit()
        
    # loop forever showing the current position and a map every 15 seconds
    i = 0
    while True:    
        # let the gps process so it can update its location
        gps_process()
     
        # update some information
        set_color('black')
        fill_rect(00150110)
        set_color('white')
        draw_text("Map Update in %d" % (15 - i)                 , 1010)
        draw_text("Latitude: %s"     % gps_get_latitude()       , 1030)
        draw_text("Longitude: %s"    % gps_get_longitude()      , 1050)
        draw_text("Elevation: %s"    % gps_get_elevation()      , 1070)
        draw_text("Satellites: %s"   % gps_get_satellites_used()1090)
     
        # increment the counter, but keep in the range of 0 to 15
        i = (i + 1) % 15
        # download and show a map from google every 15 seconds
        if i == 0:
            # download a map image from google.  Be courteous and limit to every 15 seconds so we dont 
            # get banned from google.  See https://developers.google.com/maps/documentation/staticmaps 
            # for more information on how to use this feature from google
            map_url = 'http://maps.googleapis.com/maps/api/staticmap?' \
                      'center=%s%%20%s&zoom=19&format=jpg&size=640x480&sensor=true&markers=%s%%2C%s' \
                       % (gps_get_latitude()gps_get_longitude()gps_get_latitude()gps_get_longitude())
            response = urllib2.urlopen(map_url)
        
            # save the jpg of the map from google to a temporary file
            f = open('/mnt/micile_unstable/tmp_map.jpg''wb')
            f.write(response.read())
            f.close()
        
            # draw the image on the lcd screen
            img = load_image('/mnt/micile_unstable/tmp_map.jpg')
            draw_image(img1500)
     
        # sleep
        time.sleep(1)
     

    gps demo