2018/06/18
Diff: GPS.h
- Revision:
- 0:2c0d50143d85
- Child:
- 1:2f131675f872
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GPS.h Thu May 03 14:19:36 2018 +0000 @@ -0,0 +1,89 @@ +/* + + GYSFDMAXB(GPS受信機1pps出力付きみちびき対応)用ライブラリ + written by ST + 他の処理と並行するなら割り込み処理を使用すべし + ex:NVIC_SetPriority(UART2_IRQn,0); //0の部分で優先順位を決定 + readable == true のとき正しいデータが出力 + + ※経度、緯度、時間の読み方 + lon,lat:ddmm.mmmm + dd:度 + mm.mmmm:分(上一桁:10分、下一桁:1/10000分) + + time:hhmmss.000000 + hh.時 + mm.分 + ss.秒 + + ※機能 + ・GPS(TX,RX); コンストラクタ、ピン宣言 + ・GPS::attach(関数名); 割り込み処理設定 + ・GPS::GetDefault(); 編集前データ出力(char) + ・gps.ExtractionData(); 編集データ出力(float gps.longtitude, float gps.latitude, float gps.timedefault) + ・gps.ExtractionData_FULL(); 編集データ出力(書式は下記のサンプルプログラム参照) + + @code + //---------------------------------------------------------------------------------------------------------------------------------------------------------- + //sample program(TERA TERMに出力) + //---------------------------------------------------------------------------------------------------------------------------------------------------------- +#include "mbed.h" +#include "GPS.h" + +GPS gps(p28,p27); //(tx,rx) +Serial pc(USBTX, USBRX); + +void getGPS(){ + //NVIC_SetPriority(UART2_IRQn,0); //割り込み優先順位(必要に応じて) + gps.ExtractionData_FULL(); //データ抽出 + if(gps.readable == true){ + //pc.printf("longtitude:%f latitude:%f time:%f\r\n", gps.longtitude, gps.latitude, gps.time); //gps.ExtractionData(); 書き込み(経度、緯度、時間) + } +} + +int main(){ + gps.attach(getGPS); //割り込み(関数名) + while(1){ + //gps.GetDefault(); //元のデータ + //pc.printf("%c",gps.datadefault); //書き込み + } +} +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + @endcode + +*/ + +#ifndef GPS_H +#define GPS_H + +#include "mbed.h" + +#define GPSBAUD 9600//GPSのボーレート +#define ODR 10//max 10Hz 更新周期 + +class GPS { + public: + GPS(PinName gpstx,PinName gpsrx); + + bool readable; + char datadefault; + char *longtitudeFULL, *latitudeFULL, *timeFULL, *altitudeFULL; + float longtitude, latitude, time, altitude, times; + + void GPS::attach(void(*fn)()); + void GetDefault(); + void ExtractionData(); + void ExtractionData_FULL(); + + private: + Serial serial; + bool reasonable; + char buf[100]; + int Degrees, Minutes, Hours, m; + float fDegrees, fMinutes, Seconds, fHours; + void gpscmd(char *command); + void getstring(char DATA[]); + void Initialization(); +}; + +#endif \ No newline at end of file