Akizuki 32x16 dot LED Matrix unit (K-03735) control library.
秋月電子の32×16ドットLEDマトリクス表示装置(K-03735)を制御するライブラリです。
バッファの内容をそのままLEDマトリクス装置に送ります。
LEDマトリクス表示装置は最大4台まで接続できるので、接続台数を必ず指定してください。(この台数でバッファのサイズを計算しています。)
行間表示は1msのdelayを入れています。パラメタで変更可能です。
このライブラリの呼び出し元は基本的にwhile()でループしてください。
初めてのライブラリなのでメンバ関数もドキュメントとかまだ最低限です。
おかしなところはぜひコメントをください。
表示例は以下ページをご覧ください。
Diff: akiledmatrix.cpp
- Revision:
- 7:2daedb892e15
- Parent:
- 6:141717976896
- Child:
- 9:988d937735e0
--- a/akiledmatrix.cpp Sun Jun 09 05:58:08 2013 +0000 +++ b/akiledmatrix.cpp Sun Jun 09 12:23:33 2013 +0000 @@ -7,7 +7,7 @@ PinName clock, PinName latch, PinName strobe, - const int ledunit, + const int rowsize, const int delay, const int shift_count_init) : _sin1(sin1), @@ -16,7 +16,7 @@ _clock(clock), _latch(latch), _strobe(strobe), - _ledunit(ledunit), + _rowsize(rowsize), _delay(delay), _shift_count_init(shift_count_init) { // initrize @@ -30,7 +30,7 @@ } // -// bit shift array[buf_xsize] +// bit shift array[buf_rowsize] // void AkiLedMatrix::bitshift(unsigned char *array, int xsize){ int top_bit = 0, work_bit = 0; @@ -62,14 +62,11 @@ } void AkiLedMatrix::display(unsigned char *buffer) { - DigitalOut myled4(LED4); - - int bufp = 0; // buffer pointer - - for (int y = 0; y < 16; y++){ - for (int ledno = (_ledunit - 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 y = 0; y < 16; y++){ + int bufp = y * 80 * 2; // buffer pointer + for (int ledno = 3; ledno >= 0; ledno--){ + uint16_t led1_data = buffer[bufp + ledno * 4] << 8 | buffer[bufp + ledno * 4 + 1]; + uint16_t led2_data = buffer[bufp + ledno * 4 + 2] << 8 | buffer[bufp + ledno * 4 + 3]; for (int x = 0; x < 16; x++){ if (x == y){ @@ -101,24 +98,15 @@ _latch = 1; wait_us(_delay); - - bufp = bufp + (_ledunit * 4); // shift check if (shift_count-- == 0){ - bitshift(buffer, _ledunit * 4); + bitshift(buffer, _rowsize); shift_count = _shift_count_init; - - // blink LED4 - if (myled4 == 1) { - myled4 = 0; - } else { - myled4 = 1; - } } } } -int AkiLedMatrix::getLedunit(){ - return _ledunit; +int AkiLedMatrix::getrowsize(){ + return _rowsize; }