2017年伊豆大島共同打ち上げ実験用電装モジュール搭載GPS測位プログラム
Dependents: Hybrid_interruptGPS Hybrid_main_FirstEdtion rocket_logger_sinkan2018_v1 HYBRYD2018_IZU_ROCKET ... more
Diff: GPS_interrupt.h
- Revision:
- 4:758f97bee95a
- Parent:
- 3:8e66ec281888
- Child:
- 5:15ff963f066b
diff -r 8e66ec281888 -r 758f97bee95a GPS_interrupt.h --- a/GPS_interrupt.h Tue Jan 03 09:22:54 2017 +0000 +++ b/GPS_interrupt.h Sun Jan 15 20:01:46 2017 +0000 @@ -1,5 +1,5 @@ /*============================================================================= -* GPS_interrupt.lib ver 1.2.6 +* GPS_interrupt.lib ver 1.3.5 * * Each palameters are not stable because they can be changed unexpectedly. * Therefor, you should use the funtions which have return value. @@ -7,6 +7,13 @@ * なんかコマンドの送信ミスがあるみたいで、確認して次に進めるようにすべきかも * PCソフトで設定して、バックアップ電池付けるのが正確っぽい *=============================================================================*/ +/** + * @file GPS_interrupt.h + * @brief GPSから送られてくるデータをバックグラウンドで解析し、呼び出せるライブラリ + * @author 松本岳 + * @note ver1.3.5 + */ + #ifndef GPS_INTERRUPT_H_ #define GPS_INTERRUPT_H_ @@ -15,20 +22,18 @@ class GPS_interrupt{ public: - /**===================================================================== + /** * @brief GPS_interrupt's constructer * @param *_gps : your Rawserial bus address - * @param _baudrate : baudrate you want to communication with GPS module * @param _frequency : set updata rate - * @param start_baudrate : baudrate in starting link - *=======================================================================*/ - GPS_interrupt(RawSerial *_gps, int _baudrate = 115200, int _frequency = 10, int start_baudrate = 9600); - static GPS_interrupt* gps_irq; + */ + GPS_interrupt(RawSerial *_gps, int _frequency = 10); + GPS_interrupt* gps_irq; void initialize();//初期化関数 void gps_auto_receive(); bool processGPRMC(char *line); bool processGPGGA(char *line); - void debug(char *str); + void debug(bool tf); unsigned char checkSum(char *str); void rmc_initialize(); void gga_initialize(); @@ -37,98 +42,267 @@ int baudrate; int frequency; - static double latitude; - static double longitude; - static int year; - static int month; - static int day; - static int hour; - static int minutes; - static double seconds; - static double knot; - static double degree; - static double height; - static double geoid; - static int number; + double latitude; + double longitude; + int year; + int month; + int day; + int hour; + int minutes; + double seconds; + double knot; + double degree; + double height; + double geoid; + int number; - static char gps_buffer_A[128]; - static char gps_buffer_B[128]; + char gps_buffer_A[128]; + char gps_buffer_B[128]; + + bool debugFlag; public: - static char *gps_read_buffer; - static bool gps_readable; + char *gps_read_buffer; + bool gps_readable; private: RawSerial *gps; public: + /** + * @fn + * 経度を返す関数 + * @brief 経度を取得 + * @return double型 経度 + * @detail inline展開したつもり + */ inline double Longitude(){ return longitude; } + + /** + * @fn + * 緯度を返す関数 + * @brief 緯度を取得 + * @return double型 緯度 + * @detail inline展開したつもり + */ inline double Latitude(){ return latitude; } + + /** + * @fn + * 年を返す関数 + * @brief 年を取得 + * @return int型 年 + * @detail inline展開したつもり + */ inline int Year(){ return year; } + + /** + * @fn + * 月を返す関数 + * @brief 月を取得 + * @return int型 月 + * @detail inline展開したつもり + */ inline int Month(){ return month; } + + /** + * @fn + * 日にちを返す関数 + * @brief 日にちを取得 + * @return int型 日にち + * @detail inline展開したつもり + */ inline int Day(){ return day; } + + /** + * @fn + * 時間を返す関数 + * @brief 時間を取得 + * @return int型 時間 + * @detail inline展開したつもり + */ inline int Hour(){ return hour; } + + /** + * @fn + * 分を返す関数 + * @brief 分を取得 + * @return int型 分 + * @detail inline展開したつもり + */ inline int Minutes(){ return minutes; } + + /** + * @fn + * 秒を返す関数 + * @brief 秒を取得 + * @return double型 秒 + * @detail inline展開したつもり + */ inline double Seconds(){ return seconds; } - inline void getPosition(double *lon, double *lat){ + + /** + * @fn + * 経度・緯度を取得できる関数 + * @brief 2つの変数に経度、緯度の順に値を代入する + * @param (*lon) double型 経度 アドレス + * @param (*lat) double型 緯度 アドレス + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 2つ変数を作って、そのアドレスを引数に与えてください。 + */ + inline bool getPosition(double *lon, double *lat){ *lon = longitude; - *lat = latitude; + *lat = latitude; + if(gps_readable) return true; + else return false; } - inline void getPosition(double *lonlat){ + + /** + * @fn + * 経度・緯度を取得できる関数 + * @brief 2つの配列に経度、緯度の順に値を代入する + * @param (*lonlat) double型 要素2の配列 + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 要素2の配列を作って、そのアドレスを引数に与えてください。 + */ + inline bool getPosition(double *lonlat){ lonlat[0] = longitude; - lonlat[1] = latitude; + lonlat[1] = latitude; + if(gps_readable) return true; + else return false; } - inline void getUTC(int *_year, int *_month, int *_day, int *_hour, int *_minutes, double *_seconds){ + + /** + * @fn + * 日付・時刻を取得できる関数 + * @brief 6つの変数に年、月、日、時間、分、秒の順に値を代入する + * @param (*_year) int型 年 アドレス + * @param (*_month) int型 月 アドレス + * @param (*_day) int型 日 アドレス + * @param (*_hour) int型 時間 アドレス + * @param (*_minutes) int型 分 アドレス + * @param (*_seconds) double型 秒 アドレス + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 6つ変数を作って、そのアドレスを引数に与えてください。 + */ + inline bool getUTC(int *_year, int *_month, int *_day, int *_hour, int *_minutes, double *_seconds){ *_year = year; *_month = month; *_day = day; *_hour = hour; *_minutes = minutes; - *_seconds = seconds; + *_seconds = seconds; + if(gps_readable) return true; + else return false; } - inline void getUTC(float *_utc){ + + /** + * @fn + * 世界協定時間の日付・時刻を取得できる関数 + * @brief 要素数6の配列に年、月、日、時間、分、秒の順に値を代入する + * @param (*_utc) float型 秒 アドレス + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 要素6の配列を作って、そのアドレスを引数に与えてください。 + */ + inline bool getUTC(float *_utc){ _utc[0] = (float)year; _utc[1] = (float)month; _utc[2] = (float)day; _utc[3] = (float)hour; _utc[4] = (float)minutes; _utc[5] = seconds; + + if(gps_readable) return true; + else return false; } - inline void getUTC(int *_utc){ + + /** + * @fn + * 世界協定時間の日付・時刻を取得できる関数 + * @brief 要素数6の配列に年、月、日、時間、分、秒の順に値を代入する + * @param (*_utc) int型 秒 アドレス + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 要素6の配列を作って、そのアドレスを引数に与えてください。 + */ + inline bool getUTC(int *_utc){ _utc[0] = year; _utc[1] = month; _utc[2] = day; _utc[3] = hour; _utc[4] = minutes; _utc[5] = (int)seconds; + if(gps_readable) return true; + else return false; } - inline void getSpeedVector(double *_knot, double *_degree){ + + /** + * @fn + * 速度・進行方角を取得できる関数 + * @brief 2つの変数に速度、進行方角の順に値を代入する + * @param (*_knot) double型 経度 アドレス [knot] + * @param (*_degree) double型 緯度 アドレス [degree] 北から右回り正です。 + * @return データが有効かどうか 有効ならtrue, 無効ならfalse + * @detail 2つ変数を作って、そのアドレスを引数に与えてください。 + */ + inline bool getSpeedVector(double *_knot, double *_degree){ *_knot = knot; *_degree = degree; + if(gps_readable) return true; + else return false; } + + /** + * @fn + * 捕捉衛星数を取得できる関数 + * @brief 捕捉衛星数を返します。 + * @return int型 捕捉衛星数 アドレス + */ inline int Number(){ return number; } + + /** + * @fn + * 標高を取得できる関数 + * @brief 標高を返します。 + * @return double型 標高 アドレス + */ inline double Height(){ return height; } + + + /** + * @fn + * 速さを取得できる関数 + * @brief 速さを返します。 + * @return double型 速さ アドレス[knot] + */ inline double Knot(){ return knot; } + + + /** + * @fn + * 進行方角を取得できる関数 + * @brief 進行方角を返します。 + * @return double型 進行方角 アドレス 北から右回り正です。 + */ inline double Degree(){ return degree; } @@ -137,6 +311,7 @@ /////sample////// ///////////////// /* +@code #include "mbed.h" #include "GPS_interrupt.h" Serial pc(USBTX, USBRX); @@ -203,6 +378,6 @@ wait(0.1); } } - +@codeend */ #endif \ No newline at end of file