This project is about creating an airplane instrument (such as an altimeter) for a flight simulator running on a PC. The code will read in two space-separated \"words\" containing the altitude and airspeed, with units, from a \"USBSerial port\". See my notebook page for details.

Dependencies:   TextLCD

Revision:
0:a2ecd3b777ac
Child:
1:c97e837e48a6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 26 13:41:01 2011 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "USBSerial.h"
+#include "TextLCD.h"
+
+//an LED to display activity
+DigitalOut serial_activity_led(LED2);
+//Virtual serial port over USB
+USBSerial serial;
+//The TextLCD
+TextLCD lcd(p21, p22, p17, p18, p19, p20); // rs, e, d4-d7
+
+int main() {
+    //initialise the LCD
+    lcd.printf("FlightSimInstru\nready!");
+    
+    //setup some buffers - using ints crashed my mbed, not sure why
+    uint8_t ias[128];
+    uint8_t alt[128];
+    //clear them
+    memset(ias,0,sizeof(ias)*sizeof(*ias));
+    memset(alt,0,sizeof(alt)*sizeof(*alt));
+    
+    //toggle an LED to show us, that the mbed is alive.
+    while(1) {
+        //read two space separated strings
+        serial.scanf("%s %s", ias, alt);
+        //write them on the LCD
+        lcd.cls();
+        lcd.printf("Speed: %s\nAlt: %s", ias, alt);
+        //toggle activity LED
+        serial_activity_led = !serial_activity_led;
+    }
+}