Blue LED matrix (8x16) program. Gets text string through bluetooth and displays it on led matrix. Also has a clock function- get system time from a phone through bluetooth and enters clock mode. In clock mode it acts as a clock showing hours and minutes and blinking led every second. Clock mode can be broken if a text string is received through bluetooth.

Dependencies:   mbed

Revision:
6:76b89d8b62a0
Parent:
5:76dd6da3e640
Child:
7:ca5ed7936472
--- a/main.cpp	Wed Jul 30 10:28:47 2014 +0000
+++ b/main.cpp	Thu Oct 30 23:12:18 2014 +0000
@@ -1,24 +1,40 @@
 #include "mbed.h"
 #include "matrix.h"
 #include "text.h"
-#include "rtos.h"
+#include <string>
 
 text generator;
 matrix display(p13, p12, p11, p14, p15, p17, p16);
+DigitalOut led(LED1);
 Serial pc(USBTX, USBRX);
 Serial bluetooth(p28,p27);
 char line[256];
+void receive();
 
 int main() {
+    pc.baud(115200);
     bluetooth.baud(38400);
-    generator.generate("LIAULIUS");
+    bluetooth.attach(&receive, Serial::RxIrq);
+    generator.generate("HELLO WORLD SAYS LED MATRIX");
     while(true){
-        if (bluetooth.readable()){
-            bluetooth.gets(line, 10);
-            pc.printf("\r\n%s", line);
+        if (strlen(line) > 0){  
+            led = 0;  
             generator.generate(line);
+            memset(line, 0, sizeof(line));
         }
         display.show();
     }
-    //matrix("WELCOME!");
+}
+
+void receive(){
+    led = 1;
+    int i, j = 0;
+    i = 10 * (bluetooth.getc() - 48);
+    i += bluetooth.getc() - 48;
+    do{ 
+        line[j] = bluetooth.getc();
+        j++;
+        wait(0.0004);       
+    }
+    while(bluetooth.readable() && (j < i));
 }
\ No newline at end of file