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

Files at this revision

API Documentation at this revision

Comitter:
mblokzijl
Date:
Sat Nov 26 13:41:01 2011 +0000
Child:
1:c97e837e48a6
Commit message:
publish

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Nov 26 13:41:01 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Sat Nov 26 13:41:01 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/USBDevice/#ef8c6751b185
--- /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;
+    }
+}