2017年伊豆大島共同打ち上げ実験用電装モジュール搭載GPS測位プログラム
Dependents: Hybrid_interruptGPS Hybrid_main_FirstEdtion rocket_logger_sinkan2018_v1 HYBRYD2018_IZU_ROCKET ... more
GPS_interrupt.h@6:2f91c71d64b1, 2017-02-21 (annotated)
- Committer:
- Gaku0606
- Date:
- Tue Feb 21 13:42:00 2017 +0000
- Revision:
- 6:2f91c71d64b1
- Parent:
- 5:15ff963f066b
- Child:
- 8:3f32df2b66c0
due
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gaku0606 | 0:74d8e952a3bd | 1 | /*============================================================================= |
Gaku0606 | 4:758f97bee95a | 2 | * GPS_interrupt.lib ver 1.3.5 |
Gaku0606 | 0:74d8e952a3bd | 3 | * |
Gaku0606 | 1:57eeee14dd31 | 4 | * Each palameters are not stable because they can be changed unexpectedly. |
Gaku0606 | 1:57eeee14dd31 | 5 | * Therefor, you should use the funtions which have return value. |
Gaku0606 | 1:57eeee14dd31 | 6 | * Then, you must not substitute any value for those palameters. |
Gaku0606 | 2:7be89bab6db9 | 7 | * なんかコマンドの送信ミスがあるみたいで、確認して次に進めるようにすべきかも |
Gaku0606 | 2:7be89bab6db9 | 8 | * PCソフトで設定して、バックアップ電池付けるのが正確っぽい |
Gaku0606 | 0:74d8e952a3bd | 9 | *=============================================================================*/ |
Gaku0606 | 4:758f97bee95a | 10 | /** |
Gaku0606 | 4:758f97bee95a | 11 | * @file GPS_interrupt.h |
Gaku0606 | 5:15ff963f066b | 12 | * @bref GPSから送られてくるデータをバックグラウンドで解析し、呼び出せるライブラリ |
Gaku0606 | 4:758f97bee95a | 13 | * @author 松本岳 |
Gaku0606 | 4:758f97bee95a | 14 | * @note ver1.3.5 |
Gaku0606 | 4:758f97bee95a | 15 | */ |
Gaku0606 | 4:758f97bee95a | 16 | |
Gaku0606 | 0:74d8e952a3bd | 17 | #ifndef GPS_INTERRUPT_H_ |
Gaku0606 | 0:74d8e952a3bd | 18 | #define GPS_INTERRUPT_H_ |
Gaku0606 | 0:74d8e952a3bd | 19 | |
Gaku0606 | 2:7be89bab6db9 | 20 | #include "mbed.h"//要る? |
Gaku0606 | 0:74d8e952a3bd | 21 | |
Gaku0606 | 0:74d8e952a3bd | 22 | class GPS_interrupt{ |
Gaku0606 | 0:74d8e952a3bd | 23 | |
Gaku0606 | 0:74d8e952a3bd | 24 | public: |
Gaku0606 | 6:2f91c71d64b1 | 25 | GPS_interrupt(Serial *_gps); |
Gaku0606 | 5:15ff963f066b | 26 | |
Gaku0606 | 5:15ff963f066b | 27 | /** |
Gaku0606 | 5:15ff963f066b | 28 | * @bref GPS_interrupt's constructer |
Gaku0606 | 6:2f91c71d64b1 | 29 | * @param _gps GPSと通信したいSerialバスのポインタ |
Gaku0606 | 5:15ff963f066b | 30 | * @param _frequency GPSから何Hzでデータを取得したいか |
Gaku0606 | 4:758f97bee95a | 31 | */ |
Gaku0606 | 6:2f91c71d64b1 | 32 | GPS_interrupt(Serial *_gps, int _frequency); |
Gaku0606 | 5:15ff963f066b | 33 | |
Gaku0606 | 5:15ff963f066b | 34 | |
Gaku0606 | 0:74d8e952a3bd | 35 | void initialize();//初期化関数 |
Gaku0606 | 0:74d8e952a3bd | 36 | void gps_auto_receive(); |
Gaku0606 | 2:7be89bab6db9 | 37 | bool processGPRMC(char *line); |
Gaku0606 | 2:7be89bab6db9 | 38 | bool processGPGGA(char *line); |
Gaku0606 | 4:758f97bee95a | 39 | void debug(bool tf); |
Gaku0606 | 2:7be89bab6db9 | 40 | unsigned char checkSum(char *str); |
Gaku0606 | 2:7be89bab6db9 | 41 | void rmc_initialize(); |
Gaku0606 | 2:7be89bab6db9 | 42 | void gga_initialize(); |
Gaku0606 | 0:74d8e952a3bd | 43 | |
Gaku0606 | 2:7be89bab6db9 | 44 | private://別にpublicにしても良かったけれど、unexpectedlyに変更されるので使えないようにしてやった |
Gaku0606 | 5:15ff963f066b | 45 | GPS_interrupt* gps_irq; |
Gaku0606 | 2:7be89bab6db9 | 46 | int baudrate; |
Gaku0606 | 2:7be89bab6db9 | 47 | int frequency; |
Gaku0606 | 2:7be89bab6db9 | 48 | |
Gaku0606 | 4:758f97bee95a | 49 | double latitude; |
Gaku0606 | 4:758f97bee95a | 50 | double longitude; |
Gaku0606 | 4:758f97bee95a | 51 | int year; |
Gaku0606 | 4:758f97bee95a | 52 | int month; |
Gaku0606 | 4:758f97bee95a | 53 | int day; |
Gaku0606 | 4:758f97bee95a | 54 | int hour; |
Gaku0606 | 4:758f97bee95a | 55 | int minutes; |
Gaku0606 | 4:758f97bee95a | 56 | double seconds; |
Gaku0606 | 4:758f97bee95a | 57 | double knot; |
Gaku0606 | 4:758f97bee95a | 58 | double degree; |
Gaku0606 | 4:758f97bee95a | 59 | double height; |
Gaku0606 | 4:758f97bee95a | 60 | double geoid; |
Gaku0606 | 4:758f97bee95a | 61 | int number; |
Gaku0606 | 0:74d8e952a3bd | 62 | |
Gaku0606 | 4:758f97bee95a | 63 | char gps_buffer_A[128]; |
Gaku0606 | 4:758f97bee95a | 64 | char gps_buffer_B[128]; |
Gaku0606 | 4:758f97bee95a | 65 | |
Gaku0606 | 4:758f97bee95a | 66 | bool debugFlag; |
Gaku0606 | 2:7be89bab6db9 | 67 | |
Gaku0606 | 2:7be89bab6db9 | 68 | public: |
Gaku0606 | 4:758f97bee95a | 69 | char *gps_read_buffer; |
Gaku0606 | 4:758f97bee95a | 70 | bool gps_readable; |
Gaku0606 | 0:74d8e952a3bd | 71 | private: |
Gaku0606 | 6:2f91c71d64b1 | 72 | Serial *gps; |
Gaku0606 | 0:74d8e952a3bd | 73 | public: |
Gaku0606 | 5:15ff963f066b | 74 | |
Gaku0606 | 5:15ff963f066b | 75 | /** 経度を返す関数 |
Gaku0606 | 5:15ff963f066b | 76 | * @bref 経度を取得 |
Gaku0606 | 4:758f97bee95a | 77 | * @return double型 経度 |
Gaku0606 | 5:15ff963f066b | 78 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 79 | */ |
Gaku0606 | 0:74d8e952a3bd | 80 | inline double Longitude(){ |
Gaku0606 | 0:74d8e952a3bd | 81 | return longitude; |
Gaku0606 | 0:74d8e952a3bd | 82 | } |
Gaku0606 | 4:758f97bee95a | 83 | |
Gaku0606 | 5:15ff963f066b | 84 | /** 緯度を返す関数 |
Gaku0606 | 5:15ff963f066b | 85 | * @bref 緯度を取得 |
Gaku0606 | 4:758f97bee95a | 86 | * @return double型 緯度 |
Gaku0606 | 5:15ff963f066b | 87 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 88 | */ |
Gaku0606 | 0:74d8e952a3bd | 89 | inline double Latitude(){ |
Gaku0606 | 0:74d8e952a3bd | 90 | return latitude; |
Gaku0606 | 0:74d8e952a3bd | 91 | } |
Gaku0606 | 4:758f97bee95a | 92 | |
Gaku0606 | 5:15ff963f066b | 93 | /** 年を返す関数 |
Gaku0606 | 5:15ff963f066b | 94 | * @bref 年を取得 |
Gaku0606 | 4:758f97bee95a | 95 | * @return int型 年 |
Gaku0606 | 5:15ff963f066b | 96 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 97 | */ |
Gaku0606 | 0:74d8e952a3bd | 98 | inline int Year(){ |
Gaku0606 | 0:74d8e952a3bd | 99 | return year; |
Gaku0606 | 0:74d8e952a3bd | 100 | } |
Gaku0606 | 4:758f97bee95a | 101 | |
Gaku0606 | 5:15ff963f066b | 102 | /** 月を返す関数 |
Gaku0606 | 5:15ff963f066b | 103 | * @bref 月を取得 |
Gaku0606 | 4:758f97bee95a | 104 | * @return int型 月 |
Gaku0606 | 5:15ff963f066b | 105 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 106 | */ |
Gaku0606 | 0:74d8e952a3bd | 107 | inline int Month(){ |
Gaku0606 | 0:74d8e952a3bd | 108 | return month; |
Gaku0606 | 0:74d8e952a3bd | 109 | } |
Gaku0606 | 4:758f97bee95a | 110 | |
Gaku0606 | 5:15ff963f066b | 111 | /** 日にちを返す関数 |
Gaku0606 | 5:15ff963f066b | 112 | * @bref 日にちを取得 |
Gaku0606 | 4:758f97bee95a | 113 | * @return int型 日にち |
Gaku0606 | 5:15ff963f066b | 114 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 115 | */ |
Gaku0606 | 0:74d8e952a3bd | 116 | inline int Day(){ |
Gaku0606 | 0:74d8e952a3bd | 117 | return day; |
Gaku0606 | 0:74d8e952a3bd | 118 | } |
Gaku0606 | 4:758f97bee95a | 119 | |
Gaku0606 | 5:15ff963f066b | 120 | /** 時間を返す関数 |
Gaku0606 | 5:15ff963f066b | 121 | * @bref 時間を取得 |
Gaku0606 | 4:758f97bee95a | 122 | * @return int型 時間 |
Gaku0606 | 5:15ff963f066b | 123 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 124 | */ |
Gaku0606 | 0:74d8e952a3bd | 125 | inline int Hour(){ |
Gaku0606 | 0:74d8e952a3bd | 126 | return hour; |
Gaku0606 | 0:74d8e952a3bd | 127 | } |
Gaku0606 | 4:758f97bee95a | 128 | |
Gaku0606 | 5:15ff963f066b | 129 | /** 分を返す関数 |
Gaku0606 | 5:15ff963f066b | 130 | * @bref 分を取得 |
Gaku0606 | 4:758f97bee95a | 131 | * @return int型 分 |
Gaku0606 | 5:15ff963f066b | 132 | * @note inline展開したつもり |
Gaku0606 | 4:758f97bee95a | 133 | */ |
Gaku0606 | 0:74d8e952a3bd | 134 | inline int Minutes(){ |
Gaku0606 | 0:74d8e952a3bd | 135 | return minutes; |
Gaku0606 | 0:74d8e952a3bd | 136 | } |
Gaku0606 | 4:758f97bee95a | 137 | |
Gaku0606 | 5:15ff963f066b | 138 | /** 秒を返す関数 |
Gaku0606 | 5:15ff963f066b | 139 | * @bref 秒を取得 |
Gaku0606 | 4:758f97bee95a | 140 | * @return double型 秒 |
Gaku0606 | 4:758f97bee95a | 141 | */ |
Gaku0606 | 0:74d8e952a3bd | 142 | inline double Seconds(){ |
Gaku0606 | 0:74d8e952a3bd | 143 | return seconds; |
Gaku0606 | 0:74d8e952a3bd | 144 | } |
Gaku0606 | 4:758f97bee95a | 145 | |
Gaku0606 | 5:15ff963f066b | 146 | /** 経度・緯度を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 147 | * @bref 2つの変数に経度、緯度の順に値を代入する |
Gaku0606 | 5:15ff963f066b | 148 | * @param lon double型 経度 ポインタ |
Gaku0606 | 5:15ff963f066b | 149 | * @param lat double型 緯度 ポインタ |
Gaku0606 | 4:758f97bee95a | 150 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 5:15ff963f066b | 151 | * @note 2つ変数を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 152 | */ |
Gaku0606 | 4:758f97bee95a | 153 | inline bool getPosition(double *lon, double *lat){ |
Gaku0606 | 0:74d8e952a3bd | 154 | *lon = longitude; |
Gaku0606 | 4:758f97bee95a | 155 | *lat = latitude; |
Gaku0606 | 4:758f97bee95a | 156 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 157 | else return false; |
Gaku0606 | 0:74d8e952a3bd | 158 | } |
Gaku0606 | 4:758f97bee95a | 159 | |
Gaku0606 | 5:15ff963f066b | 160 | /** 経度・緯度を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 161 | * @bref 2つの配列に経度、緯度の順に値を代入する |
Gaku0606 | 5:15ff963f066b | 162 | * @param lonlat double型 要素2の配列 |
Gaku0606 | 4:758f97bee95a | 163 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 5:15ff963f066b | 164 | * @note 要素2の配列を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 165 | */ |
Gaku0606 | 4:758f97bee95a | 166 | inline bool getPosition(double *lonlat){ |
Gaku0606 | 0:74d8e952a3bd | 167 | lonlat[0] = longitude; |
Gaku0606 | 4:758f97bee95a | 168 | lonlat[1] = latitude; |
Gaku0606 | 4:758f97bee95a | 169 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 170 | else return false; |
Gaku0606 | 0:74d8e952a3bd | 171 | } |
Gaku0606 | 4:758f97bee95a | 172 | |
Gaku0606 | 5:15ff963f066b | 173 | /** 日付・時刻を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 174 | * @bref 6つの変数に年、月、日、時間、分、秒の順に値を代入する |
Gaku0606 | 5:15ff963f066b | 175 | * @param _year int型 年 ポインタ |
Gaku0606 | 5:15ff963f066b | 176 | * @param _month int型 月 ポインタ |
Gaku0606 | 5:15ff963f066b | 177 | * @param _day int型 日 ポインタ |
Gaku0606 | 5:15ff963f066b | 178 | * @param _hour int型 時間 ポインタ |
Gaku0606 | 5:15ff963f066b | 179 | * @param _minutes int型 分 ポインタ |
Gaku0606 | 5:15ff963f066b | 180 | * @param _seconds double型 秒 ポインタ |
Gaku0606 | 4:758f97bee95a | 181 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 5:15ff963f066b | 182 | * @note 6つ変数を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 183 | */ |
Gaku0606 | 4:758f97bee95a | 184 | inline bool getUTC(int *_year, int *_month, int *_day, int *_hour, int *_minutes, double *_seconds){ |
Gaku0606 | 0:74d8e952a3bd | 185 | *_year = year; |
Gaku0606 | 0:74d8e952a3bd | 186 | *_month = month; |
Gaku0606 | 0:74d8e952a3bd | 187 | *_day = day; |
Gaku0606 | 0:74d8e952a3bd | 188 | *_hour = hour; |
Gaku0606 | 0:74d8e952a3bd | 189 | *_minutes = minutes; |
Gaku0606 | 4:758f97bee95a | 190 | *_seconds = seconds; |
Gaku0606 | 4:758f97bee95a | 191 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 192 | else return false; |
Gaku0606 | 0:74d8e952a3bd | 193 | } |
Gaku0606 | 4:758f97bee95a | 194 | |
Gaku0606 | 5:15ff963f066b | 195 | /** 世界協定時間の日付・時刻を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 196 | * @bref 要素数6の配列に年、月、日、時間、分、秒の順に値を代入する |
Gaku0606 | 4:758f97bee95a | 197 | * @param (*_utc) float型 秒 アドレス |
Gaku0606 | 4:758f97bee95a | 198 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 4:758f97bee95a | 199 | * @detail 要素6の配列を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 200 | */ |
Gaku0606 | 4:758f97bee95a | 201 | inline bool getUTC(float *_utc){ |
Gaku0606 | 0:74d8e952a3bd | 202 | _utc[0] = (float)year; |
Gaku0606 | 0:74d8e952a3bd | 203 | _utc[1] = (float)month; |
Gaku0606 | 0:74d8e952a3bd | 204 | _utc[2] = (float)day; |
Gaku0606 | 0:74d8e952a3bd | 205 | _utc[3] = (float)hour; |
Gaku0606 | 0:74d8e952a3bd | 206 | _utc[4] = (float)minutes; |
Gaku0606 | 0:74d8e952a3bd | 207 | _utc[5] = seconds; |
Gaku0606 | 4:758f97bee95a | 208 | |
Gaku0606 | 4:758f97bee95a | 209 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 210 | else return false; |
Gaku0606 | 0:74d8e952a3bd | 211 | } |
Gaku0606 | 4:758f97bee95a | 212 | |
Gaku0606 | 5:15ff963f066b | 213 | /** 世界協定時間の日付・時刻を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 214 | * @bref 要素数6の配列に年、月、日、時間、分、秒の順に値を代入する |
Gaku0606 | 5:15ff963f066b | 215 | * @param _utc int型 秒 ポインタ |
Gaku0606 | 4:758f97bee95a | 216 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 5:15ff963f066b | 217 | * @note 要素6の配列を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 218 | */ |
Gaku0606 | 4:758f97bee95a | 219 | inline bool getUTC(int *_utc){ |
Gaku0606 | 0:74d8e952a3bd | 220 | _utc[0] = year; |
Gaku0606 | 0:74d8e952a3bd | 221 | _utc[1] = month; |
Gaku0606 | 0:74d8e952a3bd | 222 | _utc[2] = day; |
Gaku0606 | 0:74d8e952a3bd | 223 | _utc[3] = hour; |
Gaku0606 | 0:74d8e952a3bd | 224 | _utc[4] = minutes; |
Gaku0606 | 0:74d8e952a3bd | 225 | _utc[5] = (int)seconds; |
Gaku0606 | 4:758f97bee95a | 226 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 227 | else return false; |
Gaku0606 | 0:74d8e952a3bd | 228 | } |
Gaku0606 | 4:758f97bee95a | 229 | |
Gaku0606 | 5:15ff963f066b | 230 | /** 速度・進行方角を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 231 | * @bref 2つの変数に速度、進行方角の順に値を代入する |
Gaku0606 | 5:15ff963f066b | 232 | * @param _knot double型 経度 ポインタ [knot] |
Gaku0606 | 5:15ff963f066b | 233 | * @param _degree double型 緯度 ポインタ [degree] 北から右回り正です。 |
Gaku0606 | 4:758f97bee95a | 234 | * @return データが有効かどうか 有効ならtrue, 無効ならfalse |
Gaku0606 | 4:758f97bee95a | 235 | * @detail 2つ変数を作って、そのアドレスを引数に与えてください。 |
Gaku0606 | 4:758f97bee95a | 236 | */ |
Gaku0606 | 4:758f97bee95a | 237 | inline bool getSpeedVector(double *_knot, double *_degree){ |
Gaku0606 | 2:7be89bab6db9 | 238 | *_knot = knot; |
Gaku0606 | 2:7be89bab6db9 | 239 | *_degree = degree; |
Gaku0606 | 4:758f97bee95a | 240 | if(gps_readable) return true; |
Gaku0606 | 4:758f97bee95a | 241 | else return false; |
Gaku0606 | 2:7be89bab6db9 | 242 | } |
Gaku0606 | 4:758f97bee95a | 243 | |
Gaku0606 | 5:15ff963f066b | 244 | /** 捕捉衛星数を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 245 | * @bref 捕捉衛星数を返します。 |
Gaku0606 | 4:758f97bee95a | 246 | * @return int型 捕捉衛星数 アドレス |
Gaku0606 | 4:758f97bee95a | 247 | */ |
Gaku0606 | 2:7be89bab6db9 | 248 | inline int Number(){ |
Gaku0606 | 2:7be89bab6db9 | 249 | return number; |
Gaku0606 | 2:7be89bab6db9 | 250 | } |
Gaku0606 | 4:758f97bee95a | 251 | |
Gaku0606 | 5:15ff963f066b | 252 | /** 標高を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 253 | * @bref 標高を返します。 |
Gaku0606 | 4:758f97bee95a | 254 | * @return double型 標高 アドレス |
Gaku0606 | 4:758f97bee95a | 255 | */ |
Gaku0606 | 2:7be89bab6db9 | 256 | inline double Height(){ |
Gaku0606 | 2:7be89bab6db9 | 257 | return height; |
Gaku0606 | 2:7be89bab6db9 | 258 | } |
Gaku0606 | 4:758f97bee95a | 259 | |
Gaku0606 | 4:758f97bee95a | 260 | |
Gaku0606 | 5:15ff963f066b | 261 | /** 速さを取得できる関数 |
Gaku0606 | 5:15ff963f066b | 262 | * @bref 速さを返します。 |
Gaku0606 | 4:758f97bee95a | 263 | * @return double型 速さ アドレス[knot] |
Gaku0606 | 4:758f97bee95a | 264 | */ |
Gaku0606 | 2:7be89bab6db9 | 265 | inline double Knot(){ |
Gaku0606 | 2:7be89bab6db9 | 266 | return knot; |
Gaku0606 | 2:7be89bab6db9 | 267 | } |
Gaku0606 | 4:758f97bee95a | 268 | |
Gaku0606 | 4:758f97bee95a | 269 | |
Gaku0606 | 5:15ff963f066b | 270 | /** 進行方角を取得できる関数 |
Gaku0606 | 5:15ff963f066b | 271 | * @bref 進行方角を返します。 |
Gaku0606 | 4:758f97bee95a | 272 | * @return double型 進行方角 アドレス 北から右回り正です。 |
Gaku0606 | 4:758f97bee95a | 273 | */ |
Gaku0606 | 2:7be89bab6db9 | 274 | inline double Degree(){ |
Gaku0606 | 2:7be89bab6db9 | 275 | return degree; |
Gaku0606 | 2:7be89bab6db9 | 276 | } |
Gaku0606 | 0:74d8e952a3bd | 277 | }; |
Gaku0606 | 1:57eeee14dd31 | 278 | ///////////////// |
Gaku0606 | 1:57eeee14dd31 | 279 | /////sample////// |
Gaku0606 | 1:57eeee14dd31 | 280 | ///////////////// |
Gaku0606 | 1:57eeee14dd31 | 281 | /* |
Gaku0606 | 4:758f97bee95a | 282 | @code |
Gaku0606 | 1:57eeee14dd31 | 283 | #include "mbed.h" |
Gaku0606 | 1:57eeee14dd31 | 284 | #include "GPS_interrupt.h" |
Gaku0606 | 1:57eeee14dd31 | 285 | Serial pc(USBTX, USBRX); |
Gaku0606 | 1:57eeee14dd31 | 286 | RawSerial mygps(p9, p10); |
Gaku0606 | 0:74d8e952a3bd | 287 | |
Gaku0606 | 2:7be89bab6db9 | 288 | GPS_interrupt gps(&mygps, 115200, 10, 115200); |
Gaku0606 | 2:7be89bab6db9 | 289 | |
Gaku0606 | 2:7be89bab6db9 | 290 | void bootFunction(){//do not need |
Gaku0606 | 2:7be89bab6db9 | 291 | pc.printf("\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 292 | pc.printf("start LPC1768 boot phase\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 293 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 294 | for(int i = 0;i < 100;i++){ |
Gaku0606 | 2:7be89bab6db9 | 295 | pc.printf("Loading... : %3d [%%]\r", i); |
Gaku0606 | 2:7be89bab6db9 | 296 | wait(0.025); |
Gaku0606 | 2:7be89bab6db9 | 297 | } |
Gaku0606 | 2:7be89bab6db9 | 298 | pc.printf("Loading... : %3d [%%]\r\n", 100); |
Gaku0606 | 2:7be89bab6db9 | 299 | pc.printf("\t-> finished!!\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 300 | pc.printf("System : %d Hz\r\n", SystemCoreClock ); |
Gaku0606 | 2:7be89bab6db9 | 301 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 302 | pc.printf("start main program\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 303 | wait(0.1); |
Gaku0606 | 2:7be89bab6db9 | 304 | pc.printf("initialize"); |
Gaku0606 | 2:7be89bab6db9 | 305 | wait(0.75); |
Gaku0606 | 2:7be89bab6db9 | 306 | pc.printf(" -> OK\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 307 | wait(0.1); |
Gaku0606 | 2:7be89bab6db9 | 308 | pc.printf("GPS Connecting"); |
Gaku0606 | 2:7be89bab6db9 | 309 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 310 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 311 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 312 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 313 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 314 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 315 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 316 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 317 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 318 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 319 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 320 | pc.printf("."); |
Gaku0606 | 2:7be89bab6db9 | 321 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 322 | while(1){ |
Gaku0606 | 2:7be89bab6db9 | 323 | if(gps.gps_readable) break; |
Gaku0606 | 2:7be89bab6db9 | 324 | } |
Gaku0606 | 2:7be89bab6db9 | 325 | pc.printf(" -> OK\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 326 | pc.printf("start!!\r\n\r\n"); |
Gaku0606 | 2:7be89bab6db9 | 327 | wait(0.5); |
Gaku0606 | 2:7be89bab6db9 | 328 | } |
Gaku0606 | 1:57eeee14dd31 | 329 | |
Gaku0606 | 1:57eeee14dd31 | 330 | int main() { |
Gaku0606 | 1:57eeee14dd31 | 331 | |
Gaku0606 | 1:57eeee14dd31 | 332 | pc.baud(115200); |
Gaku0606 | 2:7be89bab6db9 | 333 | //mygps.baud(9600); |
Gaku0606 | 1:57eeee14dd31 | 334 | |
Gaku0606 | 2:7be89bab6db9 | 335 | bootFunction(); |
Gaku0606 | 1:57eeee14dd31 | 336 | |
Gaku0606 | 1:57eeee14dd31 | 337 | while(1){ |
Gaku0606 | 2:7be89bab6db9 | 338 | double xy[2] = {0}; |
Gaku0606 | 2:7be89bab6db9 | 339 | float utc[6] = {0}; |
Gaku0606 | 2:7be89bab6db9 | 340 | gps.getPosition(xy); |
Gaku0606 | 2:7be89bab6db9 | 341 | gps.getUTC(utc); |
Gaku0606 | 2:7be89bab6db9 | 342 | pc.printf("\033[K"); |
Gaku0606 | 2:7be89bab6db9 | 343 | pc.printf("%d/%d/%d %d:%d:%02.2f ",(int)utc[0],(int)utc[1], (int)utc[2], (int)utc[3], (int)utc[4] ,utc[5]); |
Gaku0606 | 2:7be89bab6db9 | 344 | pc.printf("(%3.7fe,%3.7fn) ",xy[0], xy[1]); |
Gaku0606 | 2:7be89bab6db9 | 345 | pc.printf("%d satellites, %.2f[m], %.3f[m/s], %3.2f[degree]\r", gps.Number(), gps.Height(), gps.Knot()*1852/3600, gps.Degree()); |
Gaku0606 | 2:7be89bab6db9 | 346 | wait(0.1); |
Gaku0606 | 1:57eeee14dd31 | 347 | } |
Gaku0606 | 1:57eeee14dd31 | 348 | } |
Gaku0606 | 4:758f97bee95a | 349 | @codeend |
Gaku0606 | 1:57eeee14dd31 | 350 | */ |
Gaku0606 | 0:74d8e952a3bd | 351 | #endif |