東北大学学友会準加盟団体 From The Earth の高高度ロケットFTE-06(通称:海豚)にて使用したソフトウェアです.ご自由にお使いください.このプログラムによって生じた損害について当団体は一切責任を負いません.また,各モジュールのライブラリは当団体が作成したものではないので再配布は禁止します.

Dependencies:   mbed FATFileSystem

Fork of FTE-06 by Tetsushi Amano

Committer:
mizuki_akaike
Date:
Mon Aug 21 16:24:34 2017 +0000
Revision:
46:a8617076f021
gps?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mizuki_akaike 46:a8617076f021 1 #include "mbed.h"
mizuki_akaike 46:a8617076f021 2
mizuki_akaike 46:a8617076f021 3 #ifndef MBED_GPS_H
mizuki_akaike 46:a8617076f021 4 #define MBED_GPS_H
mizuki_akaike 46:a8617076f021 5
mizuki_akaike 46:a8617076f021 6 #define NO_LOCK 1
mizuki_akaike 46:a8617076f021 7 #define NOT_PARSED 2
mizuki_akaike 46:a8617076f021 8 #define GGA 3
mizuki_akaike 46:a8617076f021 9 #define GLL 4
mizuki_akaike 46:a8617076f021 10 #define RMC 5
mizuki_akaike 46:a8617076f021 11 #define VTG 6
mizuki_akaike 46:a8617076f021 12
mizuki_akaike 46:a8617076f021 13 #define PI (3.141592653589793)
mizuki_akaike 46:a8617076f021 14
mizuki_akaike 46:a8617076f021 15 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */
mizuki_akaike 46:a8617076f021 16 class GPS {
mizuki_akaike 46:a8617076f021 17 public:
mizuki_akaike 46:a8617076f021 18
mizuki_akaike 46:a8617076f021 19 /** Create the GPS interface, connected to the specified serial port
mizuki_akaike 46:a8617076f021 20 */
mizuki_akaike 46:a8617076f021 21 GPS(PinName tx, PinName rx);
mizuki_akaike 46:a8617076f021 22
mizuki_akaike 46:a8617076f021 23 /** Sample the incoming GPS data, returning whether there is a lock
mizuki_akaike 46:a8617076f021 24 *
mizuki_akaike 46:a8617076f021 25 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
mizuki_akaike 46:a8617076f021 26 */
mizuki_akaike 46:a8617076f021 27 int sample();
mizuki_akaike 46:a8617076f021 28 float get_nmea_longitude();
mizuki_akaike 46:a8617076f021 29 float get_nmea_latitude();
mizuki_akaike 46:a8617076f021 30 float get_dec_longitude();
mizuki_akaike 46:a8617076f021 31 float get_dec_latitude();
mizuki_akaike 46:a8617076f021 32 float get_msl_altitude();
mizuki_akaike 46:a8617076f021 33 float get_course_t();
mizuki_akaike 46:a8617076f021 34 float get_course_m();
mizuki_akaike 46:a8617076f021 35 float get_speed_k();
mizuki_akaike 46:a8617076f021 36 float get_speed_km();
mizuki_akaike 46:a8617076f021 37 int get_satelites();
mizuki_akaike 46:a8617076f021 38 float get_altitude_ft();
mizuki_akaike 46:a8617076f021 39
mizuki_akaike 46:a8617076f021 40 // navigational functions
mizuki_akaike 46:a8617076f021 41 float calc_course_to(float, float);
mizuki_akaike 46:a8617076f021 42 double calc_dist_to_mi(float, float);
mizuki_akaike 46:a8617076f021 43 double calc_dist_to_ft(float, float);
mizuki_akaike 46:a8617076f021 44 double calc_dist_to_km(float, float);
mizuki_akaike 46:a8617076f021 45 double calc_dist_to_m(float, float);
mizuki_akaike 46:a8617076f021 46
mizuki_akaike 46:a8617076f021 47 #ifdef OPEN_LOG
mizuki_akaike 46:a8617076f021 48 void start_log(void);
mizuki_akaike 46:a8617076f021 49 void new_file(void);
mizuki_akaike 46:a8617076f021 50 void stop_log(void);
mizuki_akaike 46:a8617076f021 51 #endif
mizuki_akaike 46:a8617076f021 52
mizuki_akaike 46:a8617076f021 53 private:
mizuki_akaike 46:a8617076f021 54 float nmea_to_dec(float, char);
mizuki_akaike 46:a8617076f021 55 float trunc(float v);
mizuki_akaike 46:a8617076f021 56 void getline();
mizuki_akaike 46:a8617076f021 57 void format_for_log(void);
mizuki_akaike 46:a8617076f021 58
mizuki_akaike 46:a8617076f021 59 Serial _gps;
mizuki_akaike 46:a8617076f021 60 char msg[1024];
mizuki_akaike 46:a8617076f021 61 char bfr[1030];
mizuki_akaike 46:a8617076f021 62 bool is_logging;
mizuki_akaike 46:a8617076f021 63 #ifdef OPEN_LOG
mizuki_akaike 46:a8617076f021 64 Logger _openLog;
mizuki_akaike 46:a8617076f021 65 #endif
mizuki_akaike 46:a8617076f021 66 // calculated values
mizuki_akaike 46:a8617076f021 67 float dec_longitude;
mizuki_akaike 46:a8617076f021 68 float dec_latitude;
mizuki_akaike 46:a8617076f021 69 float altitude_ft;
mizuki_akaike 46:a8617076f021 70
mizuki_akaike 46:a8617076f021 71 // GGA - Global Positioning System Fixed Data
mizuki_akaike 46:a8617076f021 72 float nmea_longitude;
mizuki_akaike 46:a8617076f021 73 float nmea_latitude;
mizuki_akaike 46:a8617076f021 74 float utc_time;
mizuki_akaike 46:a8617076f021 75 char ns, ew;
mizuki_akaike 46:a8617076f021 76 int lock;
mizuki_akaike 46:a8617076f021 77 int satelites;
mizuki_akaike 46:a8617076f021 78 float hdop;
mizuki_akaike 46:a8617076f021 79 float msl_altitude;
mizuki_akaike 46:a8617076f021 80 char msl_units;
mizuki_akaike 46:a8617076f021 81
mizuki_akaike 46:a8617076f021 82 // RMC - Recommended Minimmum Specific GNS Data
mizuki_akaike 46:a8617076f021 83 char rmc_status;
mizuki_akaike 46:a8617076f021 84 float speed_k;
mizuki_akaike 46:a8617076f021 85 float course_d;
mizuki_akaike 46:a8617076f021 86 int date;
mizuki_akaike 46:a8617076f021 87
mizuki_akaike 46:a8617076f021 88 // GLL
mizuki_akaike 46:a8617076f021 89 char gll_status;
mizuki_akaike 46:a8617076f021 90
mizuki_akaike 46:a8617076f021 91 // VTG - Course over ground, ground speed
mizuki_akaike 46:a8617076f021 92 float course_t; // ground speed true
mizuki_akaike 46:a8617076f021 93 char course_t_unit;
mizuki_akaike 46:a8617076f021 94 float course_m; // magnetic
mizuki_akaike 46:a8617076f021 95 char course_m_unit;
mizuki_akaike 46:a8617076f021 96 char speed_k_unit;
mizuki_akaike 46:a8617076f021 97 float speed_km; // speek km/hr
mizuki_akaike 46:a8617076f021 98 char speed_km_unit;
mizuki_akaike 46:a8617076f021 99 };
mizuki_akaike 46:a8617076f021 100
mizuki_akaike 46:a8617076f021 101 #endif