simple ecu reader

Dependencies:   FatFileSystem GPS-ecu TextLCD mbed

Fork of ecu_reader by Sukkin Pang

Files at this revision

API Documentation at this revision

Comitter:
nherriot
Date:
Tue Jul 23 13:32:24 2013 +0000
Parent:
5:46a6a3e36e05
Child:
7:61b712aa2771
Commit message:
Adding a 'home' menu

Changed in this revision

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
--- a/GPS.lib	Tue Aug 28 13:16:46 2012 +0000
+++ b/GPS.lib	Tue Jul 23 13:32:24 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/pangsk/code/GPS/#0f423a982334
+http://mbed.org/users/pangsk/code/GPS/#71e46131743f
--- a/main.cpp	Tue Aug 28 13:16:46 2012 +0000
+++ b/main.cpp	Tue Jul 23 13:32:24 2013 +0000
@@ -38,11 +38,15 @@
 Serial pc(USBTX, USBRX);
 
 
+
 ecu_reader obdii(CANSPEED_500);     //Create object and set CAN speed
+void can_demo(void);
 void gps_demo(void);
 void sd_demo(void);
+void home(void);                    // Function to set the screen on a home position
 
-int main() {
+int main() 
+{
     pc.baud(115200);
     char buffer[20];
     
@@ -53,36 +57,35 @@
     left.mode(PullUp);
     up.mode(PullUp);
     
-    printf("ECU Reader \n"); 
+    // Display splash screen
+    printf("Vodafone UBI Prototype \n"); 
     lcd.locate(0,0);                // Set LCD cursor position
-    lcd.printf("CAN-Bus demo");
-    
+    lcd.printf("Voda UBI Prototype");    
     lcd.locate(0,1);
-    lcd.printf("www.skpang.co.uk");
-       
-    pc.printf("\n\rCAN-bus demo...");
-    
+    lcd.printf("www.vodafone.com");      
+    // Wait and clear screen
     wait(3);
     lcd.cls();
-    lcd.printf("Use joystick");
 
-    lcd.locate(0,1);
-    lcd.printf("U-CAN:D-GPS:L-SD");
-    
-    pc.printf("\nU-CAN:D-GPS:L-SD");
+    // Call up the home menu
+    home();
+}
+
 
-    while(1)    // Wait until option is selected by the joystick
-    {
-   
-        if(down == 0) gps_demo();
-        if(left == 0) sd_demo();
-               
-        if(up == 0) break;
-        
-    }
+void can_demo(void)
+{
+    char buffer[20];
     lcd.cls();
+    pc.printf("\nVodafone CAN selelected:");
+    
+    lcd.locate(0,0);                // Set LCD cursor position
+    lcd.printf("Voda Car Connect");
+    lcd.locate(0,1);
+    lcd.printf("CAN bus selected");  
 
-    while(1) {  // Main CAN loop
+    while(1) 
+    {  // Main CAN loop
+        if(click == 0) home();
         led2 = 1;
         wait(0.1);
         led2 = 0;
@@ -114,35 +117,69 @@
         }   
        
     }
+
 }
 
+
+
+void home(void)
+{
+    pc.printf("\nVodafone Home Menu");
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Home - use joystick");
+    lcd.locate(0,1);
+    lcd.printf("to select option...");
+    wait(2);
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Use joystick");
+    lcd.locate(0,1);
+    lcd.printf("U-CAN:D-GPS:L-SD:P-Ho");   
+    pc.printf("\nUse the joystick to select an option - hold down the joystick to get back to home");
+    pc.printf("\nUp = CAN buss demo:Down = GPS demo:Left = SD demo: Press = Home");
+ 
+    while(1)    // Wait until option is selected by the joystick
+    {
+        
+        if(down == 0) gps_demo();
+        if(left == 0) sd_demo();
+        if(up == 0) can_demo();       
+    }
+  
+}
+
+
 void gps_demo(void)
 {
+    
     lcd.cls();
     lcd.printf("GPS demo");
     lcd.locate(0,1);
     lcd.printf("Waiting for lock");
- 
-    wait(3);    
-    lcd.cls();
-   
+    pc.printf("\nVodafone Ublox GPS initiated");
+    pc.printf("\nGPS Sampling starting....\n");   
+
     while(1)
     {
-      if(gps.sample()) {
-         lcd.cls();
+      if(click == 0) home();  
+      if(gps.sample()) 
+      {
+        lcd.cls();
         lcd.printf("Long:%f", gps.longitude);
-           lcd.locate(0,1);
+        lcd.locate(0,1);
         lcd.printf("Lat:%f", gps.latitude);
-            pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude);
-        } else {
-            pc.printf("Oh Dear! No lock :(\n");
-            lcd.cls();
-            lcd.printf("Waiting for lock");
-   
-        }
+        pc.printf("I'm at Latitude: %f, Longitude: %f\n", gps.latitude, gps.longitude);
+      } 
+      else 
+      {
+        pc.printf("Oh Dear! No lock :(\n");
+        lcd.cls();
+        lcd.printf("Waiting for lock");
+      }
     }
- 
-}
+
+} 
 
 void sd_demo(void)
 {
@@ -166,6 +203,7 @@
         
     while(1)
     {
+        if(click == 0) home();
         led2 = 1;
         wait(0.1);
         led2 = 0;