GPS精度実験

Dependents:   GPSLOG_program

Fork of MBed_Adafruit-GPS-Library by aigamozu

Committer:
kityann
Date:
Tue Aug 09 13:04:23 2016 +0000
Revision:
5:ce26d53dc358
Parent:
3:cc9ab73d0624
Child:
7:3f389529228e
comitto

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mlee350 0:a23e3099bb0a 1 /***********************************
mlee350 0:a23e3099bb0a 2 This is the Adafruit GPS library - the ultimate GPS library
mlee350 0:a23e3099bb0a 3 for the ultimate GPS module!
mlee350 0:a23e3099bb0a 4
mlee350 0:a23e3099bb0a 5 Tested and works great with the Adafruit Ultimate GPS module
mlee350 0:a23e3099bb0a 6 using MTK33x9 chipset
mlee350 0:a23e3099bb0a 7 ------> http://www.adafruit.com/products/746
mlee350 0:a23e3099bb0a 8 Pick one up today at the Adafruit electronics shop
mlee350 0:a23e3099bb0a 9 and help support open source hardware & software! -ada
mlee350 0:a23e3099bb0a 10
mlee350 0:a23e3099bb0a 11 Adafruit invests time and resources providing this open source code,
mlee350 0:a23e3099bb0a 12 please support Adafruit and open-source hardware by purchasing
mlee350 0:a23e3099bb0a 13 products from Adafruit!
mlee350 0:a23e3099bb0a 14
mlee350 0:a23e3099bb0a 15 Written by Limor Fried/Ladyada for Adafruit Industries.
mlee350 0:a23e3099bb0a 16 BSD license, check license.txt for more information
mlee350 0:a23e3099bb0a 17 All text above must be included in any redistribution
mlee350 0:a23e3099bb0a 18 ****************************************/
mlee350 0:a23e3099bb0a 19 #include "mbed.h"
mlee350 0:a23e3099bb0a 20 #include <stdint.h>
mlee350 0:a23e3099bb0a 21 #include <math.h>
mlee350 0:a23e3099bb0a 22 #include <ctype.h>
mlee350 0:a23e3099bb0a 23
kityann 5:ce26d53dc358 24
mlee350 0:a23e3099bb0a 25 #ifndef _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 26 #define _MBED_ADAFRUIT_GPS_H
mlee350 0:a23e3099bb0a 27
mlee350 0:a23e3099bb0a 28
mlee350 0:a23e3099bb0a 29 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
mlee350 0:a23e3099bb0a 30 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
mlee350 0:a23e3099bb0a 31 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
mlee350 0:a23e3099bb0a 32 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
mlee350 0:a23e3099bb0a 33
mlee350 0:a23e3099bb0a 34
mlee350 0:a23e3099bb0a 35 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
mlee350 0:a23e3099bb0a 36 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
mlee350 0:a23e3099bb0a 37
mlee350 0:a23e3099bb0a 38 // turn on only the second sentence (GPRMC)
mlee350 0:a23e3099bb0a 39 #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"
mlee350 0:a23e3099bb0a 40 // turn on GPRMC and GGA
mlee350 0:a23e3099bb0a 41 #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"
mlee350 0:a23e3099bb0a 42 // turn on ALL THE DATA
mlee350 0:a23e3099bb0a 43 #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"
mlee350 0:a23e3099bb0a 44 // turn off output
mlee350 0:a23e3099bb0a 45 #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"
mlee350 0:a23e3099bb0a 46
mlee350 0:a23e3099bb0a 47 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
mlee350 0:a23e3099bb0a 48 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
mlee350 0:a23e3099bb0a 49
mlee350 0:a23e3099bb0a 50 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
mlee350 0:a23e3099bb0a 51 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
mlee350 0:a23e3099bb0a 52 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
mlee350 0:a23e3099bb0a 53 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
mlee350 0:a23e3099bb0a 54 #define LOCUS_OVERLAP 0
mlee350 0:a23e3099bb0a 55 #define LOCUS_FULLSTOP 1
mlee350 0:a23e3099bb0a 56
mlee350 0:a23e3099bb0a 57 // standby command & boot successful message
mlee350 0:a23e3099bb0a 58 #define PMTK_STANDBY "$PMTK161,0*28"
mlee350 0:a23e3099bb0a 59 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
mlee350 0:a23e3099bb0a 60 #define PMTK_AWAKE "$PMTK010,002*2D"
mlee350 0:a23e3099bb0a 61
mlee350 0:a23e3099bb0a 62 // ask for the release and version
mlee350 0:a23e3099bb0a 63 #define PMTK_Q_RELEASE "$PMTK605*31"
mlee350 0:a23e3099bb0a 64
mlee350 0:a23e3099bb0a 65 // request for updates on antenna status
mlee350 0:a23e3099bb0a 66 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
mlee350 0:a23e3099bb0a 67 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
mlee350 0:a23e3099bb0a 68
mlee350 0:a23e3099bb0a 69 // how long to wait when we're looking for a response
mlee350 0:a23e3099bb0a 70 #define MAXWAITSENTENCE 5
mlee350 0:a23e3099bb0a 71
mlee350 0:a23e3099bb0a 72
mlee350 0:a23e3099bb0a 73
mlee350 0:a23e3099bb0a 74 class Adafruit_GPS {
mlee350 0:a23e3099bb0a 75 public:
mlee350 0:a23e3099bb0a 76 void begin(int baud);
mlee350 0:a23e3099bb0a 77
mlee350 0:a23e3099bb0a 78 Adafruit_GPS(Serial * ser);
mlee350 0:a23e3099bb0a 79
mlee350 0:a23e3099bb0a 80 char *lastNMEA(void);
mlee350 0:a23e3099bb0a 81 bool newNMEAreceived();
mlee350 0:a23e3099bb0a 82 void common_init(void);
mlee350 0:a23e3099bb0a 83 void sendCommand(char *);
mlee350 0:a23e3099bb0a 84 void pause(bool b);
mlee350 0:a23e3099bb0a 85
mlee350 0:a23e3099bb0a 86 bool parseNMEA(char *response);
mlee350 0:a23e3099bb0a 87 uint8_t parseHex(char c);
kityann 5:ce26d53dc358 88
kityann 5:ce26d53dc358 89 char *GPGGAdata;
kityann 5:ce26d53dc358 90 char *GPRMCdata;
kityann 5:ce26d53dc358 91 char *GPGSAdata;
mlee350 0:a23e3099bb0a 92
mlee350 0:a23e3099bb0a 93 char read(void);
mlee350 0:a23e3099bb0a 94 bool parse(char * nmea);
mlee350 0:a23e3099bb0a 95 void interruptReads(bool r);
mlee350 0:a23e3099bb0a 96
mlee350 0:a23e3099bb0a 97 bool wakeup(void);
mlee350 0:a23e3099bb0a 98 bool standby(void);
mlee350 0:a23e3099bb0a 99
mlee350 0:a23e3099bb0a 100 uint8_t hour, minute, seconds, year, month, day;
mlee350 0:a23e3099bb0a 101 uint16_t milliseconds;
m5171135 1:ff72e93bcb0e 102 float geoidheight, altitude;
m5171135 1:ff72e93bcb0e 103 long latitudeH,latitudeL,longitudeH,longitudeL;
kityann 3:cc9ab73d0624 104 long latitudeKH,latitudeKL,longitudeKH,longitudeKL;
mlee350 0:a23e3099bb0a 105 float speed, angle, magvariation, HDOP;
mlee350 0:a23e3099bb0a 106 char lat, lon, mag;
mlee350 0:a23e3099bb0a 107 bool fix;
mlee350 0:a23e3099bb0a 108 uint8_t fixquality, satellites;
mlee350 0:a23e3099bb0a 109
mlee350 0:a23e3099bb0a 110 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
mlee350 0:a23e3099bb0a 111 bool LOCUS_StartLogger(void);
mlee350 0:a23e3099bb0a 112 bool LOCUS_ReadStatus(void);
mlee350 0:a23e3099bb0a 113
mlee350 0:a23e3099bb0a 114 uint16_t LOCUS_serial, LOCUS_records;
mlee350 0:a23e3099bb0a 115 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
mlee350 0:a23e3099bb0a 116 private:
mlee350 0:a23e3099bb0a 117 bool paused;
mlee350 0:a23e3099bb0a 118
mlee350 0:a23e3099bb0a 119 Serial * gpsSerial;
mlee350 0:a23e3099bb0a 120 };
mlee350 0:a23e3099bb0a 121
mlee350 0:a23e3099bb0a 122 #endif