tugboat project

Dependencies:   HMC5883L MMA8451Q PwmIn TinyGPS2 mbed

Fork of tugboat by brian claus

Revision:
2:db76adcdf799
Parent:
0:ee158c8007b4
Child:
4:7fb44cbc97a3
--- a/main.cpp	Mon Jul 29 23:00:34 2013 +0000
+++ b/main.cpp	Wed Jul 31 15:35:44 2013 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
 #include "MMA8451Q.h"
-#include "GPS.h"
+#include "TinyGPS.h"
 #include "HMC5883L.h"
  
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
@@ -11,27 +11,34 @@
 Serial pc(USBTX, USBRX);
 Serial radio(PTC4, PTC3);
 Timer t;
-GPS gps(PTD3,PTD2);
+TinyGPS gps;
+Serial gpsSerial(PTD3,PTD2);
+
+
+void gpsSerialRecvInterrupt (void);
 
 int main(void) {
 
     
     
     pc.baud(115200);
-    radio.baud(115200);
+    radio.baud(57600);
     int16_t dCompass[3];
     float dAcc[3];
     compass.init();
- 
+    pc.printf("inited\r\n");
+    gpsSerial.attach (&gpsSerialRecvInterrupt, gpsSerial.RxIrq);    // Recv interrupt handler
+    gps.reset_ready();
  
 
 
  
     while (true) {
         
-        if(gps.sample()){
-            pc.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude());
-            radio.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude());
+        if(gps.gga_ready()){
+           
+            pc.printf("lat: %.8f, lon: %.8f\r\n", gps.f_lat(), gps.f_lon());
+            radio.printf("lat: %.8f, lon: %.8f\r\n", gps.f_lat(), gps.f_lon());
         }
 
         acc.getAccAllAxis(dAcc);
@@ -42,4 +49,19 @@
         radio.printf("xC: %4d, yC: %4d, zC: %4d\r\n", dCompass[0], dCompass[1], dCompass[2]);
         wait(0.5);
     }
+}
+
+//*****************************************************************************
+//  serial receive interrupt handler
+//***************************************************************************** 
+
+void gpsSerialRecvInterrupt (void)
+{
+    
+
+   // while(gpsSerial.readable()){
+        gps.encode(gpsSerial.getc());  
+    //}
+
+
 }
\ No newline at end of file