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:
- 11:392395419b14
- Parent:
- 10:9ce938cdeb33
--- a/akiledmatrix.cpp Sun Jun 02 16:59:52 2013 +0000 +++ b/akiledmatrix.cpp Mon Jun 03 15:11:30 2013 +0000 @@ -6,13 +6,16 @@ PinName sin3, PinName clock, PinName latch, - PinName strobe) : + PinName strobe, + int maxledunit) : _sin1(sin1), _sin2(sin2), _sin3(sin3), _clock(clock), _latch(latch), - _strobe(strobe) { + _strobe(strobe), + _maxledunit(maxledunit) { + // initrize _sin1 = 0; _sin2 = 0; @@ -20,13 +23,14 @@ _clock = 0; _latch = 1; _strobe = 0; // LED ON + // _maxledunit = 1; } -void AkiLedMatrix::display(const unsigned char *buffer, const unsigned int delay = 1000, const unsigned int ledunit = 1) { +void AkiLedMatrix::display(unsigned char *buffer, int delay) { int bufp = 0; // buffer pointer for (int y = 0; y < 16; y++){ - for (int ledno = ( ledunit - 1 ) ; ledno >= 0; ledno--){ + 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]; @@ -60,8 +64,8 @@ wait_us(delay); - bufp = bufp + (ledunit * 4); - if (bufp > (ledunit * 64)) { + bufp = bufp + (_maxledunit * 4); + if (bufp > (_maxledunit * 64)) { bufp = 0; } }