Mbed library to get location informatiuon from GYSFDMAXB
Revision 5:6231c440275d, committed 2019-03-02
- Comitter:
- zeutel
- Date:
- Sat Mar 02 15:15:29 2019 +0000
- Parent:
- 4:2bd79a04305a
- Commit message:
- GPS
Changed in this revision
GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
GPS.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2bd79a04305a -r 6231c440275d GPS.cpp --- a/GPS.cpp Sun Jul 30 13:52:03 2017 +0000 +++ b/GPS.cpp Sat Mar 02 15:15:29 2019 +0000 @@ -4,7 +4,7 @@ GPS::GPS(PinName gpstx,PinName gpsrx): _gps(gpstx,gpsrx) { latitude=0; - longtitude=0; + longitude=0; gpscmd("314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"); int odr=ODR; @@ -26,7 +26,11 @@ _gps.baud(GPSBAUD); - _gps.attach(this,&GPS::getgps); + //_gps.attach(this,&GPS::getgps); +} + +GPS::~GPS() +{ } void GPS::gpscmd(char *command) @@ -75,7 +79,7 @@ //初期化 latitude=0; - longtitude=0; + longitude=0; //データ取得 for(counter=0;sample!='\n';counter++){ @@ -128,7 +132,7 @@ num=num*10; } - longtitude+=(float)num*(buf[counter]-48); + longitude+=(float)num*(buf[counter]-48); } minute=0; @@ -146,7 +150,7 @@ minute+=(float)num*(buf[counter]-48); } - longtitude+=minute/60; + longitude+=minute/60; result=true;
diff -r 2bd79a04305a -r 6231c440275d GPS.h --- a/GPS.h Sun Jul 30 13:52:03 2017 +0000 +++ b/GPS.h Sat Mar 02 15:15:29 2019 +0000 @@ -1,5 +1,6 @@ #ifndef GPS_H #define GPS_H +#include "mbed.h" @@ -22,18 +23,19 @@ #define GPSTX p28//GPSのTXピン #define GPSRX p27//GPSのRXピン -#define GPSBAUD 115200//GPSのボーレート +#define GPSBAUD 9600//GPSのボーレート #define ODR 10//max 10Hz 更新周期 class GPS { public: GPS(PinName gpstx,PinName gpsrx); + ~GPS(); void gpscmd(char *command); void getgps(); - float longtitude;//緯度 - float latitude;//経度 + float longitude;//経度 + float latitude;//緯度 //上の二つは自動的に更新される この二つを読むことでデータ取得が出来る bool result;//trueで成功、falseで失敗