Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ws2801 by
a101.cpp
00001 #include "a101.h" 00002 #include "mbed.h" 00003 00004 int padding; 00005 00006 a101::a101(PinName CKI, PinName SDI, int ledLength, int tapeLength) : _CKI(CKI), _SDI(SDI), _ledLength(ledLength), _tapeLength(tapeLength) { 00007 clear(); 00008 } 00009 00010 void a101::post(int *strip_colors) { 00011 for (int i = 0; i < 32; i++) { 00012 padding0(); 00013 } 00014 00015 wait_us(RESET_DERAY); 00016 00017 for (int tapeNum = 0; tapeNum < _tapeLength; tapeNum++) { 00018 for(int ledNum = 0; ledNum < _ledLength; ledNum++) { 00019 operate(); 00020 for (int color = 0; color <= 2; color++) { 00021 int color_level = (strip_colors[tapeNum*24+ledNum] & (0xff << (8*color))) >> (8*color); 00022 for (int color_bit = 7; color_bit >= 0; color_bit--) { 00023 if (color_level & (1 << color_bit)) padding1(); 00024 else padding0(); 00025 } 00026 } 00027 } 00028 } 00029 for (padding = 0; padding < 12*_ledLength*_tapeLength; padding++) { 00030 padding1(); 00031 } 00032 } 00033 00034 void a101::padding1() { 00035 _CKI = 0; 00036 _SDI = 1; 00037 _CKI = 1; 00038 } 00039 00040 void a101::padding0() { 00041 _CKI = 0; 00042 _SDI = 0; 00043 _CKI = 1; 00044 } 00045 00046 void a101::operate() { 00047 for (int i = 0; i < 8; i++) { 00048 padding1(); 00049 } 00050 } 00051 00052 void a101::clear() { 00053 for (int i = 0; i < 32; i++) { 00054 padding0(); 00055 } 00056 00057 wait_us(RESET_DERAY); 00058 00059 for (int tape = 0; tape < _tapeLength; tape++) { 00060 for (int led = 0; led < _ledLength; led++) { 00061 operate(); 00062 for (int bit = 0; bit < 24; bit++) { 00063 padding0(); 00064 } 00065 } 00066 } 00067 for (padding = 0; padding < 12*_ledLength*_tapeLength; padding++) { 00068 padding1(); 00069 } 00070 } 00071
Generated on Sun Jul 24 2022 02:33:02 by
