trying to make telnetserver repo public

Dependents:   Telnet_server

Fork of MODGPS by Andy K

Committer:
kamilion
Date:
Thu Nov 06 01:55:23 2014 +0000
Revision:
7:4cae89072f17
Parent:
0:db98027c0bbb
Child:
2:8aa059e7d8b1
trying to make repo public

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AjK 0:db98027c0bbb 1 #ifdef COMPILE_EXAMPLE_CODE_MODGPS
AjK 0:db98027c0bbb 2
AjK 0:db98027c0bbb 3 #include "mbed.h"
AjK 0:db98027c0bbb 4 #include "GPS.h"
AjK 0:db98027c0bbb 5
AjK 0:db98027c0bbb 6 Serial pc(USBTX, USBRX);
AjK 0:db98027c0bbb 7 DigitalOut led1(LED1);
AjK 0:db98027c0bbb 8 DigitalOut led2(LED2);
AjK 0:db98027c0bbb 9 DigitalOut led3(LED3);
AjK 0:db98027c0bbb 10 DigitalOut led4(LED4);
AjK 0:db98027c0bbb 11
AjK 0:db98027c0bbb 12 Timeout t2, t3, t4;
AjK 0:db98027c0bbb 13
AjK 0:db98027c0bbb 14 void t2out(void) { led2 = 0; }
AjK 0:db98027c0bbb 15 void t3out(void) { led3 = 0; }
AjK 0:db98027c0bbb 16 void t4out(void) { led4 = 0; }
AjK 0:db98027c0bbb 17
AjK 0:db98027c0bbb 18 void blip2(void) { led2 = 1; t2.attach(&t2out, 0.1); }
AjK 0:db98027c0bbb 19 void blip3(void) { led3 = 1; t3.attach(&t3out, 0.1); }
AjK 0:db98027c0bbb 20 void blip4(void) { led4 = 1; t4.attach(&t4out, 0.1); }
AjK 0:db98027c0bbb 21
AjK 0:db98027c0bbb 22 int main() {
AjK 0:db98027c0bbb 23 GPS *gps = new GPS(NC, p25);
AjK 0:db98027c0bbb 24 GPS_Time q1;
AjK 0:db98027c0bbb 25 GPS_Geodetic *geo;
AjK 0:db98027c0bbb 26
AjK 0:db98027c0bbb 27 pc.baud(115200);
AjK 0:db98027c0bbb 28
AjK 0:db98027c0bbb 29 gps->baud(9600);
AjK 0:db98027c0bbb 30 gps->format(8, Serial::None, 1);
AjK 0:db98027c0bbb 31
AjK 0:db98027c0bbb 32 gps->ppsAttach(p29, GPS::ppsFall);
AjK 0:db98027c0bbb 33
AjK 0:db98027c0bbb 34 gps->attach_pps(&blip2);
AjK 0:db98027c0bbb 35 gps->attach_gga(&blip3);
AjK 0:db98027c0bbb 36 gps->attach_rmc(&blip4);
AjK 0:db98027c0bbb 37
AjK 0:db98027c0bbb 38 while(1) {
AjK 0:db98027c0bbb 39 // Every 3 seconds, flip LED1 and print the basic GPS info.
AjK 0:db98027c0bbb 40 wait(3);
AjK 0:db98027c0bbb 41 flip1();
AjK 0:db98027c0bbb 42 pc.printf("Method 1. Lat = %.4f ", gps->latitude());
AjK 0:db98027c0bbb 43 pc.printf("Lon = %.4f ", gps->longitude());
AjK 0:db98027c0bbb 44 pc.printf("Alt = %.4f ", gps->altitude());
AjK 0:db98027c0bbb 45 gps->timeNow(&q1);
AjK 0:db98027c0bbb 46 pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n",
AjK 0:db98027c0bbb 47 q1.hour, q1.minute, q1.second, q1.day, q1.month, q1.year);
AjK 0:db98027c0bbb 48
AjK 0:db98027c0bbb 49 // Alternative method that does the same thing.
AjK 0:db98027c0bbb 50 geo = gps->geodetic();
AjK 0:db98027c0bbb 51 pc.printf("Method 2. Lat = %.4f ", geo->lat);
AjK 0:db98027c0bbb 52 pc.printf("Lon = %.4f ", geo->lon);
AjK 0:db98027c0bbb 53 pc.printf("Alt = %.4f ", geo->alt);
AjK 0:db98027c0bbb 54 delete(geo);
AjK 0:db98027c0bbb 55
AjK 0:db98027c0bbb 56 GPS_Time *q2 = gps->timeNow();
AjK 0:db98027c0bbb 57 pc.printf("%02d:%02d:%02d %02d/%02d/%04d\r\n\n",
AjK 0:db98027c0bbb 58 q2->hour, q2->minute, q2->second, q2->day, q2->month, q2->year);
AjK 0:db98027c0bbb 59 delete(q2);
AjK 0:db98027c0bbb 60 }
AjK 0:db98027c0bbb 61 }
AjK 0:db98027c0bbb 62
AjK 0:db98027c0bbb 63 #endif