Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TimerExtended TinyGPS mbed
main.cpp
00001 /********************************** 00002 check: OK, ublox 5T 00003 **********************************/ 00004 #include "mbed.h" 00005 #include "TinyGPS.h" 00006 #include "TimerExtended.h" 00007 00008 TinyGPS gpsr; 00009 00010 // serial 00011 Serial serial_gps(p9, p10); // tx, rx 00012 Serial serial_pc(USBTX, USBRX); // tx, rx 00013 00014 Timer timer; 00015 TimerExtended timer2; 00016 TimerExtended timer3; 00017 00018 void setup() 00019 { 00020 timer.start(); 00021 timer2.start(); 00022 00023 serial_gps.baud(9600); 00024 serial_pc.baud(115200); 00025 00026 serial_pc.printf("hello\n"); 00027 wait(3.0); 00028 00029 timer3.start(); 00030 } 00031 00032 void loop() 00033 { 00034 if(serial_gps.readable()) 00035 { 00036 //serial_pc.printf("hoge\n"); 00037 char c = serial_gps.getc(); 00038 //serial_pc.putc(c); 00039 bool gps_avairable = gpsr.encode(c); 00040 if(gps_avairable) 00041 { 00042 //serial_pc.printf("fuga\n"); 00043 double lat, lon; 00044 unsigned long age; 00045 (void)gpsr.f_get_position(&lat, &lon, &age); 00046 00047 int year; 00048 byte month, day, hour, minute, second; 00049 (void)gpsr.crack_datetime(&year, &month, &day, &hour, &minute, &second); 00050 00051 double t = (double)timer.read_ms() / 1000.0; 00052 serial_pc.printf("%f, ", t); 00053 double t2 = (double)timer2.read_ms() / 1000.0; 00054 serial_pc.printf("%f, ", t2); 00055 double t3 = (double)timer3.read_ms() / 1000.0; 00056 serial_pc.printf("%f, ", t3); 00057 serial_pc.printf("%d-%02d-%02d %02d:%02d:%02d, ", year, month, day, hour, minute, second); 00058 serial_pc.printf("%f, %f\n", lat, lon); 00059 } 00060 } 00061 } 00062 00063 int main() { 00064 setup(); 00065 00066 while(1) 00067 { 00068 loop(); 00069 } 00070 }
Generated on Sun Jul 17 2022 01:45:41 by
1.7.2