C Language Development Kit/Functions/GpsPower

From OptiWiki

Jump to: navigation, search
Description Powers up or down the GPS communication module inside the OPL9713.
Syntax
void GpsPower(unsigned short onoff);
Arguments
unsigned short onoff
Onoff is a variable that defines whether the GPS hardware should be ON or OFF.
ON Turn power on the GPS module.
OFF Turn power off the GPS module.
Returns The GPS module inside the terminal transmits the NMEA-0183 protocol.
Remarks When GPS power is turned on the power consumption increases, so use the GpsPower( OFF )

when reading from the Gps module is no longer needed.

Example
//
// gps bluetooth server 
// transmits NMEA-0183 protocol from GPS receiver through bluetooth
// This sample can be used as an external GPS receiver.
//
// REMARK: This sample will drain the batteries quickly!!
//
#include <stdio.h>
#include "lib.h"
 
void main( void )
{
    int ch;
 
    //
    // Set local bluetooth name
    //
    SetBltLocalName("SuperGPS");
 
    //
    // Open the bluetooth port as server
    //
    comopen( COM5 );
    for(;;)
    {
        //
        // Wait for an incomming bluetooth connection
        //
        while( blt_is_connected() != TRUE)
        {
            delay( 50 );
            goodreadled( RED, 20);
            idle();
        }
        sound( TSTANDARD, VHIGH, SERROR, SLOW, SMEDIUM, SHIGH, SLOW, SMEDIUM, SHIGH, 0);
        //
        // Turn the GPS module ON
        //
        GpsPower( ON);
        ClearGpsReceiver(); // Clear the receive buffer
        while( blt_is_connected() == TRUE)
        {
            //
            // All all data from the GPS buffer
            //
            if( ( ch = ReadGps()) < 0)
            {
                idle();
                continue;
            }
            putcom( ch );
        }
        //
        // Bluetooth connection lost, turn the GPS module OFF
        //
        GpsPower( OFF );
        sound( TSTANDARD, VHIGH, SERROR, 0);
    }
}


Views
Personal tools