Lingxuan Zeng / Mbed 2 deprecated masterboard

Files at this revision

API Documentation at this revision

Comitter:
zenglingxuan
Date:
Fri May 03 11:15:21 2013 +0000
Commit message:
masterboard of counting sitting time and typing time. typing wired. sitting wireless xbee. works.

Changed in this revision

TextLCD.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 ed2c77b37f59 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri May 03 11:15:21 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
diff -r 000000000000 -r ed2c77b37f59 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 03 11:15:21 2013 +0000
@@ -0,0 +1,100 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+Timer t;
+
+DigitalOut led1(LED_BLUE);
+DigitalOut led2(LED_RED);
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
+
+Serial wire(PTD3,PTD2);
+Serial xbee2(PTC4, PTC3);
+DigitalOut rst2(PTC5);
+
+
+
+int main()
+{
+
+    //initiating lcd and xbee reset
+
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("starting\n");
+    rst2 = 0;
+    wait_ms(1);
+    rst2 = 1;
+    wait_ms(1);
+
+
+    char alast = 0;
+    char a = 0;
+    
+    char typingflag;
+    
+    int typingtime;
+    
+    float timesitting;
+    
+    led1 = 1;
+    led2 = 1;
+    typingflag=0;
+    typingtime=0;
+      
+    
+    while(1) {
+        if (xbee2.readable() && wire.readable()) {
+                    
+            a = xbee2.getc();
+            lcd.putc(a);
+            lcd.locate(0,1);
+            lcd.printf("t=%f",t.read());
+            
+            typingflag=wire.getc();
+            lcd.locate(2,0);
+            lcd.printf("%d", (int) typingflag);
+            
+                if((int) typingflag == 1)
+                {
+                led1 = 0;
+                typingtime++;
+                wait(0.5);
+                }
+
+
+            if (a != alast) {
+                if (a == '1') {
+                    t.start();
+                    led1 = 0;
+                               } 
+                else {
+                    //  if (alast == 1) {
+
+                    t.stop();
+                    led2 = 0;
+                    timesitting = t.read();
+                    lcd.cls();
+                    lcd.locate(0,0);
+                    lcd.printf("%d", typingtime);
+                    lcd.locate(0,1);
+                    lcd.printf("%f",timesitting);
+                    
+                    
+                    t.reset();
+                    typingtime = 0;
+                    wait(3);
+                      } // terminate else
+                            } // terminate if (a != alast)
+
+            } // terminate if (xbee2.readable() && wire.readable())
+
+
+
+
+            alast = a;
+            wait(0.8);
+            lcd.cls();
+            led1 = 1;
+            led2 = 1;
+        }
+    }
diff -r 000000000000 -r ed2c77b37f59 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 03 11:15:21 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd
\ No newline at end of file