Akizuki 32x16 dot LED Matrix unit (K-03735) control library.

秋月電子の32×16ドットLEDマトリクス表示装置(K-03735)を制御するライブラリです。
バッファの内容をそのままLEDマトリクス装置に送ります。
LEDマトリクス表示装置は最大4台まで接続できるので、接続台数を必ず指定してください。(この台数でバッファのサイズを計算しています。)
行間表示は1msのdelayを入れています。パラメタで変更可能です。
このライブラリの呼び出し元は基本的にwhile()でループしてください。
初めてのライブラリなのでメンバ関数もドキュメントとかまだ最低限です。
おかしなところはぜひコメントをください。

表示例は以下ページをご覧ください。

Files at this revision

API Documentation at this revision

Comitter:
kanpapa
Date:
Mon Jun 03 15:45:48 2013 +0000
Parent:
1:2705be49d5e2
Child:
3:532c50dc800e
Commit message:
bug fix. 2 LED unit.

Changed in this revision

akiledmatrix.cpp Show annotated file Show diff for this revision Revisions of this file
akiledmatrix.h Show annotated file Show diff for this revision Revisions of this file
--- a/akiledmatrix.cpp	Sun Feb 17 14:38:20 2013 +0000
+++ b/akiledmatrix.cpp	Mon Jun 03 15:45:48 2013 +0000
@@ -7,7 +7,7 @@
                  PinName clock,
                  PinName latch,
                  PinName strobe,
-                 const unsigned int maxledunit) :
+                 int maxledunit) :
                  _sin1(sin1),
                  _sin2(sin2),
                  _sin3(sin3),
@@ -25,36 +25,37 @@
                  _maxledunit = 1; // The number of LED units. (default 1 unit)
 }
  
-void AkiLedMatrix::display(const unsigned char *buffer, const unsigned int delay) {
+void AkiLedMatrix::display(const unsigned char *buffer, int delay) {
     int bufp = 0;   // buffer pointer
     
     for (int y = 0; y < 16; y++){
-        uint16_t led1_data = buffer[bufp + 0] * 256 + buffer[bufp + 1];
-        uint16_t led2_data = buffer[bufp + 2] * 256 + buffer[bufp + 3];
+         for (int ledno = (_maxledunit - 1); ledno >= 0; ledno--){
+            uint16_t led1_data = buffer[ledno * 4 + bufp + 0] * 256 + buffer[ledno * 4 + bufp + 1];
+            uint16_t led2_data = buffer[ledno * 4 + bufp + 2] * 256 + buffer[ledno * 4 + bufp + 3];
 
-        for (int x = 0; x < 16; x++){
-            if (x == y){
-                _sin1 = 1;
-            } else {
-                _sin1 = 0;
-            }
+            for (int x = 0; x < 16; x++){
+                if (x == y){
+                    _sin1 = 1;
+                } else {
+                    _sin1 = 0;
+                }
                 
-            // LED1
-            _sin2 = led1_data & 0x01;
-            led1_data = led1_data >> 1;
+                // LED1
+                _sin2 = led1_data & 0x01;
+                led1_data = led1_data >> 1;
                 
-            // LED2
-            _sin3 = led2_data & 0x01;
-            led2_data = led2_data >> 1;
+                // LED2
+                _sin3 = led2_data & 0x01;
+                led2_data = led2_data >> 1;
 
-            wait_us(2);         // tSETUP min:1.2us
+                wait_us(2);         // tSETUP min:1.2us
                 
-            // set clock
-            _clock = 1;
-            wait_us(1);         // twCLK min:1.0us
-            _clock = 0;
+                // set clock
+                _clock = 1;
+                wait_us(1);         // twCLK min:1.0us
+                _clock = 0;
+            }
         }
-
         // set latch
         _latch = 0;
         wait_us(2);             // twLAT min:2.0us
@@ -62,8 +63,8 @@
             
         wait_us(delay);
 
-        bufp = bufp + 4;
-        if (bufp > (_maxledunit * 16 * 16)) {
+        bufp = bufp + (_maxledunit * 4);
+        if (bufp > (_maxledunit * 64)) {
             bufp = 0;
         }
     }
--- a/akiledmatrix.h	Sun Feb 17 14:38:20 2013 +0000
+++ b/akiledmatrix.h	Mon Jun 03 15:45:48 2013 +0000
@@ -70,7 +70,7 @@
                  PinName clock,
                  PinName latch,
                  PinName strobe,
-                 const unsigned int maxledunit);
+                 int maxledunit);
                                   
      /** Displays the contents of the buffer
       *
@@ -79,11 +79,11 @@
       * @returns
       *        void
       */
-     void display(const unsigned char *buffer, const unsigned int delay = 1000);
+     void display(const unsigned char *buffer, int delay = 1000);
  
 private:
     DigitalOut _sin1,_sin2,_sin3,_clock,_latch,_strobe;
-    unsigned int _maxledunit;
+    int _maxledunit;
 };
  
 #endif
\ No newline at end of file