Akizuki 32x16 dot LED Matrix unit (K-03735) control library.
秋月電子の32×16ドットLEDマトリクス表示装置(K-03735)を制御するライブラリです。
バッファの内容をそのままLEDマトリクス装置に送ります。
LEDマトリクス表示装置は最大4台まで接続できるので、接続台数を必ず指定してください。(この台数でバッファのサイズを計算しています。)
行間表示は1msのdelayを入れています。パラメタで変更可能です。
このライブラリの呼び出し元は基本的にwhile()でループしてください。
初めてのライブラリなのでメンバ関数もドキュメントとかまだ最低限です。
おかしなところはぜひコメントをください。
表示例は以下ページをご覧ください。
Revision 12:4e85b39e922b, committed 2013-06-09
- Comitter:
- kanpapa
- Date:
- Sun Jun 09 14:00:10 2013 +0000
- Parent:
- 9:988d937735e0
- Commit message:
- bugfix. add ledunit param.
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 Jun 09 12:57:36 2013 +0000 +++ b/akiledmatrix.cpp Sun Jun 09 14:00:10 2013 +0000 @@ -7,6 +7,7 @@ PinName clock, PinName latch, PinName strobe, + const int ledunit, const int rowsize, const int delay, const int shift_count_init) : @@ -16,6 +17,7 @@ _clock(clock), _latch(latch), _strobe(strobe), + _ledunit(ledunit), _rowsize(rowsize), _delay(delay), _shift_count_init(shift_count_init) { @@ -64,7 +66,7 @@ void AkiLedMatrix::display(unsigned char *buffer) { for (int y = 0; y < 16; y++){ int bufp = y * _rowsize; // buffer pointer - for (int ledno = 3; ledno >= 0; ledno--){ + for (int ledno = (_ledunit - 1); 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]; @@ -100,9 +102,11 @@ wait_us(_delay); // shift check - if (shift_count-- == 0){ - bitshift(buffer, _rowsize); - shift_count = _shift_count_init; + if (_shift_count_init != 0){ + if (shift_count-- == 0){ + bitshift(buffer, _rowsize); + shift_count = _shift_count_init; + } } } } @@ -110,3 +114,7 @@ int AkiLedMatrix::getrowsize(){ return _rowsize; } + +int AkiLedMatrix::getledunit(){ + return _ledunit; +}
--- a/akiledmatrix.h Sun Jun 09 12:57:36 2013 +0000 +++ b/akiledmatrix.h Sun Jun 09 14:00:10 2013 +0000 @@ -24,11 +24,12 @@ * // 9 GND * // 10 GND * - * // rowsize = 4 - * // dynamic_delay = 1000 - * // scroll_delay = 50 + * // ledunit = 1 units + * // rowsize = 4 bytes + * // dynamic_delay = 1000 us + * // scroll_delay = 50 count * - * AkiLedMatrix ledmatrix(p5, p6, p7, p8, p9, p10, 4, 1000, 50); + * AkiLedMatrix ledmatrix(p5, p6, p7, p8, p9, p10, 1, 4, 1000, 50); * * int main() { * const unsigned char buf[] = { @@ -65,9 +66,10 @@ * @param clock CLOCK IN * @param latch LATCH IN * @param strobe STROBE IN + * @param ledunit Number of LED units * @param rowsize LED buffer row size * @param delay Dynamic display delay in microseconds - * @param shift_count_init scroll timing + * @param shift_count_init scroll timing. if 0 is No scroll. */ AkiLedMatrix(PinName sin1, PinName sin2, @@ -75,6 +77,7 @@ PinName clock, PinName latch, PinName strobe, + const int ledunit, const int rowsize, const int delay, const int shift_count_init); @@ -87,6 +90,15 @@ */ void display(unsigned char *buffer); + /** Get number of LED units connecting + * + * @param + * void + * @returns + * number of LED units + */ + int getledunit(); + /** Get LED buffer row size * * @param @@ -108,6 +120,7 @@ void bitshift(unsigned char *array, int xsize); DigitalOut _sin1,_sin2,_sin3,_clock,_latch,_strobe; + const int _ledunit; const int _rowsize; const int _delay; const int _shift_count_init;