First commit, working build.
This commit is contained in:
500
lib/Adafruit-GPS-Library/Adafruit_GPS.cpp
Executable file
500
lib/Adafruit-GPS-Library/Adafruit_GPS.cpp
Executable file
@@ -0,0 +1,500 @@
|
||||
/***********************************
|
||||
This is our GPS library
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
****************************************/
|
||||
#ifdef __AVR__
|
||||
// Only include software serial on AVR platforms (i.e. not on Due).
|
||||
#include <SoftwareSerial.h>
|
||||
#endif
|
||||
#include <Adafruit_GPS.h>
|
||||
|
||||
// how long are max NMEA lines to parse?
|
||||
#define MAXLINELENGTH 120
|
||||
|
||||
// we double buffer: read one line in and leave one for the main program
|
||||
volatile char line1[MAXLINELENGTH];
|
||||
volatile char line2[MAXLINELENGTH];
|
||||
// our index into filling the current line
|
||||
volatile uint8_t lineidx=0;
|
||||
// pointers to the double buffers
|
||||
volatile char *currentline;
|
||||
volatile char *lastline;
|
||||
volatile boolean recvdflag;
|
||||
volatile boolean inStandbyMode;
|
||||
|
||||
|
||||
boolean Adafruit_GPS::parse(char *nmea) {
|
||||
// do checksum check
|
||||
|
||||
// first look if we even have one
|
||||
if (nmea[strlen(nmea)-4] == '*') {
|
||||
uint16_t sum = parseHex(nmea[strlen(nmea)-3]) * 16;
|
||||
sum += parseHex(nmea[strlen(nmea)-2]);
|
||||
|
||||
// check checksum
|
||||
for (uint8_t i=2; i < (strlen(nmea)-4); i++) {
|
||||
sum ^= nmea[i];
|
||||
}
|
||||
if (sum != 0) {
|
||||
// bad checksum :(
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int32_t degree;
|
||||
long minutes;
|
||||
char degreebuff[10];
|
||||
// look for a few common sentences
|
||||
if (strstr(nmea, "$GPGGA")) {
|
||||
// found GGA
|
||||
char *p = nmea;
|
||||
// get time
|
||||
p = strchr(p, ',')+1;
|
||||
float timef = atof(p);
|
||||
uint32_t time = timef;
|
||||
hour = time / 10000;
|
||||
minute = (time % 10000) / 100;
|
||||
seconds = (time % 100);
|
||||
|
||||
milliseconds = fmod(timef, 1.0) * 1000;
|
||||
|
||||
// parse out latitude
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
strncpy(degreebuff, p, 2);
|
||||
p += 2;
|
||||
degreebuff[2] = '\0';
|
||||
degree = atol(degreebuff) * 10000000;
|
||||
strncpy(degreebuff, p, 2); // minutes
|
||||
p += 3; // skip decimal point
|
||||
strncpy(degreebuff + 2, p, 4);
|
||||
degreebuff[6] = '\0';
|
||||
minutes = 50 * atol(degreebuff) / 3;
|
||||
latitude_fixed = degree + minutes;
|
||||
latitude = degree / 100000 + minutes * 0.000006F;
|
||||
latitudeDegrees = (latitude-100*int(latitude/100))/60.0;
|
||||
latitudeDegrees += int(latitude/100);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
if (p[0] == 'S') latitudeDegrees *= -1.0;
|
||||
if (p[0] == 'N') lat = 'N';
|
||||
else if (p[0] == 'S') lat = 'S';
|
||||
else if (p[0] == ',') lat = 0;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// parse out longitude
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
strncpy(degreebuff, p, 3);
|
||||
p += 3;
|
||||
degreebuff[3] = '\0';
|
||||
degree = atol(degreebuff) * 10000000;
|
||||
strncpy(degreebuff, p, 2); // minutes
|
||||
p += 3; // skip decimal point
|
||||
strncpy(degreebuff + 2, p, 4);
|
||||
degreebuff[6] = '\0';
|
||||
minutes = 50 * atol(degreebuff) / 3;
|
||||
longitude_fixed = degree + minutes;
|
||||
longitude = degree / 100000 + minutes * 0.000006F;
|
||||
longitudeDegrees = (longitude-100*int(longitude/100))/60.0;
|
||||
longitudeDegrees += int(longitude/100);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
if (p[0] == 'W') longitudeDegrees *= -1.0;
|
||||
if (p[0] == 'W') lon = 'W';
|
||||
else if (p[0] == 'E') lon = 'E';
|
||||
else if (p[0] == ',') lon = 0;
|
||||
else return false;
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
fixquality = atoi(p);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
satellites = atoi(p);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
HDOP = atof(p);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
altitude = atof(p);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
geoidheight = atof(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strstr(nmea, "$GPRMC")) {
|
||||
// found RMC
|
||||
char *p = nmea;
|
||||
|
||||
// get time
|
||||
p = strchr(p, ',')+1;
|
||||
float timef = atof(p);
|
||||
uint32_t time = timef;
|
||||
hour = time / 10000;
|
||||
minute = (time % 10000) / 100;
|
||||
seconds = (time % 100);
|
||||
|
||||
milliseconds = fmod(timef, 1.0) * 1000;
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
// Serial.println(p);
|
||||
if (p[0] == 'A')
|
||||
fix = true;
|
||||
else if (p[0] == 'V')
|
||||
fix = false;
|
||||
else
|
||||
return false;
|
||||
|
||||
// parse out latitude
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
strncpy(degreebuff, p, 2);
|
||||
p += 2;
|
||||
degreebuff[2] = '\0';
|
||||
long degree = atol(degreebuff) * 10000000;
|
||||
strncpy(degreebuff, p, 2); // minutes
|
||||
p += 3; // skip decimal point
|
||||
strncpy(degreebuff + 2, p, 4);
|
||||
degreebuff[6] = '\0';
|
||||
long minutes = 50 * atol(degreebuff) / 3;
|
||||
latitude_fixed = degree + minutes;
|
||||
latitude = degree / 100000 + minutes * 0.000006F;
|
||||
latitudeDegrees = (latitude-100*int(latitude/100))/60.0;
|
||||
latitudeDegrees += int(latitude/100);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
if (p[0] == 'S') latitudeDegrees *= -1.0;
|
||||
if (p[0] == 'N') lat = 'N';
|
||||
else if (p[0] == 'S') lat = 'S';
|
||||
else if (p[0] == ',') lat = 0;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// parse out longitude
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
strncpy(degreebuff, p, 3);
|
||||
p += 3;
|
||||
degreebuff[3] = '\0';
|
||||
degree = atol(degreebuff) * 10000000;
|
||||
strncpy(degreebuff, p, 2); // minutes
|
||||
p += 3; // skip decimal point
|
||||
strncpy(degreebuff + 2, p, 4);
|
||||
degreebuff[6] = '\0';
|
||||
minutes = 50 * atol(degreebuff) / 3;
|
||||
longitude_fixed = degree + minutes;
|
||||
longitude = degree / 100000 + minutes * 0.000006F;
|
||||
longitudeDegrees = (longitude-100*int(longitude/100))/60.0;
|
||||
longitudeDegrees += int(longitude/100);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
if (p[0] == 'W') longitudeDegrees *= -1.0;
|
||||
if (p[0] == 'W') lon = 'W';
|
||||
else if (p[0] == 'E') lon = 'E';
|
||||
else if (p[0] == ',') lon = 0;
|
||||
else return false;
|
||||
}
|
||||
// speed
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
speed = atof(p);
|
||||
}
|
||||
|
||||
// angle
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
angle = atof(p);
|
||||
}
|
||||
|
||||
p = strchr(p, ',')+1;
|
||||
if (',' != *p)
|
||||
{
|
||||
uint32_t fulldate = atof(p);
|
||||
day = fulldate / 10000;
|
||||
month = (fulldate % 10000) / 100;
|
||||
year = (fulldate % 100);
|
||||
}
|
||||
// we dont parse the remaining, yet!
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
char Adafruit_GPS::read(void) {
|
||||
char c = 0;
|
||||
|
||||
if (paused) return c;
|
||||
|
||||
#ifdef __AVR__
|
||||
if(gpsSwSerial) {
|
||||
if(!gpsSwSerial->available()) return c;
|
||||
c = gpsSwSerial->read();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if(!gpsHwSerial->available()) return c;
|
||||
c = gpsHwSerial->read();
|
||||
}
|
||||
|
||||
//Serial.print(c);
|
||||
|
||||
// if (c == '$') { //please don't eat the dollar sign - rdl 9/15/14
|
||||
// currentline[lineidx] = 0;
|
||||
// lineidx = 0;
|
||||
// }
|
||||
if (c == '\n') {
|
||||
currentline[lineidx] = 0;
|
||||
|
||||
if (currentline == line1) {
|
||||
currentline = line2;
|
||||
lastline = line1;
|
||||
} else {
|
||||
currentline = line1;
|
||||
lastline = line2;
|
||||
}
|
||||
|
||||
//Serial.println("----");
|
||||
//Serial.println((char *)lastline);
|
||||
//Serial.println("----");
|
||||
lineidx = 0;
|
||||
recvdflag = true;
|
||||
}
|
||||
|
||||
currentline[lineidx++] = c;
|
||||
if (lineidx >= MAXLINELENGTH)
|
||||
lineidx = MAXLINELENGTH-1;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef __AVR__
|
||||
// Constructor when using SoftwareSerial or NewSoftSerial
|
||||
#if ARDUINO >= 100
|
||||
Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser)
|
||||
#else
|
||||
Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser)
|
||||
#endif
|
||||
{
|
||||
common_init(); // Set everything to common state, then...
|
||||
gpsSwSerial = ser; // ...override gpsSwSerial with value passed.
|
||||
}
|
||||
#endif
|
||||
|
||||
// Constructor when using HardwareSerial
|
||||
Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) {
|
||||
common_init(); // Set everything to common state, then...
|
||||
gpsHwSerial = ser; // ...override gpsHwSerial with value passed.
|
||||
}
|
||||
|
||||
// Initialization code used by all constructor types
|
||||
void Adafruit_GPS::common_init(void) {
|
||||
#ifdef __AVR__
|
||||
gpsSwSerial = NULL; // Set both to NULL, then override correct
|
||||
#endif
|
||||
gpsHwSerial = NULL; // port pointer in corresponding constructor
|
||||
recvdflag = false;
|
||||
paused = false;
|
||||
lineidx = 0;
|
||||
currentline = line1;
|
||||
lastline = line2;
|
||||
|
||||
hour = minute = seconds = year = month = day =
|
||||
fixquality = satellites = 0; // uint8_t
|
||||
lat = lon = mag = 0; // char
|
||||
fix = false; // boolean
|
||||
milliseconds = 0; // uint16_t
|
||||
latitude = longitude = geoidheight = altitude =
|
||||
speed = angle = magvariation = HDOP = 0.0; // float
|
||||
}
|
||||
|
||||
void Adafruit_GPS::begin(uint16_t baud)
|
||||
{
|
||||
#ifdef __AVR__
|
||||
if(gpsSwSerial)
|
||||
gpsSwSerial->begin(baud);
|
||||
else
|
||||
gpsHwSerial->begin(baud);
|
||||
#endif
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void Adafruit_GPS::sendCommand(const char *str) {
|
||||
#ifdef __AVR__
|
||||
if(gpsSwSerial)
|
||||
gpsSwSerial->println(str);
|
||||
else
|
||||
#endif
|
||||
gpsHwSerial->println(str);
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::newNMEAreceived(void) {
|
||||
return recvdflag;
|
||||
}
|
||||
|
||||
void Adafruit_GPS::pause(boolean p) {
|
||||
paused = p;
|
||||
}
|
||||
|
||||
char *Adafruit_GPS::lastNMEA(void) {
|
||||
recvdflag = false;
|
||||
return (char *)lastline;
|
||||
}
|
||||
|
||||
// read a Hex value and return the decimal equivalent
|
||||
uint8_t Adafruit_GPS::parseHex(char c) {
|
||||
if (c < '0')
|
||||
return 0;
|
||||
if (c <= '9')
|
||||
return c - '0';
|
||||
if (c < 'A')
|
||||
return 0;
|
||||
if (c <= 'F')
|
||||
return (c - 'A')+10;
|
||||
// if (c > 'F')
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::waitForSentence(const char *wait4me, uint8_t max) {
|
||||
char str[20];
|
||||
|
||||
uint8_t i=0;
|
||||
while (i < max) {
|
||||
if (newNMEAreceived()) {
|
||||
char *nmea = lastNMEA();
|
||||
strncpy(str, nmea, 20);
|
||||
str[19] = 0;
|
||||
i++;
|
||||
|
||||
if (strstr(str, wait4me))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::LOCUS_StartLogger(void) {
|
||||
sendCommand(PMTK_LOCUS_STARTLOG);
|
||||
recvdflag = false;
|
||||
return waitForSentence(PMTK_LOCUS_STARTSTOPACK);
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::LOCUS_StopLogger(void) {
|
||||
sendCommand(PMTK_LOCUS_STOPLOG);
|
||||
recvdflag = false;
|
||||
return waitForSentence(PMTK_LOCUS_STARTSTOPACK);
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::LOCUS_ReadStatus(void) {
|
||||
sendCommand(PMTK_LOCUS_QUERY_STATUS);
|
||||
|
||||
if (! waitForSentence("$PMTKLOG"))
|
||||
return false;
|
||||
|
||||
char *response = lastNMEA();
|
||||
uint16_t parsed[10];
|
||||
uint8_t i;
|
||||
|
||||
for (i=0; i<10; i++) parsed[i] = -1;
|
||||
|
||||
response = strchr(response, ',');
|
||||
for (i=0; i<10; i++) {
|
||||
if (!response || (response[0] == 0) || (response[0] == '*'))
|
||||
break;
|
||||
response++;
|
||||
parsed[i]=0;
|
||||
while ((response[0] != ',') &&
|
||||
(response[0] != '*') && (response[0] != 0)) {
|
||||
parsed[i] *= 10;
|
||||
char c = response[0];
|
||||
if (isDigit(c))
|
||||
parsed[i] += c - '0';
|
||||
else
|
||||
parsed[i] = c;
|
||||
response++;
|
||||
}
|
||||
}
|
||||
LOCUS_serial = parsed[0];
|
||||
LOCUS_type = parsed[1];
|
||||
if (isAlpha(parsed[2])) {
|
||||
parsed[2] = parsed[2] - 'a' + 10;
|
||||
}
|
||||
LOCUS_mode = parsed[2];
|
||||
LOCUS_config = parsed[3];
|
||||
LOCUS_interval = parsed[4];
|
||||
LOCUS_distance = parsed[5];
|
||||
LOCUS_speed = parsed[6];
|
||||
LOCUS_status = !parsed[7];
|
||||
LOCUS_records = parsed[8];
|
||||
LOCUS_percent = parsed[9];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Standby Mode Switches
|
||||
boolean Adafruit_GPS::standby(void) {
|
||||
if (inStandbyMode) {
|
||||
return false; // Returns false if already in standby mode, so that you do not wake it up by sending commands to GPS
|
||||
}
|
||||
else {
|
||||
inStandbyMode = true;
|
||||
sendCommand(PMTK_STANDBY);
|
||||
//return waitForSentence(PMTK_STANDBY_SUCCESS); // don't seem to be fast enough to catch the message, or something else just is not working
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean Adafruit_GPS::wakeup(void) {
|
||||
if (inStandbyMode) {
|
||||
inStandbyMode = false;
|
||||
sendCommand(""); // send byte to wake it up
|
||||
return waitForSentence(PMTK_AWAKE);
|
||||
}
|
||||
else {
|
||||
return false; // Returns false if not in standby mode, nothing to wakeup
|
||||
}
|
||||
}
|
||||
168
lib/Adafruit-GPS-Library/Adafruit_GPS.h
Executable file
168
lib/Adafruit-GPS-Library/Adafruit_GPS.h
Executable file
@@ -0,0 +1,168 @@
|
||||
/***********************************
|
||||
This is the Adafruit GPS library - the ultimate GPS library
|
||||
for the ultimate GPS module!
|
||||
|
||||
Tested and works great with the Adafruit Ultimate GPS module
|
||||
using MTK33x9 chipset
|
||||
------> http://www.adafruit.com/products/746
|
||||
Pick one up today at the Adafruit electronics shop
|
||||
and help support open source hardware & software! -ada
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
****************************************/
|
||||
// Fllybob added lines 34,35 and 40,41 to add 100mHz logging capability
|
||||
|
||||
#ifndef _ADAFRUIT_GPS_H
|
||||
#define _ADAFRUIT_GPS_H
|
||||
|
||||
#ifdef __AVR__
|
||||
#if ARDUINO >= 100
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
#include <NewSoftSerial.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
|
||||
// Note that these only control the rate at which the position is echoed, to actually speed up the
|
||||
// position fix you must also send one of the position fix rate commands below too.
|
||||
#define PMTK_SET_NMEA_UPDATE_100_MILLIHERTZ "$PMTK220,10000*2F" // Once every 10 seconds, 100 millihertz.
|
||||
#define PMTK_SET_NMEA_UPDATE_200_MILLIHERTZ "$PMTK220,5000*1B" // Once every 5 seconds, 200 millihertz.
|
||||
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
|
||||
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
|
||||
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
|
||||
// Position fix update rate commands.
|
||||
#define PMTK_API_SET_FIX_CTL_100_MILLIHERTZ "$PMTK300,10000,0,0,0,0*2C" // Once every 10 seconds, 100 millihertz.
|
||||
#define PMTK_API_SET_FIX_CTL_200_MILLIHERTZ "$PMTK300,5000,0,0,0,0*18" // Once every 5 seconds, 200 millihertz.
|
||||
#define PMTK_API_SET_FIX_CTL_1HZ "$PMTK300,1000,0,0,0,0*1C"
|
||||
#define PMTK_API_SET_FIX_CTL_5HZ "$PMTK300,200,0,0,0,0*2F"
|
||||
// Can't fix position faster than 5 times a second!
|
||||
|
||||
|
||||
#define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
|
||||
#define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
|
||||
|
||||
// turn on only the second sentence (GPRMC)
|
||||
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
|
||||
// turn on GPRMC and GGA
|
||||
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
// turn on ALL THE DATA
|
||||
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
// turn off output
|
||||
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
|
||||
// to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
|
||||
// such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
|
||||
|
||||
#define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
|
||||
#define PMTK_LOCUS_STOPLOG "$PMTK185,1*23"
|
||||
#define PMTK_LOCUS_STARTSTOPACK "$PMTK001,185,3*3C"
|
||||
#define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
|
||||
#define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
|
||||
#define LOCUS_OVERLAP 0
|
||||
#define LOCUS_FULLSTOP 1
|
||||
|
||||
#define PMTK_ENABLE_SBAS "$PMTK313,1*2E"
|
||||
#define PMTK_ENABLE_WAAS "$PMTK301,2*2E"
|
||||
|
||||
// standby command & boot successful message
|
||||
#define PMTK_STANDBY "$PMTK161,0*28"
|
||||
#define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
|
||||
#define PMTK_AWAKE "$PMTK010,002*2D"
|
||||
|
||||
// ask for the release and version
|
||||
#define PMTK_Q_RELEASE "$PMTK605*31"
|
||||
|
||||
// request for updates on antenna status
|
||||
#define PGCMD_ANTENNA "$PGCMD,33,1*6C"
|
||||
#define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
|
||||
|
||||
// how long to wait when we're looking for a response
|
||||
#define MAXWAITSENTENCE 5
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#if defined (__AVR__) && !defined(__AVR_ATmega32U4__)
|
||||
#include "SoftwareSerial.h"
|
||||
#endif
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#include "NewSoftSerial.h"
|
||||
#endif
|
||||
|
||||
|
||||
class Adafruit_GPS {
|
||||
public:
|
||||
void begin(uint16_t baud);
|
||||
|
||||
#ifdef __AVR__
|
||||
#if ARDUINO >= 100
|
||||
Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
|
||||
#else
|
||||
Adafruit_GPS(NewSoftSerial *ser); // Constructor when using NewSoftSerial
|
||||
#endif
|
||||
#endif
|
||||
Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
|
||||
|
||||
char *lastNMEA(void);
|
||||
boolean newNMEAreceived();
|
||||
void common_init(void);
|
||||
|
||||
void sendCommand(const char *);
|
||||
|
||||
void pause(boolean b);
|
||||
|
||||
boolean parseNMEA(char *response);
|
||||
uint8_t parseHex(char c);
|
||||
|
||||
char read(void);
|
||||
boolean parse(char *);
|
||||
void interruptReads(boolean r);
|
||||
|
||||
boolean wakeup(void);
|
||||
boolean standby(void);
|
||||
|
||||
uint8_t hour, minute, seconds, year, month, day;
|
||||
uint16_t milliseconds;
|
||||
// Floating point latitude and longitude value in degrees.
|
||||
float latitude, longitude;
|
||||
// Fixed point latitude and longitude value with degrees stored in units of 1/100000 degrees,
|
||||
// and minutes stored in units of 1/100000 degrees. See pull #13 for more details:
|
||||
// https://github.com/adafruit/Adafruit-GPS-Library/pull/13
|
||||
int32_t latitude_fixed, longitude_fixed;
|
||||
float latitudeDegrees, longitudeDegrees;
|
||||
float geoidheight, altitude;
|
||||
float speed, angle, magvariation, HDOP;
|
||||
char lat, lon, mag;
|
||||
boolean fix;
|
||||
uint8_t fixquality, satellites;
|
||||
|
||||
boolean waitForSentence(const char *wait, uint8_t max = MAXWAITSENTENCE);
|
||||
boolean LOCUS_StartLogger(void);
|
||||
boolean LOCUS_StopLogger(void);
|
||||
boolean LOCUS_ReadStatus(void);
|
||||
|
||||
uint16_t LOCUS_serial, LOCUS_records;
|
||||
uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
|
||||
private:
|
||||
boolean paused;
|
||||
|
||||
uint8_t parseResponse(char *response);
|
||||
#ifdef __AVR__
|
||||
#if ARDUINO >= 100
|
||||
SoftwareSerial *gpsSwSerial;
|
||||
#else
|
||||
NewSoftSerial *gpsSwSerial;
|
||||
#endif
|
||||
#endif
|
||||
HardwareSerial *gpsHwSerial;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
21
lib/Adafruit-GPS-Library/README.txt
Normal file
21
lib/Adafruit-GPS-Library/README.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
This is the Adafruit GPS library - the ultimate GPS library
|
||||
for the ultimate GPS module!
|
||||
|
||||
Tested and works great with the Adafruit Ultimate GPS module
|
||||
using MTK33x9 chipset
|
||||
------> http://www.adafruit.com/products/746
|
||||
|
||||
These modules use TTL serial to communicate, 2 pins are required to
|
||||
interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
|
||||
To download. click the "Download ZIP" at the right side, extract the archive and rename the uncompressed folder Adafruit_GPS. Check that the Adafruit_GPS folder contains Adafruit_GPS.cpp and Adafruit_GPS.h
|
||||
|
||||
Place the Adafruit_GPS library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
||||
11
lib/Adafruit-GPS-Library/examples/blank/blank.pde
Normal file
11
lib/Adafruit-GPS-Library/examples/blank/blank.pde
Normal file
@@ -0,0 +1,11 @@
|
||||
// this sketch will allow you to bypass the Atmega chip
|
||||
// and connect the GPS sensor directly to the USB/Serial
|
||||
// chip converter.
|
||||
|
||||
// Connect VIN to +5V
|
||||
// Connect GND to Ground
|
||||
// Connect GPS RX (data into GPS) to Digital 0
|
||||
// Connect GPS TX (data out from GPS) to Digital 1
|
||||
|
||||
void setup() {}
|
||||
void loop() {}
|
||||
161
lib/Adafruit-GPS-Library/examples/due_parsing/due_parsing.ino
Normal file
161
lib/Adafruit-GPS-Library/examples/due_parsing/due_parsing.ino
Normal file
@@ -0,0 +1,161 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
|
||||
// This sketch is ONLY for the Arduino Due!
|
||||
// You should make the following connections with the Due and GPS module:
|
||||
// GPS power pin to Arduino Due 3.3V output.
|
||||
// GPS ground pin to Arduino Due ground.
|
||||
// For hardware serial 1 (recommended):
|
||||
// GPS TX to Arduino Due Serial1 RX pin 19
|
||||
// GPS RX to Arduino Due Serial1 TX pin 18
|
||||
#define mySerial Serial1
|
||||
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences.
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS library basic test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
|
||||
GPS.begin(9600);
|
||||
mySerial.begin(9600);
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
|
||||
// the parser doesn't care about other sentences at this time
|
||||
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
|
||||
// For the parsing code to work nicely and have time to sort thru the data, and
|
||||
// print it out we don't suggest using anything higher than 1 Hz
|
||||
|
||||
// Request updates on antenna status, comment out to keep quiet
|
||||
GPS.sendCommand(PGCMD_ANTENNA);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
|
||||
#ifdef __arm__
|
||||
usingInterrupt = false; //NOTE - we don't want to use interrupts on the Due
|
||||
#else
|
||||
useInterrupt(true);
|
||||
#endif
|
||||
|
||||
delay(1000);
|
||||
// Ask for firmware version
|
||||
mySerial.println(PMTK_Q_RELEASE);
|
||||
}
|
||||
|
||||
#ifdef __AVR__
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
#ifdef UDR0
|
||||
if (GPSECHO)
|
||||
if (c) UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
#endif //#ifdef__AVR__
|
||||
|
||||
uint32_t timer = millis();
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// in case you are not using the interrupt above, you'll
|
||||
// need to 'hand query' the GPS, not suggested :(
|
||||
if (! usingInterrupt) {
|
||||
// read data from the GPS in the 'main loop'
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
}
|
||||
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
|
||||
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
|
||||
|
||||
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
}
|
||||
|
||||
// if millis() or timer wraps around, we'll just reset it
|
||||
if (timer > millis()) timer = millis();
|
||||
|
||||
// approximately every 2 seconds or so, print out the current stats
|
||||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
|
||||
Serial.print("\nTime: ");
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||
Serial.println(GPS.milliseconds);
|
||||
Serial.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
Serial.print(GPS.month, DEC); Serial.print("/20");
|
||||
Serial.println(GPS.year, DEC);
|
||||
Serial.print("Fix: "); Serial.print((int)GPS.fix);
|
||||
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
|
||||
if (GPS.fix) {
|
||||
Serial.print("Location: ");
|
||||
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
|
||||
Serial.print(", ");
|
||||
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
|
||||
|
||||
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
|
||||
Serial.print("Angle: "); Serial.println(GPS.angle);
|
||||
Serial.print("Altitude: "); Serial.println(GPS.altitude);
|
||||
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <SoftwareSerial.h>
|
||||
#include <avr/sleep.h>
|
||||
#endif
|
||||
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
|
||||
|
||||
// Ladyada's logger modified by Bill Greiman to use the SdFat library
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS Shield
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#ifdef __AVR__
|
||||
SoftwareSerial mySerial(8, 7);
|
||||
#else
|
||||
#define mySerial Serial1
|
||||
#endif
|
||||
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
/* set to true to only log to SD when GPS has a fix, for debugging, keep it false */
|
||||
#define LOG_FIXONLY false
|
||||
|
||||
// Set the pins used
|
||||
#define chipSelect 10
|
||||
#define ledPin 13
|
||||
|
||||
File logfile;
|
||||
|
||||
// read a Hex value and return the decimal equivalent
|
||||
uint8_t parseHex(char c) {
|
||||
if (c < '0')
|
||||
return 0;
|
||||
if (c <= '9')
|
||||
return c - '0';
|
||||
if (c < 'A')
|
||||
return 0;
|
||||
if (c <= 'F')
|
||||
return (c - 'A')+10;
|
||||
}
|
||||
|
||||
// blink out an error code
|
||||
void error(uint8_t errno) {
|
||||
/*
|
||||
if (SD.errorCode()) {
|
||||
putstring("SD error: ");
|
||||
Serial.print(card.errorCode(), HEX);
|
||||
Serial.print(',');
|
||||
Serial.println(card.errorData(), HEX);
|
||||
}
|
||||
*/
|
||||
while(1) {
|
||||
uint8_t i;
|
||||
for (i=0; i<errno; i++) {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(100);
|
||||
}
|
||||
for (i=errno; i<10; i++) {
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// for Leonardos, if you want to debug SD issues, uncomment this line
|
||||
// to see serial output
|
||||
//while (!Serial);
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("\r\nUltimate GPSlogger Shield");
|
||||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
// make sure that the default chip select pin is set to
|
||||
// output, even if you don't use it:
|
||||
pinMode(10, OUTPUT);
|
||||
|
||||
// see if the card is present and can be initialized:
|
||||
if (!SD.begin(chipSelect, 11, 12, 13)) {
|
||||
//if (!SD.begin(chipSelect)) { // if you're using an UNO, you can use this line instead
|
||||
Serial.println("Card init. failed!");
|
||||
error(2);
|
||||
}
|
||||
char filename[15];
|
||||
strcpy(filename, "GPSLOG00.TXT");
|
||||
for (uint8_t i = 0; i < 100; i++) {
|
||||
filename[6] = '0' + i/10;
|
||||
filename[7] = '0' + i%10;
|
||||
// create if does not exist, do not open existing, write, sync after write
|
||||
if (! SD.exists(filename)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
logfile = SD.open(filename, FILE_WRITE);
|
||||
if( ! logfile ) {
|
||||
Serial.print("Couldnt create "); Serial.println(filename);
|
||||
error(3);
|
||||
}
|
||||
Serial.print("Writing to "); Serial.println(filename);
|
||||
|
||||
// connect to the GPS at the desired rate
|
||||
GPS.begin(9600);
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For logging data, we don't suggest using anything but either RMC only or RMC+GGA
|
||||
// to keep the log files at a reasonable size
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 or 5 Hz update rate
|
||||
|
||||
// Turn off updates on antenna status, if the firmware permits it
|
||||
GPS.sendCommand(PGCMD_NOANTENNA);
|
||||
|
||||
Serial.println("Ready!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
char c = GPS.read();
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trying to print out data
|
||||
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
|
||||
|
||||
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
|
||||
// Sentence parsed!
|
||||
Serial.println("OK");
|
||||
if (LOG_FIXONLY && !GPS.fix) {
|
||||
Serial.print("No Fix");
|
||||
return;
|
||||
}
|
||||
|
||||
// Rad. lets log it!
|
||||
Serial.println("Log");
|
||||
|
||||
char *stringptr = GPS.lastNMEA();
|
||||
uint8_t stringsize = strlen(stringptr);
|
||||
if (stringsize != logfile.write((uint8_t *)stringptr, stringsize)) //write the string to the SD file
|
||||
error(4);
|
||||
if (strstr(stringptr, "RMC")) logfile.flush();
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End code */
|
||||
125
lib/Adafruit-GPS-Library/examples/echo/echo.pde
Normal file
125
lib/Adafruit-GPS-Library/examples/echo/echo.pde
Normal file
@@ -0,0 +1,125 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code just echos whatever is coming from the GPS unit to the
|
||||
// serial monitor, handy for debugging!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#if ARDUINO >= 100
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
// Older Arduino IDE requires NewSoftSerial, download from:
|
||||
// http://arduiniana.org/libraries/newsoftserial/
|
||||
// #include <NewSoftSerial.h>
|
||||
// DO NOT install NewSoftSerial if using Arduino 1.0 or later!
|
||||
#endif
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
#if ARDUINO >= 100
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
#else
|
||||
NewSoftSerial mySerial(3, 2);
|
||||
#endif
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
// If using hardware serial (e.g. Arduino Mega), comment
|
||||
// out the above six lines and enable this line instead:
|
||||
//Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS library basic test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data for high update rates!
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA);
|
||||
|
||||
// Set the update rate
|
||||
// Note you must send both commands below to change both the output rate (how often the position
|
||||
// is written to the serial line), and the position fix rate.
|
||||
// 1 Hz update rate
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
//GPS.sendCommand(PMTK_API_SET_FIX_CTL_1HZ);
|
||||
// 5 Hz update rate- for 9600 baud you'll have to set the output to RMC or RMCGGA only (see above)
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
|
||||
GPS.sendCommand(PMTK_API_SET_FIX_CTL_5HZ);
|
||||
// 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
|
||||
// Note the position can only be updated at most 5 times a second so it will lag behind serial output.
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);
|
||||
//GPS.sendCommand(PMTK_API_SET_FIX_CTL_5HZ);
|
||||
|
||||
// Request updates on antenna status, comment out to keep quiet
|
||||
GPS.sendCommand(PGCMD_ANTENNA);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// do nothing! all reading and printing is done in the interrupt
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial);
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging dump test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||
|
||||
while (Serial1.available())
|
||||
Serial1.read();
|
||||
|
||||
delay(1000);
|
||||
GPS.sendCommand("$PMTK622,1*29");
|
||||
Serial.println("----------------------------------------------------");
|
||||
}
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
if (Serial1.available()) {
|
||||
char c = Serial1.read();
|
||||
if (c) Serial.print(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
//while (!Serial);
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
// Default is RMC + GGA
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// Default is 1 Hz update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
delay(500);
|
||||
while (true) {
|
||||
Serial.print("Starting logging....");
|
||||
if (GPS.LOCUS_StartLogger()) {
|
||||
Serial.println(" STARTED!");
|
||||
break;
|
||||
} else {
|
||||
Serial.println(" no response :(");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
pinMode(7, OUTPUT);
|
||||
digitalWrite(7, HIGH);
|
||||
delay(200);
|
||||
digitalWrite(7, LOW);
|
||||
delay(200);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// test a passthru between USB and hardware serial
|
||||
|
||||
void setup() {
|
||||
while (!Serial);
|
||||
Serial.begin(9600);
|
||||
Serial1.begin(9600);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
char c = Serial.read();
|
||||
Serial1.write(c);
|
||||
}
|
||||
if (Serial1.available()) {
|
||||
char c = Serial1.read();
|
||||
Serial.write(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// Test code for Adafruit Flora GPS modules
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Flora GPS module
|
||||
// ------> http://adafruit.com/products/1059
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS library basic test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
|
||||
GPS.begin(9600);
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
|
||||
// the parser doesn't care about other sentences at this time
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
|
||||
// For the parsing code to work nicely and have time to sort thru the data, and
|
||||
// print it out we don't suggest using anything higher than 1 Hz
|
||||
|
||||
// Request updates on antenna status, comment out to keep quiet
|
||||
GPS.sendCommand(PGCMD_ANTENNA);
|
||||
|
||||
delay(1000);
|
||||
// Ask for firmware version
|
||||
Serial1.println(PMTK_Q_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t timer = millis();
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// read data from the GPS in the 'main loop'
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
|
||||
Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
|
||||
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
}
|
||||
// if millis() or timer wraps around, we'll just reset it
|
||||
if (timer > millis()) timer = millis();
|
||||
|
||||
// approximately every 2 seconds or so, print out the current stats
|
||||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
Serial.print("\nTime: ");
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||
Serial.println(GPS.milliseconds);
|
||||
Serial.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
Serial.print(GPS.month, DEC); Serial.print("/20");
|
||||
Serial.println(GPS.year, DEC);
|
||||
Serial.print("Fix: "); Serial.print((int)GPS.fix);
|
||||
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
|
||||
if (GPS.fix) {
|
||||
Serial.print("Location: ");
|
||||
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
|
||||
Serial.print(", ");
|
||||
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
|
||||
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
|
||||
Serial.print("Angle: "); Serial.println(GPS.angle);
|
||||
Serial.print("Altitude: "); Serial.println(GPS.altitude);
|
||||
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
lib/Adafruit-GPS-Library/examples/leo_echo/leo_echo.ino
Normal file
76
lib/Adafruit-GPS-Library/examples/leo_echo/leo_echo.ino
Normal file
@@ -0,0 +1,76 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code just echos whatever is coming from the GPS unit to the
|
||||
// serial monitor, handy for debugging!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
SoftwareSerial mySerial(8, 7);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
//HardwareSerial mySerial = Serial1;
|
||||
|
||||
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
|
||||
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
|
||||
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
|
||||
|
||||
// turn on only the second sentence (GPRMC)
|
||||
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
|
||||
// turn on GPRMC and GGA
|
||||
#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
// turn on ALL THE DATA
|
||||
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
// turn off output
|
||||
#define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
|
||||
|
||||
#define PMTK_Q_RELEASE "$PMTK605*31"
|
||||
|
||||
void setup() {
|
||||
while (!Serial); // wait for leo to be ready
|
||||
|
||||
Serial.begin(57600); // this baud rate doesn't actually matter!
|
||||
mySerial.begin(9600);
|
||||
delay(2000);
|
||||
Serial.println("Get version!");
|
||||
mySerial.println(PMTK_Q_RELEASE);
|
||||
|
||||
// you can send various commands to get it started
|
||||
//mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);
|
||||
|
||||
mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
char c = Serial.read();
|
||||
Serial.write(c);
|
||||
mySerial.write(c);
|
||||
}
|
||||
if (mySerial.available()) {
|
||||
char c = mySerial.read();
|
||||
Serial.write(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
//SoftwareSerial mySerial(8, 7);
|
||||
//Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
#define mySerial Serial1
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // Leonardo will wait till serial connects
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||
|
||||
while (mySerial.available())
|
||||
mySerial.read();
|
||||
|
||||
delay(1000);
|
||||
GPS.sendCommand("$PMTK622,1*29");
|
||||
Serial.println("----------------------------------------------------");
|
||||
}
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||
if (mySerial.available()) {
|
||||
char c = mySerial.read();
|
||||
if (c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
#else
|
||||
Serial.print(c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code erases the LOCUS built-in datalogger storage
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
//SoftwareSerial mySerial(8, 7);
|
||||
//Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
HardwareSerial mySerial = Serial1;
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial) ; //wait for serial port on Leonardo
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS erase FLASH!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK
|
||||
GPS.begin(9600);
|
||||
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
|
||||
Serial.print("Are you sure you want to do this? [Y/N]: ");
|
||||
while (Serial.read() != 'Y') delay(10);
|
||||
Serial.println("\nERASING! UNPLUG YOUR ARDUINO WITHIN 5 SECONDS IF YOU DIDNT MEAN TO!");
|
||||
delay(5000);
|
||||
GPS.sendCommand(PMTK_LOCUS_ERASE_FLASH);
|
||||
Serial.println("Erased");
|
||||
}
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
if (mySerial.available()) {
|
||||
Serial.write(mySerial.read());
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO && c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#else
|
||||
Serial.write(c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
//SoftwareSerial mySerial(8, 7);
|
||||
//Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
HardwareSerial mySerial = Serial1;
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
delay(1000);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
// Default is RMC + GGA
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// Default is 1 Hz update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
delay(500);
|
||||
Serial.print("\nSTARTING LOGGING....");
|
||||
if (GPS.LOCUS_StartLogger())
|
||||
Serial.println(" STARTED!");
|
||||
else
|
||||
Serial.println(" no response :(");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// do nothing! all reading and printing is done in the interrupt
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO && c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#else
|
||||
Serial.write(c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
//SoftwareSerial mySerial(8, 7);
|
||||
//Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
HardwareSerial mySerial = Serial1;
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
// Default is RMC + GGA
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// Default is 1 Hz update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
while (true) {
|
||||
Serial.print("Starting logging....");
|
||||
if (GPS.LOCUS_StartLogger()) {
|
||||
Serial.println(" STARTED!");
|
||||
break;
|
||||
} else {
|
||||
Serial.println(" no response :(");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t updateTime = 1000;
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if ((c) && (GPSECHO))
|
||||
Serial.write(c);
|
||||
|
||||
if (millis() > updateTime)
|
||||
{
|
||||
updateTime = millis() + 1000;
|
||||
if (GPS.LOCUS_ReadStatus()) {
|
||||
Serial.print("\n\nLog #");
|
||||
Serial.print(GPS.LOCUS_serial, DEC);
|
||||
if (GPS.LOCUS_type == LOCUS_OVERLAP)
|
||||
Serial.print(", Overlap, ");
|
||||
else if (GPS.LOCUS_type == LOCUS_FULLSTOP)
|
||||
Serial.print(", Full Stop, Logging");
|
||||
|
||||
if (GPS.LOCUS_mode & 0x1) Serial.print(" AlwaysLocate");
|
||||
if (GPS.LOCUS_mode & 0x2) Serial.print(" FixOnly");
|
||||
if (GPS.LOCUS_mode & 0x4) Serial.print(" Normal");
|
||||
if (GPS.LOCUS_mode & 0x8) Serial.print(" Interval");
|
||||
if (GPS.LOCUS_mode & 0x10) Serial.print(" Distance");
|
||||
if (GPS.LOCUS_mode & 0x20) Serial.print(" Speed");
|
||||
|
||||
Serial.print(", Content "); Serial.print((int)GPS.LOCUS_config);
|
||||
Serial.print(", Interval "); Serial.print((int)GPS.LOCUS_interval);
|
||||
Serial.print(" sec, Distance "); Serial.print((int)GPS.LOCUS_distance);
|
||||
Serial.print(" m, Speed "); Serial.print((int)GPS.LOCUS_speed);
|
||||
Serial.print(" m/s, Status ");
|
||||
if (GPS.LOCUS_status)
|
||||
Serial.print("LOGGING, ");
|
||||
else
|
||||
Serial.print("OFF, ");
|
||||
Serial.print((int)GPS.LOCUS_records); Serial.print(" Records, ");
|
||||
Serial.print((int)GPS.LOCUS_percent); Serial.print("% Used ");
|
||||
|
||||
}//if (GPS.LOCUS_ReadStatus())
|
||||
}//if (millis() > updateTime)
|
||||
}//loop
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO && c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
123
lib/Adafruit-GPS-Library/examples/leo_parsing/leo_parsing.ino
Normal file
123
lib/Adafruit-GPS-Library/examples/leo_parsing/leo_parsing.ino
Normal file
@@ -0,0 +1,123 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
//This code is intended for use with Arduino Leonardo and other ATmega32U4-based Arduinos
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 8
|
||||
// Connect the GPS RX (receive) pin to Digital 7
|
||||
// If using hardware serial:
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1 (Digital 0)
|
||||
// Connect the GPS RX (receive) pin to matching TX1 (Digital 1)
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
//SoftwareSerial mySerial(8, 7);
|
||||
//Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// If using hardware serial, comment
|
||||
// out the above two lines and enable these two lines instead:
|
||||
Adafruit_GPS GPS(&Serial1);
|
||||
HardwareSerial mySerial = Serial1;
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
delay(5000);
|
||||
Serial.println("Adafruit GPS library basic test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
|
||||
// the parser doesn't care about other sentences at this time
|
||||
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
|
||||
// For the parsing code to work nicely and have time to sort thru the data, and
|
||||
// print it out we don't suggest using anything higher than 1 Hz
|
||||
|
||||
// Request updates on antenna status, comment out to keep quiet
|
||||
GPS.sendCommand(PGCMD_ANTENNA);
|
||||
|
||||
delay(1000);
|
||||
// Ask for firmware version
|
||||
mySerial.println(PMTK_Q_RELEASE);
|
||||
}
|
||||
|
||||
uint32_t timer = millis();
|
||||
void loop() // run over and over again
|
||||
{
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if ((c) && (GPSECHO))
|
||||
Serial.write(c);
|
||||
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
|
||||
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
|
||||
|
||||
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
}
|
||||
|
||||
// if millis() or timer wraps around, we'll just reset it
|
||||
if (timer > millis()) timer = millis();
|
||||
|
||||
// approximately every 2 seconds or so, print out the current stats
|
||||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
|
||||
Serial.print("\nTime: ");
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||
Serial.println(GPS.milliseconds);
|
||||
Serial.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
Serial.print(GPS.month, DEC); Serial.print("/20");
|
||||
Serial.println(GPS.year, DEC);
|
||||
Serial.print("Fix: "); Serial.print((int)GPS.fix);
|
||||
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
|
||||
if (GPS.fix) {
|
||||
Serial.print("Location: ");
|
||||
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
|
||||
Serial.print(", ");
|
||||
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
|
||||
|
||||
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
|
||||
Serial.print("Angle: "); Serial.println(GPS.angle);
|
||||
Serial.print("Altitude: "); Serial.println(GPS.altitude);
|
||||
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#if ARDUINO >= 100
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
// Older Arduino IDE requires NewSoftSerial, download from:
|
||||
// http://arduiniana.org/libraries/newsoftserial/
|
||||
// #include <NewSoftSerial.h>
|
||||
// DO NOT install NewSoftSerial if using Arduino 1.0 or later!
|
||||
#endif
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
#if ARDUINO >= 100
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
#else
|
||||
NewSoftSerial mySerial(3, 2);
|
||||
#endif
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
// If using hardware serial (e.g. Arduino Mega), comment
|
||||
// out the above six lines and enable this line instead:
|
||||
//Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // Leonardo will wait till serial connects
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||
|
||||
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||
while (mySerial.available())
|
||||
mySerial.read();
|
||||
|
||||
delay(1000);
|
||||
GPS.sendCommand("$PMTK622,1*29");
|
||||
Serial.println("----------------------------------------------------");
|
||||
}
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||
if (mySerial.available()) {
|
||||
char c = mySerial.read();
|
||||
if (c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
#else
|
||||
Serial.print(c);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
115
lib/Adafruit-GPS-Library/examples/locus_erase/locus_erase.pde
Normal file
115
lib/Adafruit-GPS-Library/examples/locus_erase/locus_erase.pde
Normal file
@@ -0,0 +1,115 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code erases the LOCUS built-in datalogger storage
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#if ARDUINO >= 100
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
// Older Arduino IDE requires NewSoftSerial, download from:
|
||||
// http://arduiniana.org/libraries/newsoftserial/
|
||||
// #include <NewSoftwareSerial.h>
|
||||
// DO NOT install NewSoftSerial if using Arduino 1.0 or later!
|
||||
#endif
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
#if ARDUINO >= 100
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
#else
|
||||
NewSoftSerial mySerial(3, 2);
|
||||
#endif
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
// If using hardware serial (e.g. Arduino Mega), comment
|
||||
// out the above six lines and enable this line instead:
|
||||
//Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS erase FLASH!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK
|
||||
GPS.begin(9600);
|
||||
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
|
||||
Serial.print("Are you sure you want to do this? [Y/N]: ");
|
||||
while (Serial.read() != 'Y') delay(10);
|
||||
Serial.println("\nERASING! UNPLUG YOUR ARDUINO WITHIN 5 SECONDS IF YOU DIDNT MEAN TO!");
|
||||
delay(5000);
|
||||
GPS.sendCommand(PMTK_LOCUS_ERASE_FLASH);
|
||||
Serial.println("Erased");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||
if (mySerial.available()) {
|
||||
char c = mySerial.read();
|
||||
if (c) UDR0 = c;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
121
lib/Adafruit-GPS-Library/examples/locus_start/locus_start.pde
Normal file
121
lib/Adafruit-GPS-Library/examples/locus_start/locus_start.pde
Normal file
@@ -0,0 +1,121 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#if ARDUINO >= 100
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
// Older Arduino IDE requires NewSoftSerial, download from:
|
||||
// http://arduiniana.org/libraries/newsoftserial/
|
||||
// #include <NewSoftSerial.h>
|
||||
// DO NOT install NewSoftSerial if using Arduino 1.0 or later!
|
||||
#endif
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
#if ARDUINO >= 100
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
#else
|
||||
NewSoftSerial mySerial(3, 2);
|
||||
#endif
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
// If using hardware serial (e.g. Arduino Mega), comment
|
||||
// out the above six lines and enable this line instead:
|
||||
//Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
// Default is RMC + GGA
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// Default is 1 Hz update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
delay(500);
|
||||
Serial.print("\nSTARTING LOGGING....");
|
||||
if (GPS.LOCUS_StartLogger())
|
||||
Serial.println(" STARTED!");
|
||||
else
|
||||
Serial.println(" no response :(");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// do nothing! all reading and printing is done in the interrupt
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO && c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
144
lib/Adafruit-GPS-Library/examples/locus_status/locus_status.pde
Normal file
144
lib/Adafruit-GPS-Library/examples/locus_status/locus_status.pde
Normal file
@@ -0,0 +1,144 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code turns on the LOCUS built-in datalogger. The datalogger
|
||||
// turns off when power is lost, so you MUST turn it on every time
|
||||
// you want to use it!
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If using software serial, keep these lines enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
// If using hardware serial (e.g. Arduino Mega), comment
|
||||
// out the above six lines and enable this line instead:
|
||||
//Adafruit_GPS GPS(&Serial1);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enuf and
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS logging start test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// You can adjust which sentences to have the module emit, below
|
||||
// Default is RMC + GGA
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// Default is 1 Hz update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
while (true) {
|
||||
Serial.print("Starting logging....");
|
||||
if (GPS.LOCUS_StartLogger()) {
|
||||
Serial.println(" STARTED!");
|
||||
break;
|
||||
} else {
|
||||
Serial.println(" no response :(");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() // run over and over again
|
||||
{
|
||||
delay(1000);
|
||||
|
||||
if (GPS.LOCUS_ReadStatus()) {
|
||||
Serial.print("\n\nLog #");
|
||||
Serial.print(GPS.LOCUS_serial, DEC);
|
||||
if (GPS.LOCUS_type == LOCUS_OVERLAP)
|
||||
Serial.print(", Overlap, ");
|
||||
else if (GPS.LOCUS_type == LOCUS_FULLSTOP)
|
||||
Serial.print(", Full Stop, Logging");
|
||||
|
||||
if (GPS.LOCUS_mode & 0x1) Serial.print(" AlwaysLocate");
|
||||
if (GPS.LOCUS_mode & 0x2) Serial.print(" FixOnly");
|
||||
if (GPS.LOCUS_mode & 0x4) Serial.print(" Normal");
|
||||
if (GPS.LOCUS_mode & 0x8) Serial.print(" Interval");
|
||||
if (GPS.LOCUS_mode & 0x10) Serial.print(" Distance");
|
||||
if (GPS.LOCUS_mode & 0x20) Serial.print(" Speed");
|
||||
|
||||
Serial.print(", Content "); Serial.print((int)GPS.LOCUS_config);
|
||||
Serial.print(", Interval "); Serial.print((int)GPS.LOCUS_interval);
|
||||
Serial.print(" sec, Distance "); Serial.print((int)GPS.LOCUS_distance);
|
||||
Serial.print(" m, Speed "); Serial.print((int)GPS.LOCUS_speed);
|
||||
Serial.print(" m/s, Status ");
|
||||
if (GPS.LOCUS_status)
|
||||
Serial.print("LOGGING, ");
|
||||
else
|
||||
Serial.print("OFF, ");
|
||||
Serial.print((int)GPS.LOCUS_records); Serial.print(" Records, ");
|
||||
Serial.print((int)GPS.LOCUS_percent); Serial.print("% Used ");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO && c) {
|
||||
#ifdef UDR0
|
||||
UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
175
lib/Adafruit-GPS-Library/examples/parsing/parsing.pde
Normal file
175
lib/Adafruit-GPS-Library/examples/parsing/parsing.pde
Normal file
@@ -0,0 +1,175 @@
|
||||
// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS module
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/746
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// If you're using a GPS module:
|
||||
// Connect the GPS Power pin to 5V
|
||||
// Connect the GPS Ground pin to ground
|
||||
// If using software serial (sketch example default):
|
||||
// Connect the GPS TX (transmit) pin to Digital 3
|
||||
// Connect the GPS RX (receive) pin to Digital 2
|
||||
// If using hardware serial (e.g. Arduino Mega):
|
||||
// Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3
|
||||
// Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3
|
||||
|
||||
// If you're using the Adafruit GPS shield, change
|
||||
// SoftwareSerial mySerial(3, 2); -> SoftwareSerial mySerial(8, 7);
|
||||
// and make sure the switch is set to SoftSerial
|
||||
|
||||
// If using software serial, keep this line enabled
|
||||
// (you can change the pin numbers to match your wiring):
|
||||
SoftwareSerial mySerial(3, 2);
|
||||
|
||||
// If using hardware serial (e.g. Arduino Mega), comment out the
|
||||
// above SoftwareSerial line, and enable this line instead
|
||||
// (you can change the Serial number to match your wiring):
|
||||
|
||||
//HardwareSerial mySerial = Serial1;
|
||||
|
||||
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences.
|
||||
#define GPSECHO true
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("Adafruit GPS library basic test!");
|
||||
|
||||
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
|
||||
GPS.begin(9600);
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
|
||||
// the parser doesn't care about other sentences at this time
|
||||
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
|
||||
// For the parsing code to work nicely and have time to sort thru the data, and
|
||||
// print it out we don't suggest using anything higher than 1 Hz
|
||||
|
||||
// Request updates on antenna status, comment out to keep quiet
|
||||
GPS.sendCommand(PGCMD_ANTENNA);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
delay(1000);
|
||||
// Ask for firmware version
|
||||
mySerial.println(PMTK_Q_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
#ifdef UDR0
|
||||
if (GPSECHO)
|
||||
if (c) UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t timer = millis();
|
||||
void loop() // run over and over again
|
||||
{
|
||||
// in case you are not using the interrupt above, you'll
|
||||
// need to 'hand query' the GPS, not suggested :(
|
||||
if (! usingInterrupt) {
|
||||
// read data from the GPS in the 'main loop'
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
}
|
||||
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
|
||||
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
|
||||
|
||||
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
}
|
||||
|
||||
// if millis() or timer wraps around, we'll just reset it
|
||||
if (timer > millis()) timer = millis();
|
||||
|
||||
// approximately every 2 seconds or so, print out the current stats
|
||||
if (millis() - timer > 2000) {
|
||||
timer = millis(); // reset the timer
|
||||
|
||||
Serial.print("\nTime: ");
|
||||
Serial.print(GPS.hour, DEC); Serial.print(':');
|
||||
Serial.print(GPS.minute, DEC); Serial.print(':');
|
||||
Serial.print(GPS.seconds, DEC); Serial.print('.');
|
||||
Serial.println(GPS.milliseconds);
|
||||
Serial.print("Date: ");
|
||||
Serial.print(GPS.day, DEC); Serial.print('/');
|
||||
Serial.print(GPS.month, DEC); Serial.print("/20");
|
||||
Serial.println(GPS.year, DEC);
|
||||
Serial.print("Fix: "); Serial.print((int)GPS.fix);
|
||||
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
|
||||
if (GPS.fix) {
|
||||
Serial.print("Location: ");
|
||||
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
|
||||
Serial.print(", ");
|
||||
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
|
||||
Serial.print("Location (in degrees, works with Google Maps): ");
|
||||
Serial.print(GPS.latitudeDegrees, 4);
|
||||
Serial.print(", ");
|
||||
Serial.println(GPS.longitudeDegrees, 4);
|
||||
|
||||
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
|
||||
Serial.print("Angle: "); Serial.println(GPS.angle);
|
||||
Serial.print("Altitude: "); Serial.println(GPS.altitude);
|
||||
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
|
||||
}
|
||||
}
|
||||
}
|
||||
211
lib/Adafruit-GPS-Library/examples/shield_sdlog/shield_sdlog.ino
Normal file
211
lib/Adafruit-GPS-Library/examples/shield_sdlog/shield_sdlog.ino
Normal file
@@ -0,0 +1,211 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
#include <SD.h>
|
||||
#include <avr/sleep.h>
|
||||
|
||||
// Ladyada's logger modified by Bill Greiman to use the SdFat library
|
||||
//
|
||||
// This code shows how to listen to the GPS module in an interrupt
|
||||
// which allows the program to have more 'freedom' - just parse
|
||||
// when a new NMEA sentence is available! Then access data when
|
||||
// desired.
|
||||
//
|
||||
// Tested and works great with the Adafruit Ultimate GPS Shield
|
||||
// using MTK33x9 chipset
|
||||
// ------> http://www.adafruit.com/products/
|
||||
// Pick one up today at the Adafruit electronics shop
|
||||
// and help support open source hardware & software! -ada
|
||||
// Fllybob added 10 sec logging option
|
||||
SoftwareSerial mySerial(8, 7);
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
|
||||
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||
#define GPSECHO true
|
||||
/* set to true to only log to SD when GPS has a fix, for debugging, keep it false */
|
||||
#define LOG_FIXONLY false
|
||||
|
||||
// this keeps track of whether we're using the interrupt
|
||||
// off by default!
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
|
||||
|
||||
// Set the pins used
|
||||
#define chipSelect 10
|
||||
#define ledPin 13
|
||||
|
||||
File logfile;
|
||||
|
||||
// read a Hex value and return the decimal equivalent
|
||||
uint8_t parseHex(char c) {
|
||||
if (c < '0')
|
||||
return 0;
|
||||
if (c <= '9')
|
||||
return c - '0';
|
||||
if (c < 'A')
|
||||
return 0;
|
||||
if (c <= 'F')
|
||||
return (c - 'A')+10;
|
||||
}
|
||||
|
||||
// blink out an error code
|
||||
void error(uint8_t errno) {
|
||||
/*
|
||||
if (SD.errorCode()) {
|
||||
putstring("SD error: ");
|
||||
Serial.print(card.errorCode(), HEX);
|
||||
Serial.print(',');
|
||||
Serial.println(card.errorData(), HEX);
|
||||
}
|
||||
*/
|
||||
while(1) {
|
||||
uint8_t i;
|
||||
for (i=0; i<errno; i++) {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(100);
|
||||
}
|
||||
for (i=errno; i<10; i++) {
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// for Leonardos, if you want to debug SD issues, uncomment this line
|
||||
// to see serial output
|
||||
//while (!Serial);
|
||||
|
||||
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
|
||||
// also spit it out
|
||||
Serial.begin(115200);
|
||||
Serial.println("\r\nUltimate GPSlogger Shield");
|
||||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
// make sure that the default chip select pin is set to
|
||||
// output, even if you don't use it:
|
||||
pinMode(10, OUTPUT);
|
||||
|
||||
// see if the card is present and can be initialized:
|
||||
if (!SD.begin(chipSelect, 11, 12, 13)) {
|
||||
//if (!SD.begin(chipSelect)) { // if you're using an UNO, you can use this line instead
|
||||
Serial.println("Card init. failed!");
|
||||
error(2);
|
||||
}
|
||||
char filename[15];
|
||||
strcpy(filename, "GPSLOG00.TXT");
|
||||
for (uint8_t i = 0; i < 100; i++) {
|
||||
filename[6] = '0' + i/10;
|
||||
filename[7] = '0' + i%10;
|
||||
// create if does not exist, do not open existing, write, sync after write
|
||||
if (! SD.exists(filename)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
logfile = SD.open(filename, FILE_WRITE);
|
||||
if( ! logfile ) {
|
||||
Serial.print("Couldnt create ");
|
||||
Serial.println(filename);
|
||||
error(3);
|
||||
}
|
||||
Serial.print("Writing to ");
|
||||
Serial.println(filename);
|
||||
|
||||
// connect to the GPS at the desired rate
|
||||
GPS.begin(9600);
|
||||
|
||||
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
|
||||
// uncomment this line to turn on only the "minimum recommended" data
|
||||
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
|
||||
// For logging data, we don't suggest using anything but either RMC only or RMC+GGA
|
||||
// to keep the log files at a reasonable size
|
||||
// Set the update rate
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate
|
||||
|
||||
// Turn off updates on antenna status, if the firmware permits it
|
||||
GPS.sendCommand(PGCMD_NOANTENNA);
|
||||
|
||||
// the nice thing about this code is you can have a timer0 interrupt go off
|
||||
// every 1 millisecond, and read data from the GPS for you. that makes the
|
||||
// loop code a heck of a lot easier!
|
||||
useInterrupt(true);
|
||||
|
||||
Serial.println("Ready!");
|
||||
}
|
||||
|
||||
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
SIGNAL(TIMER0_COMPA_vect) {
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
#ifdef UDR0
|
||||
if (GPSECHO)
|
||||
if (c) UDR0 = c;
|
||||
// writing direct to UDR0 is much much faster than Serial.print
|
||||
// but only one character can be written at a time.
|
||||
#endif
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v) {
|
||||
if (v) {
|
||||
// Timer0 is already used for millis() - we'll just interrupt somewhere
|
||||
// in the middle and call the "Compare A" function above
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
}
|
||||
else {
|
||||
// do not call the interrupt function COMPA anymore
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (! usingInterrupt) {
|
||||
// read data from the GPS in the 'main loop'
|
||||
char c = GPS.read();
|
||||
// if you want to debug, this is a good time to do it!
|
||||
if (GPSECHO)
|
||||
if (c) Serial.print(c);
|
||||
}
|
||||
|
||||
// if a sentence is received, we can check the checksum, parse it...
|
||||
if (GPS.newNMEAreceived()) {
|
||||
// a tricky thing here is if we print the NMEA sentence, or data
|
||||
// we end up not listening and catching other sentences!
|
||||
// so be very wary if using OUTPUT_ALLDATA and trying to print out data
|
||||
|
||||
// Don't call lastNMEA more than once between parse calls! Calling lastNMEA
|
||||
// will clear the received flag and can cause very subtle race conditions if
|
||||
// new data comes in before parse is called again.
|
||||
char *stringptr = GPS.lastNMEA();
|
||||
|
||||
if (!GPS.parse(stringptr)) // this also sets the newNMEAreceived() flag to false
|
||||
return; // we can fail to parse a sentence in which case we should just wait for another
|
||||
|
||||
// Sentence parsed!
|
||||
Serial.println("OK");
|
||||
if (LOG_FIXONLY && !GPS.fix) {
|
||||
Serial.print("No Fix");
|
||||
return;
|
||||
}
|
||||
|
||||
// Rad. lets log it!
|
||||
Serial.println("Log");
|
||||
|
||||
uint8_t stringsize = strlen(stringptr);
|
||||
if (stringsize != logfile.write((uint8_t *)stringptr, stringsize)) //write the string to the SD file
|
||||
error(4);
|
||||
if (strstr(stringptr, "RMC") || strstr(stringptr, "GGA")) logfile.flush();
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End code */
|
||||
|
||||
9
lib/Adafruit-GPS-Library/library.properties
Normal file
9
lib/Adafruit-GPS-Library/library.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
name=Adafruit GPS Library
|
||||
version=1.0.0
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=An interrupt-based GPS library for no-parsing-required use
|
||||
paragraph=An interrupt-based GPS library for no-parsing-required use
|
||||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit-GPS-Library
|
||||
architectures=*
|
||||
26
lib/Adafruit-GPS-Library/license.txt
Normal file
26
lib/Adafruit-GPS-Library/license.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012, Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
179
src/sketch.ino
Normal file
179
src/sketch.ino
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Reverse Geocache
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <LiquidCrystal.h>
|
||||
#include <Adafruit_GPS.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
// Defines
|
||||
#define GPSECHO false // make true to debug GPS
|
||||
#define ANTIFLICKER 500 // timeout for lcd
|
||||
|
||||
// Declarations
|
||||
const float deg2rad = 0.01745329251994;
|
||||
const float rEarth = 6371000.0; // can replace with 3958.75 mi, 6370.0 km, or 3440.06 NM
|
||||
float range = 3000; // distance from HERE to THERE
|
||||
String here; // read from GPS
|
||||
String tmp;
|
||||
int gpsWasFixed = HIGH; // did the GPS have a fix?
|
||||
boolean usingInterrupt = false;
|
||||
void useInterrupt(boolean);
|
||||
SoftwareSerial mySerial(3,2);
|
||||
Adafruit_GPS GPS(&mySerial);
|
||||
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
|
||||
|
||||
String there = "N46 59.776, E007 27.771";
|
||||
|
||||
/*******************************************/
|
||||
//String there = "N46 55.090, W7 26.442"; // Gurten: N 46 55.090 E 7 26.442
|
||||
/*******************************************/
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.begin(16, 2);
|
||||
|
||||
//Serial.begin(9600);
|
||||
//Serial.println("[DEBUGGING INFORMATIONS]:");
|
||||
|
||||
GPS.begin(9600);
|
||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); // RMC (recommended minimum) and GGA (fix data) including altitude
|
||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
|
||||
useInterrupt(true); // reads the steaming data in a background
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Parse GPS if new NMEA is available
|
||||
if (GPS.newNMEAreceived()) {
|
||||
if (!GPS.parse(GPS.lastNMEA())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (GPS.fix) {
|
||||
gpsWasFixed = HIGH;
|
||||
|
||||
here = gps2string ((String) GPS.lat, GPS.latitude, (String) GPS.lon, GPS.longitude);
|
||||
range = haversine(string2lat(here), string2lon(here), string2lat(there), string2lon(there));
|
||||
|
||||
tmp = String(range);
|
||||
tmp += " [m]";
|
||||
|
||||
/*Serial.print("Here: ");
|
||||
Serial.print(here);
|
||||
Serial.print("There: ");
|
||||
Serial.println(there);
|
||||
Serial.print("Range: ");
|
||||
Serial.print(range);
|
||||
Serial.println("m");*/
|
||||
|
||||
lcd.clear();
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print("I want up.");
|
||||
lcd.setCursor(0,1);
|
||||
lcd.print(tmp);
|
||||
|
||||
delay(500);
|
||||
|
||||
} else {
|
||||
lcd.clear();
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print("Hello Mischa!");
|
||||
lcd.setCursor(0,1);
|
||||
lcd.print("Take me outside!");
|
||||
delay(200);
|
||||
}
|
||||
|
||||
if (range < 20.0) {
|
||||
delay(1000);
|
||||
lcd.clear();
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print("Unlocked!");
|
||||
lcd.setCursor(0,1);
|
||||
lcd.print("[@1AK!!^~443]");
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SIGNAL(TIMER0_COMPA_vect)
|
||||
{
|
||||
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
|
||||
char c = GPS.read();
|
||||
if (GPSECHO){
|
||||
if (c) {
|
||||
UDR0 = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void useInterrupt(boolean v)
|
||||
{
|
||||
if (v) {
|
||||
OCR0A = 0xAF;
|
||||
TIMSK0 |= _BV(OCIE0A);
|
||||
usingInterrupt = true;
|
||||
} else {
|
||||
TIMSK0 &= ~_BV(OCIE0A);
|
||||
usingInterrupt = false;
|
||||
}
|
||||
}
|
||||
|
||||
String int2fw (int x, int n)
|
||||
{
|
||||
// returns a string of length n (fixed-width)
|
||||
String s = (String) x;
|
||||
while (s.length() < n) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
String gps2string (String lat, float latitude, String lon, float longitude)
|
||||
{
|
||||
// returns "Ndd mm.mmm, Wddd mm.mmm";
|
||||
int dd = (int) latitude/100;
|
||||
int mm = (int) latitude % 100;
|
||||
int mmm = (int) round(1000 * (latitude - floor(latitude)));
|
||||
String gps2lat = lat + int2fw(dd, 2) + " " + int2fw(mm, 2) + "." + int2fw(mmm, 3);
|
||||
dd = (int) longitude/100;
|
||||
mm = (int) longitude % 100;
|
||||
mmm = (int) round(1000 * (longitude - floor(longitude)));
|
||||
String gps2lon = lon + int2fw(dd, 3) + " " + int2fw(mm, 2) + "." + int2fw(mmm, 3);
|
||||
String myString = gps2lat + ", " + gps2lon;
|
||||
return myString;
|
||||
}
|
||||
|
||||
float string2lat (String myString)
|
||||
{
|
||||
// returns radians: e.g. String myString = "N38 58.892, W076 29.177";
|
||||
float lat = ((myString.charAt(1) - '0') * 10.0) + (myString.charAt(2) - '0') * 1.0 + ((myString.charAt(4) - '0') / 6.0) + ((myString.charAt(5) - '0') / 60.0) + ((myString.charAt(7) - '0') / 600.0) + ((myString.charAt(8) - '0') / 6000.0) + ((myString.charAt(9) - '0') / 60000.0);
|
||||
lat *= deg2rad;
|
||||
if (myString.charAt(0) == 'S') {
|
||||
lat *= -1; // Correct for hemisphere
|
||||
}
|
||||
return lat;
|
||||
}
|
||||
|
||||
float string2lon (String myString)
|
||||
{
|
||||
// returns radians: e.g. String myString = "N38 58.892, W076 29.177";
|
||||
float lon = ((myString.charAt(13) - '0') * 100.0) + ((myString.charAt(14) - '0') * 10.0) + (myString.charAt(15) - '0') * 1.0 + ((myString.charAt(17) - '0') / 6.0) + ((myString.charAt(18) - '0') / 60.0) + ((myString.charAt(20) - '0') / 600.0) + ((myString.charAt(21) - '0') / 6000.0) + ((myString.charAt(22) - '0') / 60000.0);
|
||||
lon *= deg2rad;
|
||||
if (myString.charAt(12) == 'W') {
|
||||
lon *= -1; // Correct for hemisphere
|
||||
}
|
||||
return lon;
|
||||
}
|
||||
|
||||
float haversine (float lat1, float lon1, float lat2, float lon2)
|
||||
{
|
||||
// returns the great-circle distance between two points (radians) on a sphere
|
||||
float h = sq((sin((lat1 - lat2) / 2.0))) + (cos(lat1) * cos(lat2) * sq((sin((lon1 - lon2) / 2.0))));
|
||||
float d = 2.0 * rEarth * asin (sqrt(h));
|
||||
return d;
|
||||
}
|
||||
Reference in New Issue
Block a user