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

Files at this revision

API Documentation at this revision

Comitter:
DaniusKalv
Date:
Thu Oct 30 23:12:18 2014 +0000
Parent:
5:76dd6da3e640
Child:
7:ca5ed7936472
Commit message:
Added X and Y letters, fixed bluetooth with interrupt integration. Up to 99 chars

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
matrix.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
text.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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
--- a/matrix.cpp	Wed Jul 30 10:28:47 2014 +0000
+++ b/matrix.cpp	Thu Oct 30 23:12:18 2014 +0000
@@ -1,6 +1,6 @@
 #include "matrix.h"
 #include "mbed.h"
-#include "rtos.h"
+//#include "rtos.h"
 
 matrix::matrix(PinName _in1, PinName _in2, PinName _in3, PinName _clr, 
 PinName _clr1, PinName _clk, PinName _clk1): local("local"), in1(_in1), in2(_in2), 
--- a/mbed-rtos.lib	Wed Jul 30 10:28:47 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#ac8d036315ed
--- a/text.cpp	Wed Jul 30 10:28:47 2014 +0000
+++ b/text.cpp	Thu Oct 30 23:12:18 2014 +0000
@@ -6,6 +6,7 @@
 
 void text::generate(string input){
     stringLength = input.length();
+    if (stringLength == 0) return;
     pc.printf("\r\nStarting generation, string length: %i", stringLength);
     fp = fopen("/local/out.txt", "w");
     pc.printf("\r\nOpened a text file out.txt");
@@ -360,6 +361,34 @@
             };
             memcpy(temp, w, sizeof(w));
             break;
+        case 'Y':
+            letSize = 5;
+            int y[8][8] = {
+                {1, 0, 0, 0, 1, 0, 0, 0},
+                {1, 0, 0, 0, 1, 0, 0, 0},
+                {0, 1, 0, 1, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+            };
+            memcpy(temp, y, sizeof(y));
+            break;
+        case 'X':
+            letSize = 5;
+            int x[8][8] = {
+                {1, 0, 0, 0, 1, 0, 0, 0},
+                {1, 0, 0, 0, 1, 0, 0, 0},
+                {0, 1, 0, 1, 0, 0, 0, 0},
+                {0, 0, 1, 0, 0, 0, 0, 0},
+                {0, 0, 0, 0, 0, 0, 0, 0},
+                {0, 1, 0, 1, 0, 0, 0, 0},
+                {1, 0, 0, 0, 1, 0, 0, 0},
+                {1, 0, 0, 0, 1, 0, 0, 0},
+            };
+            memcpy(temp, x, sizeof(x));
+            break;
         case ' ':
             letSize = 3;
             int gap[8][8] = {