tracker with usb

Dependencies:   C12832_lcd CMPS03 FatFileSystemCpp GPS_copy mbed

Fork of MSCUsbHost by Igor Skochinsky

Files at this revision

API Documentation at this revision

Comitter:
Noah_Newsom
Date:
Sat Mar 10 12:17:10 2018 +0000
Parent:
3:95e55809ecdb
Commit message:
tracker with usb

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
CMPS03.lib Show annotated file Show diff for this revision Revisions of this file
GPS.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 95e55809ecdb -r 6c258ed4635e C12832_lcd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Sat Mar 10 12:17:10 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dreschpe/code/C12832_lcd/#8f86576007d6
diff -r 95e55809ecdb -r 6c258ed4635e CMPS03.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMPS03.lib	Sat Mar 10 12:17:10 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/CMPS03/#c6bcc390612a
diff -r 95e55809ecdb -r 6c258ed4635e GPS.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GPS.lib	Sat Mar 10 12:17:10 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Noah_Newsom/code/GPS_copy/#e239db2b266d
diff -r 95e55809ecdb -r 6c258ed4635e main.cpp
--- a/main.cpp	Mon Jul 30 13:49:56 2012 +0000
+++ b/main.cpp	Sat Mar 10 12:17:10 2018 +0000
@@ -1,69 +1,54 @@
 #include "mbed.h"
+#include "CMPS03.h"
+#include "GPS.h"
+#include "C12832_lcd.h"
 #include "MSCFileSystem.h"
-//#include <stat.h>
-
 #define FSNAME "msc"
+C12832_LCD lcd;// Local name for the LCD
 MSCFileSystem msc(FSNAME);
+Serial pc(USBTX, USBRX);
+GPS gps(p9, p10);
+CMPS03 compass(p28, p27, CMPS03_DEFAULT_I2C_ADDRESS);
 
-int main()
-{
-	DIR *d;
-	struct dirent *p;
-	//struct stat st;
-	//char path[PATH_MAX];
-    
-    printf("\n\n================================\n");
-    printf("USB Mass storage demo program for mbed LPC1768\n");
-    printf("================================\n\n");
-    
-	d = opendir("/" FSNAME);
+int lock = 0;
+int main() {
+    DIR *d;
+    struct dirent *p;
+    d = opendir("/" FSNAME);
     
-    printf("\nList of files on the flash drive:\n");
-    if ( d != NULL )
-    {
-        while ( (p = readdir(d)) != NULL )
-        {
-        	printf(" - %s\n", p->d_name);
-        	/* no <stat.h> on mbed, it seems :/
-        	sprintf(path, "/"FSNAME"/%s", p->d_name);
-        	if ( stat(path, &st) == 0 )
-        	{
-        	  if ( S_ISDIR(st.st_mode) )
-        	    printf(" <directory>\n");
-        	  else
-        	    printf(" %d\n", st.st_size);
-        	}
-        	else
-        	{
-        	  printf(" ???\n");
-        	}*/
+    lcd.cls();
+    lcd.locate(1,0); 
+    lcd.printf("GPS Tester");
+    lcd.locate(1,11);
+    lcd.printf("Connect GPS to pins 9 & 10");  
+    gps.Init();
+    gps.parseData();
+    while(1) {
+        if(gps.parseData()) {
+            FILE *fp = fopen( "/" FSNAME "/Tracker_data.txt", "w");
+            lcd.cls();
+            lcd.locate(1,0);
+            lcd.printf("%f, %f, %d\n", gps.latitude, gps.longitude, gps.hours);
+            lcd.locate(1,11);
+            lcd.printf("%02d:%02d:%02.0f Bearing is: %f\n", 
+                gps.hours, gps.minutes, gps.seconds, 
+                (compass.readBearing() / 10.0));
+            lcd.locate(1,22);
+            lcd.printf("Satellites: %02d\n", gps.satellites);
+            lcd.invert(0);
+            fprintf(fp, "%f %f %f %02d:%02d:%02.0f\n ", gps.latitude, gps.longitude,(compass.readBearing() / 10.0),gps.hours, gps.minutes, gps.seconds);
+            fclose(fp); 
+        } else {
+            lcd.cls();//clear LCD for next reading round
+            lcd.locate(1,0);
+            lcd.printf("No satellite lock\n");
+            lcd.locate(1,11);
+            lcd.printf("%02d:%02d:%02.0f %02d/%02d/%02d\n", 
+                gps.hours, gps.minutes, gps.seconds, 
+                gps.day, gps.month, gps.year);
+            lcd.locate(1,22);
+            lcd.printf("Satellites: %02d\n",gps.satellites);
+            lcd.invert(0);
         }
     }
-    else
-    {
-    	error("Could not open directory!");
-    }
-    printf("\nTesting file write:\n");
-    FILE *fp = fopen( "/" FSNAME "/msctest.txt", "w");
-    if ( fp == NULL )
-    {
-        error("Could not open file for write\n");
-    }
-    fprintf(fp, "Hello mass storage!");
-    fclose(fp); 
-    printf("\n - OK\n");
-
-    printf("\nTesting file read:\n");
-    fp = fopen( "/" FSNAME "/msctest.txt", "r");
-    if ( fp == NULL )
-    {
-        error("Could not open file for read\n");
-    }
-    char buf[256];
-    if ( NULL == fgets(buf, sizeof(buf), fp) )
-    {
-        error("Error reading from file\n");
-    }
-    fclose(fp); 
-    printf("\n - OK, read string: '%s'\n\n", buf);
-}
+}
\ No newline at end of file