![](/media/cache/profiles/7dcf06698a343e7d4985689898cb8491.jpg.50x50_q85.jpg)
Gestione GPS
Revision 0:79b375437cec, committed 2016-10-07
- Comitter:
- fdalforno
- Date:
- Fri Oct 07 19:16:22 2016 +0000
- Commit message:
- gestione gps
Changed in this revision
diff -r 000000000000 -r 79b375437cec TinyGPS.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TinyGPS.lib Fri Oct 07 19:16:22 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/dROb/code/TinyGPS/#44bee9056857
diff -r 000000000000 -r 79b375437cec main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 07 19:16:22 2016 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" +#include "TinyGPS.h" + +//------------------------------------ +// Hyperterminal configuration +// 9600 bauds, 8-bit data, no parity +//------------------------------------ + +Serial pc(SERIAL_TX, SERIAL_RX); +Serial gps(D8,D2); +DigitalOut myled(LED1); + +TinyGPS parser; + +float flat, flon, falt, fkmph; +unsigned long date,ltime; + +int main() { + gps.baud(9600); + pc.printf("Prova GPS !\n"); + while(1) { + /* + if(gps.readable()) { + pc.putc(gps.getc()); + } + */ + if(gps.readable()) { + if (parser.encode(gps.getc())){ + unsigned long fix_age; // returns +- latitude/longitude in degrees + parser.f_get_position(&flat, &flon, &fix_age); + + if (fix_age == TinyGPS::GPS_INVALID_AGE) + pc.printf("No fix detected \r\n"); + else if (fix_age > 5000) + pc.printf("Warning: possible stale data! \r\n"); + else + pc.printf("Data is current. \r\n"); + + parser.get_datetime(&date, <ime, &fix_age); + fkmph = parser.f_speed_kmph(); + + + pc.printf("Date: %d Time: %d lat: %f lon: %f speed: %f \r\n",date,ltime,flat,flon,fkmph); + } + } + } +} + \ No newline at end of file
diff -r 000000000000 -r 79b375437cec mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 07 19:16:22 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file