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:
Sun Nov 02 18:26:37 2014 +0000
Parent:
10:ee58d712c7fb
Child:
19:2b14139fb19f
Commit message:
Fixed some letters

Changed in this revision

letters.h 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
matrix.cpp Show annotated file Show diff for this revision Revisions of this file
matrix.h Show annotated file Show diff for this revision Revisions of this file
--- a/letters.h	Sun Nov 02 18:15:48 2014 +0000
+++ b/letters.h	Sun Nov 02 18:26:37 2014 +0000
@@ -398,15 +398,15 @@
     1 1 0 0 0 0 0 0 0xC0
 };*/
 
-uint8_t letterk[8] = { 0x00, 0x00, 0x90, 0xA0, 0xC0, 0xA0, 0x90, 0x00};
+uint8_t letterk[8] = { 0x00, 0x00, 0x00, 0x90, 0xA0, 0xC0, 0xA0, 0x90};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 0 0 1 0 0 0 0 0x90
     1 0 1 0 0 0 0 0 0xA0
     1 1 0 0 0 0 0 0 0xC0
     1 0 1 0 0 0 0 0 0xA0
     1 0 0 1 0 0 0 0 0x90
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
 uint8_t letterl[8] = { 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80};
@@ -420,37 +420,37 @@
     1 0 0 0 0 0 0 0 0x80
 };*/
 
-uint8_t letterm[8] = { 0x00, 0x00, 0xF0, 0xA8, 0xA8, 0xA8, 0xA8, 0x00};
+uint8_t letterm[8] = { 0x00, 0x00, 0x00, 0xF0, 0xA8, 0xA8, 0xA8, 0xA8};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 1 1 1 0 0 0 0 0xF0
     1 0 1 0 1 0 0 0 0xA8
     1 0 1 0 1 0 0 0 0xA8
     1 0 1 0 1 0 0 0 0xA8
     1 0 1 0 1 0 0 0 0xA8
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t lettern[8] = { 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0x90, 0x00};
+uint8_t lettern[8] = { 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0x90};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 1 1 0 0 0 0 0 0xE0
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t lettero[8] = { 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x60, 0x00};
+uint8_t lettero[8] = { 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x60};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     0 1 1 0 0 0 0 0 0x60
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     0 1 1 0 0 0 0 0 0x60 
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
 uint8_t letterp[8] = { 0x00, 0x00, 0xE0, 0x90, 0x90, 0xE0, 0x80, 0x80};
@@ -508,31 +508,32 @@
     0 1 1 1 0 0 0 0 0x70
 };*/
 
-uint8_t letteru[8] = { 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x70, 0x00};
+uint8_t letteru[8] = { 0x00, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x70};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     0 1 1 1 0 0 0 0 0x70
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t letterv[8] = { 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00};
+uint8_t letterv[8] = { 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0x50, 0x20};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 0 0 0 1 0 0 0 0x88
     1 0 0 0 1 0 0 0 0x88
     1 0 0 0 1 0 0 0 0x88
     0 1 0 1 0 0 0 0 0x50
     0 0 1 0 0 0 0 0 0x20
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t letterw[8] = { 0x00, 0x00, 0x88, 0x88, 0xA8, 0xA8, 0x70, 0x00};
+uint8_t letterw[8] = { 0x00, 0x00, 0x00, 0x88, 0x88, 0xA8, 0xA8, 0x70};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 0 0 0 1 0 0 0 0x88
     1 0 0 0 1 0 0 0 0x88
     1 0 1 0 1 0 0 0 0xA8
@@ -541,37 +542,37 @@
     0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t letterx[8] = { 0x00, 0x00, 0x90, 0x90, 0x60, 0x90, 0x90, 0x00};
+uint8_t letterx[8] = { 0x00, 0x00, 0x00, 0x90, 0x90, 0x60, 0x90, 0x90};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     0 1 1 0 0 0 0 0 0x60
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t lettery[8] = { 0x00, 0x00, 0x90, 0x90, 0x70, 0x10, 0xE0, 0x00};
-  /*0 0 0 0 0 0 0 0 0x00
+uint8_t lettery[8] = { 0x00, 0x00, 0x00, 0x90, 0x90, 0x70, 0x10, 0xE0};
+  /*0 0 0 0 0 0 0 0 0x00    
+    0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
     1 0 0 1 0 0 0 0 0x90
     1 0 0 1 0 0 0 0 0x90
     0 1 1 1 0 0 0 0 0x70
     0 0 0 1 0 0 0 0 0x10
     1 1 1 0 0 0 0 0 0xE0
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
-uint8_t letterz[8] = { 0x00, 0x00, 0xF0, 0x20, 0x40, 0x80, 0xF0, 0x00};
+uint8_t letterz[8] = { 0x00, 0x00, 0x00, 0xF0, 0x20, 0x40, 0x80, 0xF0};
   /*0 0 0 0 0 0 0 0 0x00
     0 0 0 0 0 0 0 0 0x00
+    0 0 0 0 0 0 0 0 0x00
     1 1 1 1 0 0 0 0 0xF0
     0 0 1 0 0 0 0 0 0x20
     0 1 0 0 0 0 0 0 0x40
     1 0 0 0 0 0 0 0 0x80
     1 1 1 1 0 0 0 0 0xF0
-    0 0 0 0 0 0 0 0 0x00
 };*/
 
 uint8_t letterGap[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
--- a/main.cpp	Sun Nov 02 18:15:48 2014 +0000
+++ b/main.cpp	Sun Nov 02 18:26:37 2014 +0000
@@ -8,45 +8,21 @@
 DigitalOut led(LED1);
 Serial pc(USBTX, USBRX);
 Serial bluetooth(p28,p27);
-static char line[99], line_buffer[99];
-static bool mode_buffer = 0;
-static uint8_t interrupt_flag = 0;
-int realTime;
+char line[99];
 void receive();
 
 int main() {
-    static bool m_mode;
-    char buffer[4];
-    bool dot;
     pc.baud(115200);
     bluetooth.baud(38400);
-    void (*foo)() = &receive;
-    bluetooth.attach(foo, Serial::RxIrq);
-    generator.generate("ABCD");
+    bluetooth.attach(&receive, Serial::RxIrq);
+    generator.generate("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
     while(true){
-        /*if (interrupt_flag == 1){
-            m_mode = mode_buffer;
-            memcpy(line, line_buffer, sizeof(line_buffer));
-            interrupt_flag = 0;
-        }*/
-        pc.printf("\r\nMode = %i", m_mode);
-        if (strlen(line) > 0 && m_mode == 0){  
+        if (strlen(line) > 0){  
             led = 0;  
             generator.generate(line);
             memset(line, 0, sizeof(line));
         }
-        else if (strlen(line) > 0 && m_mode == 1){
-            led = 0;
-            memset(line, 0, sizeof(line));
-        }
-        if(m_mode == 1){
-            time_t seconds = time(NULL);
-            strftime(buffer, 4, "%H%M", localtime(&seconds)); 
-            if ((seconds % 2) == 0) dot = true;
-            else dot = false; 
-            display.clock(buffer, dot);
-        }
-        else display.show();
+        display.show();
     }
 }
 
@@ -55,22 +31,10 @@
     int i, j = 0;
     i = 10 * (bluetooth.getc() - 48);
     i += bluetooth.getc() - 48;
-    if(i > 0){
-        mode_buffer = false;
-        do{ 
-            line_buffer[j] = bluetooth.getc();
-            j++;
-            wait(0.0004);       
-        }
-        while(bluetooth.readable() && (j < i) && (j < 99));
+    do{ 
+        line[j] = bluetooth.getc();
+        j++;
+        wait(0.0004);       
     }
-    else{
-        pc.printf("\r\nClock mode");
-        mode_buffer = true;
-        bluetooth.gets(line, 10);
-        realTime = atoi(line_buffer);
-        set_time(realTime);
-        pc.printf("\r\nTime : %i Mode : %i", realTime, mode_buffer);
-    }  
-    interrupt_flag = 1; 
+    while(bluetooth.readable() && (j < i) && (j < 99));
 }
\ No newline at end of file
--- a/matrix.cpp	Sun Nov 02 18:15:48 2014 +0000
+++ b/matrix.cpp	Sun Nov 02 18:26:37 2014 +0000
@@ -20,7 +20,6 @@
     for (int i = 15; i < length; i++){
         for (int j = 0; j < 8; j++){
             multiplex();
-            clear();
         }
         for (int g = 0; g < 15; g++){
             for (int h = 0; h < 8; h++){
@@ -78,10 +77,6 @@
     }    
 }
 
-void matrix::clock(char *buffer, bool dot){
-    pc.printf("\r\nClock %s", buffer);
-};
-
 /*void led_thread(void const *args){
     while(true){
         multiplex();
--- a/matrix.h	Sun Nov 02 18:15:48 2014 +0000
+++ b/matrix.h	Sun Nov 02 18:26:37 2014 +0000
@@ -24,7 +24,6 @@
     void show();
     void clear();
     void multiplex();
-    void clock(char *buffer, bool dot);
 };    
 
 #endif /* matrix_H_ */
\ No newline at end of file