Test program for TM1638 LED controller. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.

Dependencies:   TM1638 mbed

See here for more information.

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Tue Jan 19 18:58:35 2016 +0000
Parent:
2:d6720abfe574
Child:
4:0e1ffa381c62
Commit message:
Animation demo

Changed in this revision

TM1638.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
--- a/TM1638.lib	Fri Jan 15 19:10:16 2016 +0000
+++ b/TM1638.lib	Tue Jan 19 18:58:35 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/wim/code/TM1638/#532ce15ea9ec
+https://developer.mbed.org/users/wim/code/TM1638/#25ddabfadc8c
--- a/main.cpp	Fri Jan 15 19:10:16 2016 +0000
+++ b/main.cpp	Tue Jan 19 18:58:35 2016 +0000
@@ -36,6 +36,31 @@
 TM1638::DisplayData_t hello_str = {C7_H,0x00, C7_E,0x00, C7_L,0x00, C7_L,0x00, C7_O,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
 TM1638::DisplayData_t bye_str   = {C7_B,0x00, C7_Y,0x00, C7_E,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
 
+TM1638::DisplayData_t animate[] = {
+                                    {S7_A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, S7_A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, S7_A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, S7_A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_A,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_A,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_A,0x00},
+                                                                                                            
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_B,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_C,0x00},
+
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_D,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_D,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_D,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, S7_D,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, 0x00,0x00, S7_D,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, 0x00,0x00, S7_D,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {0x00,0x00, S7_D,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {S7_D,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+
+                                    {S7_E,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                    {S7_F,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00},
+                                  };  
 // KeyData_t size is 3 bytes  
 TM1638::KeyData_t keydata; 
 
@@ -72,6 +97,12 @@
         if (keydata[LEDKEY8_SW1_IDX] == LEDKEY8_SW1_BIT) { //sw1  
           LEDKEY8.cls(); 
           LEDKEY8.writeData(all_str);
+
+          wait(0.5);          
+          for (int i=0; i<20; i++) {            
+            LEDKEY8.writeData(animate[i]);
+            wait(0.05);
+          }  
         }  
 
         if (keydata[LEDKEY8_SW2_IDX] == LEDKEY8_SW2_BIT) { //sw2  
@@ -104,8 +135,51 @@
 //          LEDKEY8.cls(); 
 //          LEDKEY8.writeData(mbed_str);
 
+
 #if(1)
 //test to show all chars
+          pc.printf("Show all Alpha chars\r\n");
+
+//                          01234567
+const char NATO[][9]  = { {"Alpha   "},
+                          {"Bravo   "},
+                          {"Charlie "},
+                          {"Delta   "},
+                          {"Echo    "},
+                          {"Foxtrot "},
+                          {"Golf    "},
+                          {"Hotel   "},
+                          {"India   "},
+                          {"Juliet  "},
+                          {"Kilo    "},
+                          {"Lima    "},
+                          {"Mike    "},
+                          {"November"},
+                          {"Oscar   "},
+                          {"Papa    "},
+                          {"Quebec  "},
+                          {"Romeo   "},
+                          {"Sierra  "},
+                          {"Tango   "},
+                          {"Uniform "},
+                          {"Victor  "},
+                          {"Wiskey  "},
+                          {"X-ray   "},
+                          {"Yankee  "},
+                          {"Zulu    "}
+                        };     
+
+          LEDKEY8.cls(); // clear all, preserve Icons
+          for (int i=0; i<26; i++) {
+            LEDKEY8.locate(0);
+            LEDKEY8.printf("%s", NATO[i]);
+            wait(0.5);
+          }  
+          pc.printf("Show all alpha chars done\r\n");
+#endif
+
+#if(0)
+//test to show all chars
           pc.printf("Show all alpha chars\r\n");
           wait(1);          
           LEDKEY8.cls(); 
@@ -118,7 +192,7 @@
           pc.printf("Show all alpha chars done\r\n");                    
 #endif            
 
-#if(1)
+#if(0)
 //test to show all chars
           pc.printf("Show all chars\r\n");
           wait(1);          
@@ -218,6 +292,17 @@
 
         if (keydata[LEDKEY8_SW5_IDX] == LEDKEY8_SW5_BIT) { //sw5  
           LEDKEY8.cls(); // clear all, preserve Icons
+
+#if(0)
+          LEDKEY8.printf("Count");                            
+          for (int cnt=0; cnt<=0xFF; cnt++) {
+            LEDKEY8.locate(6);
+            LEDKEY8.printf("%02x", cnt);
+            wait(0.2);
+          }  
+#endif
+
+
 //          LEDKEY8.writeData(hello_str);
           LEDKEY8.printf("hello");                  
         }