lab5-4

Dependencies:   4DGL-uLCD-SE mbed

Files at this revision

API Documentation at this revision

Comitter:
taoqiuyang
Date:
Sun Mar 27 20:54:14 2016 +0000
Commit message:
lab5-4

Changed in this revision

4DGL-uLCD-SE.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7679168f2d6e 4DGL-uLCD-SE.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Sun Mar 27 20:54:14 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
diff -r 000000000000 -r 7679168f2d6e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Mar 27 20:54:14 2016 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+
+Serial pc(USBTX, USBRX);
+uLCD_4DGL lcd(p13, p14, p15);
+AnalogIn ain(p20);
+
+
+char PC_message[256];
+int  PC_message_counter=0;
+int  PC_message_length=0;
+
+
+void setup_lcd(){
+    lcd.baudrate(3000000);
+    lcd.background_color(0);
+    lcd.cls();
+    lcd.printf("Initializing...");
+}
+
+
+void update_lcd(){
+    lcd.cls();
+    lcd.locate(0,0);
+    for(int i=0;i<PC_message_length;i++){
+        lcd.printf("%c",PC_message[i]);
+         wait(0.01);
+    }
+}
+
+
+void PC_serial_ISR() {
+    char buf;
+    
+     while (pc.readable()) {
+        buf = pc.getc();
+        
+        PC_message[PC_message_counter]=buf;
+        PC_message_counter+=1;
+        
+        if (buf=='\n'){
+            PC_message_length=PC_message_counter-1;
+            PC_message_counter=0; 
+            
+            update_lcd();
+        }   
+    }
+}
+
+
+int main() {
+    pc.baud(9600);
+    pc.attach(&PC_serial_ISR);
+    setup_lcd();
+   
+    while (1) {
+        pc.printf("%2.2f\n",ain.read()*1.0f);
+        wait(1);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 7679168f2d6e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Mar 27 20:54:14 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file