Dependencies:   SLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
scohennm
Date:
Thu Mar 05 03:33:01 2015 +0000
Commit message:
Use ISR instead of checking char buffer

Changed in this revision

SLCD.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
serialO_v2.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 60b70ac7ed38 SLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD.lib	Thu Mar 05 03:33:01 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
diff -r 000000000000 -r 60b70ac7ed38 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 05 03:33:01 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file
diff -r 000000000000 -r 60b70ac7ed38 serialO_v2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/serialO_v2.cpp	Thu Mar 05 03:33:01 2015 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+#include "SLCD.h"
+
+#define LCDLEN      10
+#define MAXCHAR     4
+#define LEDBLINKTIME 0.2f
+
+
+DigitalOut rLed(LED_RED);
+
+ 
+Serial pc(USBTX, USBRX); // tx, rx
+SLCD slcd; //define LCD display
+char rxChar;
+int charIndex = 0;
+char rxString[LCDLEN];
+bool charReady = false;
+
+// set up intterupt for serial port
+
+void serialISR(){
+  rxChar = pc.getc();   // reading clears the buffer
+  pc.printf("%c\n\r", rxChar);
+  rxString[charIndex] = rxChar;
+  charIndex = (charIndex + 1 )% MAXCHAR;
+  charReady = true;
+  return;
+}
+
+void LCDMessNoDwell(char *lMess){
+        slcd.Home();
+        slcd.clear();
+        slcd.printf(lMess);
+}
+
+
+int main()
+{  
+ // set up interrupt   
+    pc.attach(&serialISR);
+    
+    while (true) {     
+        rLed = !rLed; // toggle led
+        if (charReady) {
+            LCDMessNoDwell(rxString);
+            charReady = false;
+        }
+        wait(LEDBLINKTIME);
+    }
+}
\ No newline at end of file